com.levigo.util.base.collections
Interface PeekableIterator<T>

Type Parameters:
T -
All Superinterfaces:
Iterator<T>
All Known Implementing Classes:
PeekableIteratorWrapper

public interface PeekableIterator<T>
extends Iterator<T>

provides an Iterator with peeking functionality. The PeekableIterator makes it possible to make a single element Iterator lookahead.

Author:
Francois Fernandes
See Also:
peek()

Method Summary
 boolean hasNext()
          
 T next()
          
 T peek()
          Peeks the very next element.
 void remove()
          
 

Method Detail

hasNext

boolean hasNext()

Specified by:
hasNext in interface Iterator<T>

next

T next()

Specified by:
next in interface Iterator<T>

peek

T peek()
Peeks the very next element. The element that will be returned by this method is the element that the next call to Iterator.next() would return, with the addition that it will not be consumed directly. The implementation ensures that the following statement will return true: peekableIter.peek() == peekableIter.next();

Returns:
the very next element without consuming it

remove

void remove()

Specified by:
remove in interface Iterator<T>


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.