|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.collections4.iterators.PushbackIterator<E>
public class PushbackIterator<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.
| Constructor Summary | |
|---|---|
PushbackIterator(Iterator<? extends E> iterator)
Constructor. |
|
| Method Summary | ||
|---|---|---|
boolean |
hasNext()
|
|
E |
next()
|
|
void |
pushback(E item)
Push back the given element to the iterator. |
|
static
|
pushbackIterator(Iterator<? extends E> iterator)
Decorates the specified iterator to support one-element lookahead. |
|
void |
remove()
This iterator will always throw an UnsupportedOperationException. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PushbackIterator(Iterator<? extends E> iterator)
iterator - the iterator to decorate| Method Detail |
|---|
public static <E> PushbackIterator<E> pushbackIterator(Iterator<? extends E> iterator)
If the iterator is already a PeekingIterator it is returned directly.
E - the element typeiterator - the iterator to decorate
IllegalArgumentException - if the iterator is nullpublic void pushback(E item)
Calling next() immediately afterwards will return exactly this element.
item - the element to push back to the iteratorpublic boolean hasNext()
hasNext in interface Iterator<E>public E next()
next in interface Iterator<E>public void remove()
UnsupportedOperationException.
remove in interface Iterator<E>UnsupportedOperationException - always
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||