Class PeekMarkIterator<E>
java.lang.Object
org.eclipse.rdf4j.query.algebra.evaluation.iterator.PeekMarkIterator<E>
- All Implemented Interfaces:
AutoCloseable
,Iterator<E>
,CloseableIteration<E>
An iterator that allows to peek at the next element without consuming it. It also allows to mark the current position
and reset to that position.
- Author:
- HÃ¥vard M. Ottestad
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this iteration, freeing any resources that it is holding.boolean
hasNext()
void
mark()
Mark the current position so that the iterator can be reset to the current state.next()
peek()
void
reset()
Reset the iterator to the marked position.void
unmark()
Unmark the iterator.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.rdf4j.common.iteration.CloseableIteration
stream
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
PeekMarkIterator
-
-
Method Details
-
hasNext
-
next
-
peek
- Returns:
- the next element without consuming it, or null if there are no more elements
-
mark
-
reset
public void reset()Reset the iterator to the marked position. Resetting an iterator multiple times will always reset to the same position. Resetting an iterator turns off marking. If the iterator was reset previously and the iterator has advanced beyond the point where reset was initially called, then the iterator can no longer be reset because there will be elements that were not stored while the iterator was marked and resetting will cause these elements to be lost. -
close
public void close()Description copied from interface:CloseableIteration
Closes this iteration, freeing any resources that it is holding. If the iteration has already been closed then invoking this method has no effect.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseableIteration<E>
-
unmark
public void unmark()Unmark the iterator. This will cause the iterator to stop buffering elements. If the iterator was recently reset and there are still elements in the buffer, then these elements will still be returned by next().
-