Class LookaheadIterator<T>

java.lang.Object
eu.bandm.tools.util.LookaheadIterator<T>
All Implemented Interfaces:
Iterator<T>

public class LookaheadIterator<T> extends Object implements Iterator<T>
An iterator which allows arbitrary deep look-ahead for an underlying iterator.
  • Constructor Details

    • LookaheadIterator

      public LookaheadIterator(Iterable<? extends T> things)
      Constructor which sets the underlying iterator.
    • LookaheadIterator

      @SafeVarargs public LookaheadIterator(T... things)
      Constructor which iterates over the given things.
    • LookaheadIterator

      public LookaheadIterator(Iterator<? extends T> it)
  • Method Details

    • hasNext

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

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

      public void remove()
      Unsupported Operation
      Specified by:
      remove in interface Iterator<T>
    • hasNext

      public boolean hasNext(int index)
      Returns whether the next (index+1) calls to hasNext() will be successful.
    • lookahead

      public T lookahead(int index)
      Returns the object delivered by the last of (index+1) calls of next(), as defined with the original iterator.