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
@CheckForNull private E peekedElement
public PeekingImpl(java.util.Iterator<? extends E> iterator)
public boolean hasNext()
hasNext in interface java.util.Iterator<E>public E next()
PeekingIteratorThe 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()
PeekingIteratorImplementations 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()
PeekingIteratorCalls 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>