Package generic.util
Class WrappingPeekableIterator<T>
- java.lang.Object
-
- generic.util.WrappingPeekableIterator<T>
-
- Type Parameters:
T
- the type of the iterator
- All Implemented Interfaces:
PeekableIterator<T>
,java.util.Iterator<T>
public class WrappingPeekableIterator<T> extends java.lang.Object implements PeekableIterator<T>
An implementation ofPeekableIterator
that can take a JavaIterator
and wrap it to implement thePeekableIterator
interface.
-
-
Constructor Summary
Constructors Constructor Description WrappingPeekableIterator(java.util.Iterator<T> iterator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
T
next()
T
peek()
Returns the item that would be returned by callingIterator.next()
, but does not increment the iterator as next would.void
remove()
-
-
-
Constructor Detail
-
WrappingPeekableIterator
public WrappingPeekableIterator(java.util.Iterator<T> iterator)
-
-
Method Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<T>
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<T>
-
peek
public T peek() throws java.util.NoSuchElementException
Description copied from interface:PeekableIterator
Returns the item that would be returned by callingIterator.next()
, but does not increment the iterator as next would.- Specified by:
peek
in interfacePeekableIterator<T>
- Returns:
- the item that would be returned by calling
Iterator.next()
- Throws:
java.util.NoSuchElementException
-
-