T
- type of elements to iterate.public class ReusableIterator<T> extends Object implements Iterable<T>
Iterator
.
Iterators returned by this class' iterator()
method copy the elements of the given source iterator to a list
as they are requested. Subsequent iterators then traverse the cached list (and continue to copy elements, if they
haven't been requested before) allowing to arbitrarily re-iterate over the elements of the initial iterator.
Constructor and Description |
---|
ReusableIterator(Iterator<T> iterator)
Default constructor.
|
ReusableIterator(Iterator<T> iterator,
List<T> cache)
Constructor that allows to explicitly specify that cache to be used.
|
Modifier and Type | Method and Description |
---|---|
Iterator<T> |
iterator() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
Copyright © 2020. All rights reserved.