Package com.google.common.collect
Interface PeekingIterator<E>
-
- All Superinterfaces:
<E>
("Use Iterators.peekingIterator") @GwtCompatible public interface PeekingIterator<E> extends <E>
An iterator that supports a one-element lookahead while iterating.See the Guava User Guide article on .
- Since:
- 2.0
- Author:
- Mick Killianey
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description E
next()
Returns the next element in the iteration.E
peek()
Returns the next element in the iteration, without advancing the iteration.void
remove()
Removes from the underlying collection the last element returned by this iterator (optional operation).
-
-
-
Method Detail
-
peek
E peek()
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 viaremove()
.- Throws:
- if the iteration has no more elements according to
-
next
E next()
Returns the next element in the iteration.The objects returned by consecutive calls to
peek()
thennext()
are guaranteed to be equal to each other.- Specified by:
in interface
<E>
- Returns:
- the next element in the iteration
-
remove
void remove()
Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to .The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called after a call to the method.
Implementations may or may not support removal when a call to
peek()
has occurred since the most recent call tonext()
.
-
-