Class ReusableIterator<T>
- java.lang.Object
-
- net.automatalib.common.util.collection.ReusableIterator<T>
-
- Type Parameters:
T
- type of elements to iterate.
- All Implemented Interfaces:
Iterable<T>
public class ReusableIterator<T> extends Object implements Iterable<T>
A utility class that allows to reuse anIterator
.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 Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterator<T>
iterator()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-