The first call to next() will return the last element
from the list, and so on. The hasNext() method works
in concert with the next() method as expected.
However, the nextIndex() method returns the correct
index in the list, thus it starts high and reduces as the iteration
continues. The previous methods work similarly.
| Modifier and Type | Field and Description |
|---|---|
| private ListIterator | iterator
The list iterator being wrapped. |
| private final List | list
The list being wrapped. |
| private boolean | validForUpdate
Flag to indicate if updating is possible at the moment. |
| Access | Constructor and Description |
|---|---|
| public | ReverseListIterator(final List<E>
the list to create a reversed iterator for list)Constructor that wraps a list. |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(final E
the object to add obj)Implements java. |
| public boolean | Returns: true if there is another elementImplements java. |
| public boolean | Returns: true if there is a previous elementImplements java. |
| public E | Returns: the next element in the iteratorImplements java. |
| public int | Returns: the index of the next element in the iteratorImplements java. |
| public E | Returns: the previous element in the iteratorImplements java. |
| public int | Returns: the index of the previous element in the iteratorImplements java. |
| public void | remove()
Overrides default java. Implements java. |
| public void | reset()
Implements org. |
| public void | set(final E
the object to set obj)Implements java. |
| iterator | back to summary |
|---|---|
| private ListIterator<E> iterator The list iterator being wrapped. | |
| list | back to summary |
|---|---|
| private final List<E> list The list being wrapped. | |
| validForUpdate | back to summary |
|---|---|
| private boolean validForUpdate Flag to indicate if updating is possible at the moment. | |
| ReverseListIterator | back to summary |
|---|---|
| public ReverseListIterator(final List<E> list) Constructor that wraps a list.
| |
| add | back to summary |
|---|---|
| public void add(final E obj) Implements java. Adds a new element to the list between the next and previous elements.
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Checks whether there is another element.
| |
| hasPrevious | back to summary |
|---|---|
| public boolean hasPrevious() Implements java. Checks whether there is a previous element.
| |
| next | back to summary |
|---|---|
| public E next() Implements java. Gets the next element. The next element is the previous in the list.
| |
| nextIndex | back to summary |
|---|---|
| public int nextIndex() Implements java. Gets the index of the next element.
| |
| previous | back to summary |
|---|---|
| public E previous() Implements java. Gets the previous element. The next element is the previous in the list.
| |
| previousIndex | back to summary |
|---|---|
| public int previousIndex() Implements java. Gets the index of the previous element.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Implements java. Removes the last returned element.
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Resets the iterator back to the start (which is the end of the list as this is a reversed iterator)
| |
| set | back to summary |
|---|---|
| public void set(final E obj) Implements java. Replaces the last returned element.
| |