Dart API Referencedart:coreimplHashSetIterator<E>

HashSetIterator<E> Class

Implements

Iterator<E>

Constructors

Code new HashSetIterator(HashSetImplementation<E> set_) #

HashSetIterator(HashSetImplementation<E> set_)
  : _nextValidIndex = -1,
    _entries = set_._backingMap._keys {
  _advance();
}

Methods

Code bool hasNext() #

bool hasNext() {
  if (_nextValidIndex >= _entries.length) return false;
  if (_entries[_nextValidIndex] === HashMapImplementation._DELETED_KEY) {
    // This happens in case the set was modified in the meantime.
    // A modification on the set may make this iterator misbehave,
    // but we should never return the sentinel.
    _advance();
  }
  return _nextValidIndex < _entries.length;
}

Code E next() #

E next() {
  if (!hasNext()) {
    throw const NoMoreElementsException();
  }
  E res = _entries[_nextValidIndex];
  _advance();
  return res;
}