Class PeekMarkIterator<E>

java.lang.Object
org.eclipse.rdf4j.query.algebra.evaluation.iterator.PeekMarkIterator<E>
All Implemented Interfaces:
AutoCloseable, Iterator<E>, CloseableIteration<E>

@Experimental public class PeekMarkIterator<E> extends Object implements 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
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<E>
    • next

      public E next()
      Specified by:
      next in interface Iterator<E>
    • peek

      public E peek()
      Returns:
      the next element without consuming it, or null if there are no more elements
    • mark

      public void mark()
      Mark the current position so that the iterator can be reset to the current state. This will cause elements to be stored in memory until one of reset(), unmark() or mark() is called.
    • 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 interface AutoCloseable
      Specified by:
      close in interface CloseableIteration<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().