| Index: sdk/lib/core/queue.dart
|
| diff --git a/sdk/lib/core/queue.dart b/sdk/lib/core/queue.dart
|
| index acb9c04772288b33dd835a5b274e0ef4f53cef79..15ebed34fb3d6790a161311d6285dc9761b30ec1 100644
|
| --- a/sdk/lib/core/queue.dart
|
| +++ b/sdk/lib/core/queue.dart
|
| @@ -307,7 +307,7 @@ class DoubleLinkedQueue<E> implements Queue<E> {
|
| return other;
|
| }
|
|
|
| - _DoubleLinkedQueueIterator<E> iterator() {
|
| + _DoubleLinkedQueueIterator<E> get iterator {
|
| return new _DoubleLinkedQueueIterator<E>(_sentinel);
|
| }
|
|
|
| @@ -318,21 +318,24 @@ class DoubleLinkedQueue<E> implements Queue<E> {
|
|
|
| class _DoubleLinkedQueueIterator<E> implements Iterator<E> {
|
| final _DoubleLinkedQueueEntrySentinel<E> _sentinel;
|
| - DoubleLinkedQueueEntry<E> _currentEntry;
|
| + DoubleLinkedQueueEntry<E> _currentEntry = null;
|
|
|
| - _DoubleLinkedQueueIterator(_DoubleLinkedQueueEntrySentinel this._sentinel) {
|
| - _currentEntry = _sentinel;
|
| - }
|
| + _DoubleLinkedQueueIterator(this._sentinel);
|
|
|
| - bool get hasNext {
|
| - return !identical(_currentEntry._next, _sentinel);
|
| + bool moveNext() {
|
| + // [:null:] means that the iterator hasn't moved yet.
|
| + // When it is set to the sentinel, then it is at the end.
|
| + if (identical(_currentEntry, _sentinel)) return false;
|
| + if (_currentEntry == null) _currentEntry = _sentinel;
|
| + _currentEntry = _currentEntry._next;
|
| + return !identical(_currentEntry, _sentinel);
|
| }
|
|
|
| - E next() {
|
| - if (!hasNext) {
|
| - throw new StateError("No more elements");
|
| + E get current {
|
| + if (_currentEntry != null && !identical(_currentEntry, _sentinel)) {
|
| + return _currentEntry.element;
|
| }
|
| - _currentEntry = _currentEntry._next;
|
| - return _currentEntry.element;
|
| + // TODO(floitsch): adapt error message.
|
| + throw new StateError("No more elements");
|
| }
|
| }
|
|
|