com.google.common.collect
Interface PeekingIterator<E>

All Superinterfaces:
Iterator<E>

public interface PeekingIterator<E>
extends Iterator<E>

An iterator that supports a one-element lookahead while iterating.

Author:
Mick Killianey

Method Summary
 E peek()
          Returns the next element in the iteration without advancing the iteration.
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Method Detail

peek

E peek()
Returns the next element in the iteration without advancing the iteration.

If possible, calls to peek() should not affect the iteration. As is the case with most Iterators, modifications to the underlying iteration may have unanticipated results.

If there are no remaining elements in the iteration, peek() will throw a NoSuchElementException. (A null return value does not indicate that this iterator has reached the end of its iteration.)

Usage note: Implementations may, but are not required to, support remove() following a call to peek().

Throws:
NoSuchElementException - if the iteration has no more elements.