private static class Iterators.PeekingImpl<E> extends java.lang.Object implements PeekingIterator<E>
Modifier and Type | Field and Description |
---|---|
private boolean |
hasPeeked |
private java.util.Iterator<? extends E> |
iterator |
private E |
peekedElement |
Constructor and Description |
---|
PeekingImpl(java.util.Iterator<? extends E> iterator) |
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext() |
E |
next() |
E |
peek()
Returns the next element in the iteration, without advancing the iteration.
|
void |
remove() |
private final java.util.Iterator<? extends E> iterator
private boolean hasPeeked
private E peekedElement
public PeekingImpl(java.util.Iterator<? extends E> iterator)
public boolean hasNext()
hasNext
in interface java.util.Iterator<E>
public E next()
PeekingIterator
The objects returned by consecutive calls to PeekingIterator.peek()
then PeekingIterator.next()
are guaranteed to be equal to each other.
next
in interface PeekingIterator<E>
next
in interface java.util.Iterator<E>
public void remove()
PeekingIterator
Implementations may or may not support removal when a call to PeekingIterator.peek()
has occurred since the most recent call to PeekingIterator.next()
.
remove
in interface PeekingIterator<E>
remove
in interface java.util.Iterator<E>
public E peek()
PeekingIterator
Calls to peek()
should not change the state of the iteration,
except that it may prevent removal of the most recent element via
PeekingIterator.remove()
.
peek
in interface PeekingIterator<E>