com.levigo.util.base.collections
Class PeekableIteratorWrapper<T>

java.lang.Object
  extended by com.levigo.util.base.collections.PeekableIteratorWrapper<T>
Type Parameters:
T - The type of the Iterator (has to be the same as the Iterator given into the PeekableIterator constructor)
All Implemented Interfaces:
PeekableIterator<T>, Iterator<T>

public class PeekableIteratorWrapper<T>
extends Object
implements Iterator<T>, PeekableIterator<T>

This implementation wraps another Iterator and provides the peeking functionality

Author:
Francois Fernandes

Constructor Summary
PeekableIteratorWrapper(Iterator<T> rootIter)
           
 
Method Summary
 boolean hasNext()
          
 T next()
          
 T peek()
          Peeks the very next element.
 void remove()
          removal of elements is not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeekableIteratorWrapper

public PeekableIteratorWrapper(Iterator<T> rootIter)
Method Detail

hasNext

public boolean hasNext()
Description copied from interface: PeekableIterator

Specified by:
hasNext in interface PeekableIterator<T>
Specified by:
hasNext in interface Iterator<T>

next

public T next()
Description copied from interface: PeekableIterator

Specified by:
next in interface PeekableIterator<T>
Specified by:
next in interface Iterator<T>

peek

public T peek()
Description copied from interface: PeekableIterator
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();

Specified by:
peek in interface PeekableIterator<T>
Returns:
the very next element without consuming it

remove

public void remove()
removal of elements is not supported. This method will throw a UnsupportedOperationException

Specified by:
remove in interface PeekableIterator<T>
Specified by:
remove in interface Iterator<T>


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