@DoNotMock(value="Use Iterators.peekingIterator") @GwtCompatible public interface PeekingIterator<E> extends Iterator<E>
See the Guava User Guide article on PeekingIterator
.
Modifier and Type | Method and 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).
|
forEachRemaining, hasNext
E peek()
Calls to peek()
should not change the state of the iteration, except that it
may prevent removal of the most recent element via remove()
.
NoSuchElementException
- if the iteration has no more elements according to Iterator.hasNext()
@CanIgnoreReturnValue E next()
void remove()
Iterator.next()
. 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.
Implementations may or may not support removal when a call to peek()
has occurred
since the most recent call to next()
.
Copyright © 2010–2020. All rights reserved.