Package com.google.common.collect
Class Iterators.PeekingImpl<E>
java.lang.Object
com.google.common.collect.Iterators.PeekingImpl<E>
- All Implemented Interfaces:
PeekingIterator<E>
,Iterator<E>
- Enclosing class:
Iterators
Implementation of PeekingIterator that avoids peeking unless necessary.
-
Field Details
-
iterator
-
hasPeeked
private boolean hasPeeked -
peekedElement
-
-
Constructor Details
-
PeekingImpl
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
Description copied from interface:PeekingIterator
The objects returned by consecutive calls to
PeekingIterator.peek()
thenPeekingIterator.next()
are guaranteed to be equal to each other. -
remove
public void remove()Description copied from interface:PeekingIterator
Implementations may or may not support removal when a call to
PeekingIterator.peek()
has occurred since the most recent call toPeekingIterator.next()
. -
peek
Description copied from interface:PeekingIterator
Returns the next element in the iteration, without advancing the iteration.Calls to
peek()
should not change the state of the iteration, except that it may prevent removal of the most recent element viaPeekingIterator.remove()
.- Specified by:
peek
in interfacePeekingIterator<E>
-