Package com.google.common.collect
Class Iterators.PeekingImpl<E>
- java.lang.Object
-
- com.google.common.collect.Iterators.PeekingImpl<E>
-
- All Implemented Interfaces:
PeekingIterator<E>,java.util.Iterator<E>
- Enclosing class:
- Iterators
private static class Iterators.PeekingImpl<E> extends java.lang.Object implements PeekingIterator<E>
Implementation of PeekingIterator that avoids peeking unless necessary.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanhasPeekedprivate java.util.Iterator<? extends E>iteratorprivate EpeekedElement
-
Constructor Summary
Constructors Constructor Description PeekingImpl(java.util.Iterator<? extends E> iterator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhasNext()Enext()Epeek()Returns the next element in the iteration, without advancing the iteration.voidremove()
-
-
-
Constructor Detail
-
PeekingImpl
public PeekingImpl(java.util.Iterator<? extends E> iterator)
-
-
Method Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<E>
-
next
public E next()
Description copied from interface:PeekingIteratorThe objects returned by consecutive calls to
PeekingIterator.peek()thenPeekingIterator.next()are guaranteed to be equal to each other.- Specified by:
nextin interfacejava.util.Iterator<E>- Specified by:
nextin interfacePeekingIterator<E>
-
remove
public void remove()
Description copied from interface:PeekingIteratorImplementations may or may not support removal when a call to
PeekingIterator.peek()has occurred since the most recent call toPeekingIterator.next().- Specified by:
removein interfacejava.util.Iterator<E>- Specified by:
removein interfacePeekingIterator<E>
-
peek
public E peek()
Description copied from interface:PeekingIteratorReturns 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:
peekin interfacePeekingIterator<E>
-
-