Dart API Referencedart:coreSequenceIterator<E>

SequenceIterator<E> class

Iterates over a Sequence in growing index order.

class SequenceIterator<E> implements Iterator<E> {
  Sequence<E> _sequence;
  int _position;
  SequenceIterator(this._sequence) : _position = 0;
  bool hasNext() => _position < _sequence.length;
  E next() {
    if (hasNext()) return _sequence[_position++];
    throw new NoMoreElementsException();
  }
}

Implements

Iterator<E>

Constructors

new SequenceIterator(Sequence<E> _sequence) #

SequenceIterator(this._sequence) : _position = 0;

Methods

bool hasNext() #

Returns whether the Iterator has elements left.

docs inherited from Iterator<E>
bool hasNext() => _position < _sequence.length;

E next() #

Gets the next element in the iteration. Throws a NoMoreElementsException if no element is left.

docs inherited from Iterator<E>
E next() {
  if (hasNext()) return _sequence[_position++];
  throw new NoMoreElementsException();
}