Interface Iterators.MultipleLookaheadIterator<E>

Type Parameters:
E - the element type
All Superinterfaces:
Iterator<E>
Enclosing class:
Iterators

public static interface Iterators.MultipleLookaheadIterator<E> extends Iterator<E>
Iterators which allow arbitrary deep look-ahead.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    hasNext(int k)
    Checks whether there are k+1 more elements.
    lookahead(int k)
    Returns the element that comes after k skipped elements, without changing the state of the iterator.

    Methods inherited from interface java.util.Iterator

    forEachRemaining, hasNext, next, remove
  • Method Details

    • hasNext

      boolean hasNext(int k)
      Checks whether there are k+1 more elements.

      hasNext(0) is equivalent to hasNext().

      Parameters:
      k - a nonnegative number
      Returns:
      true if next may be called k+1 times
      Throws:
      IllegalArgumentException - if k is negative
      See Also:
    • lookahead

      E lookahead(int k)
      Returns the element that comes after k skipped elements, without changing the state of the iterator.

      lookahead(0) returns the element that would also be returned by next.

      Parameters:
      k - a nonnegative number
      Returns:
      the k+1-th element
      Throws:
      NoSuchElementException - if there are not enough remaining elements