Class LookaheadIterator<T>

java.lang.Object
org.archive.util.iterator.LookaheadIterator<T>
All Implemented Interfaces:
Iterator<T>
Direct Known Subclasses:
LineReadingIterator, TransformingIteratorWrapper

public abstract class LookaheadIterator<T> extends Object implements Iterator<T>
Superclass for Iterators which must probe ahead to know if a 'next' exists, and thus have a cached next between a call to hasNext() and next().
Author:
gojomo
  • Field Details

    • next

      protected T next
  • Constructor Details

    • LookaheadIterator

      public LookaheadIterator()
  • Method Details

    • hasNext

      public boolean hasNext()
      Test whether any items remain; loads next item into holding 'next' field.
      Specified by:
      hasNext in interface Iterator<T>
      See Also:
    • lookahead

      protected abstract boolean lookahead()
      Caches the next item if available.
      Returns:
      true if there was a next item to cache, false otherwise
    • next

      public T next()
      Return the next item.
      Specified by:
      next in interface Iterator<T>
      See Also:
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<T>