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.
| Modifier and Type | Field and Description |
|---|---|
| private final Deque | items
The LIFO queue containing the pushed back items. |
| private final Iterator | iterator
The iterator being decorated. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public E | |
| public void | pushback(final E
the element to push back to the iterator item)Push back the given element to the iterator. |
| public static < the element type E> PushbackIterator | Returns: a new peeking iteratorthe iterator to decorate iterator)Decorates the specified iterator to support one-element lookahead. |
| public void | remove()
Overrides default java. UnsupportedOperationException.
|
| items | back to summary |
|---|---|
| private final Deque<E> items The LIFO queue containing the pushed back items. | |
| iterator | back to summary |
|---|---|
| private final Iterator<? extends E> iterator The iterator being decorated. | |
| PushbackIterator | back to summary |
|---|---|
| public PushbackIterator(final Iterator<? extends E> iterator) Constructor.
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public E next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| pushback | back to summary |
|---|---|
| public void pushback(final E item) Push back the given element to the iterator.
Calling
| |
| pushbackIterator | back to summary |
|---|---|
| public static <E> PushbackIterator Decorates the specified iterator to support one-element lookahead.
If the iterator is already a
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. This iterator will always throw an
| |