Class PushbackIterator<E>
java.lang.Object
org.apache.commons.collections4.iterators.PushbackIterator<E>
- Type Parameters:
- E- the type of elements returned by this iterator.
- All Implemented Interfaces:
- Iterator<E>
Decorates an iterator to support pushback of elements.
 
 The decorator stores the pushed back elements in a LIFO manner: the last element
 that has been pushed back, will be returned as the next element in a call to next().
 
 The decorator does not support the removal operation. Any call to remove() will
 result in an UnsupportedOperationException.
 
- Since:
- 4.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanhasNext()next()voidPush back the given element to the iterator.static <E> PushbackIterator<E> pushbackIterator(Iterator<? extends E> iterator) Decorates the specified iterator to support one-element lookahead.voidremove()This iterator will always throw anUnsupportedOperationException.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.IteratorforEachRemaining
- 
Constructor Details- 
PushbackIteratorConstructs a new instance.- Parameters:
- iterator- the iterator to decorate
 
 
- 
- 
Method Details- 
pushbackIteratorDecorates the specified iterator to support one-element lookahead.If the iterator is already a PushbackIteratorit is returned directly.- Type Parameters:
- E- the element type
- Parameters:
- iterator- the iterator to decorate
- Returns:
- a new peeking iterator
- Throws:
- NullPointerException- if the iterator is null
 
- 
hasNext
- 
next
- 
pushback
- 
removeThis iterator will always throw anUnsupportedOperationException.- Specified by:
- removein interface- Iterator<E>
- Throws:
- UnsupportedOperationException- always
 
 
-