clone method

  1. @override
Peekable<T> clone()
override

An iterator which is a "clone" of the original iterator. Iterating through the original or the clone will not affect the other. Do not modify the original collection the original Iterable is based on while iterating. See Clone for more information.

Implementation

@override
Peekable<T> clone() {
  final temp = Clone._trackable(_iterator);
  _iterator = temp;
  if (_hasPeaked) {
    return Peekable(_PrefixedIterator(_peeked, Clone._clone(temp)));
  }
  return Peekable(Clone._clone(temp));
}