| Index: sdk/lib/core/sequences.dart
|
| diff --git a/sdk/lib/core/sequences.dart b/sdk/lib/core/sequences.dart
|
| index 32a3b4088ef23cea008323f4662884c5b151a635..5a0af69405def37a61b485747e3baf2f340cd0e1 100644
|
| --- a/sdk/lib/core/sequences.dart
|
| +++ b/sdk/lib/core/sequences.dart
|
| @@ -33,7 +33,7 @@ abstract class Sequence<T> {
|
| abstract class SequenceCollection<E> implements Collection<E>, Sequence<E> {
|
| // The class is intended for use as a mixin as well.
|
|
|
| - Iterator<E> iterator() => new SequenceIterator(sequence);
|
| + Iterator<E> get iterator => new SequenceIterator(sequence);
|
|
|
| void forEach(f(E element)) {
|
| for (int i = 0; i < this.length; i++) f(this[i]);
|
| @@ -194,10 +194,18 @@ class SequenceList<E> extends SequenceCollection<E> implements List<E> {
|
| class SequenceIterator<E> implements Iterator<E> {
|
| Sequence<E> _sequence;
|
| int _position;
|
| - SequenceIterator(this._sequence) : _position = 0;
|
| - bool get hasNext => _position < _sequence.length;
|
| - E next() {
|
| - if (hasNext) return _sequence[_position++];
|
| + SequenceIterator(this._sequence) : _position = -1;
|
| + bool moveNext() {
|
| + _position++;
|
| + if (_position < _sequence.length) return true;
|
| + _position = _sequence.length;
|
| + return false;
|
| + }
|
| + E get current {
|
| + if (0 <= _position && _position < _sequence.length) {
|
| + return _sequence[_position];
|
| + }
|
| + // TODO(floitsch): adapt error-message.
|
| throw new StateError("No more elements");
|
| }
|
| }
|
|
|