Class PagingIterator<T>
java.lang.Object
com.github.basking2.sdsai.itrex.iterators.PagingIterator<T>
- Type Parameters:
T
- The type of elements to page.
This iterator wraps its input iterator in
HeadIterator
s until no elements remain in the source iterator.
This structures the computation into pages of data. Users of this class must take care,
all HeadIterator
instances share the source iterator and calling them in parallel will
yield unexpected results.
A returned iterator should be exhausted before another is called.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
hasNext()
Returns true if the source iterator has more elements to be paged over.next()
Return aPagingIterator
for the source iterator.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
PagingIterator
-
-
Method Details
-
hasNext
public boolean hasNext()Returns true if the source iterator has more elements to be paged over. If the user is consuming an iterator returned by a call tonext()
, this may return inconsistent results. -
next
Return aPagingIterator
for the source iterator. The previously returned iterator must be empty.- Specified by:
next
in interfaceIterator<T>
- Returns:
- A
HeadIterator
that pages over elements of the input iterator. - Throws:
IllegalStateException
- when the previously returned iterator is not fully consumed.
-