java.lang.Object | |
↳ | org.apache.commons.collections.iterators.ReverseListIterator |
Iterates backwards through a List, starting with the last element and continuing to the first. This is useful for looping around a list in reverse order without needing to actually reverse the list.
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.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor that wraps a list.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a new element to the list between the next and previous elements.
| |||||||||||
Checks whether there is another element.
| |||||||||||
Checks whether there is a previous element.
| |||||||||||
Gets the next element.
| |||||||||||
Gets the index of the next element.
| |||||||||||
Gets the previous element.
| |||||||||||
Gets the index of the previous element.
| |||||||||||
Removes the last returned element.
| |||||||||||
Resets the iterator back to the start (which is the
end of the list as this is a reversed iterator)
| |||||||||||
Replaces the last returned element.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.util.Iterator
| |||||||||||
From interface
java.util.ListIterator
| |||||||||||
From interface
org.apache.commons.collections.ResettableIterator
| |||||||||||
From interface
org.apache.commons.collections.ResettableListIterator
|
Constructor that wraps a list.
list | the list to create a reversed iterator for |
---|
NullPointerException | if the list is null |
---|
Adds a new element to the list between the next and previous elements.
obj | the object to add |
---|
UnsupportedOperationException | if the list is unmodifiable |
---|---|
IllegalStateException | if the iterator is not in a valid state for set |
Checks whether there is another element.
Checks whether there is a previous element.
Gets the next element. The next element is the previous in the list.
Gets the index of the next element.
Gets the previous element. The next element is the previous in the list.
Gets the index of the previous element.
Removes the last returned element.
UnsupportedOperationException | if the list is unmodifiable |
---|---|
IllegalStateException | if there is no element to remove |
Resets the iterator back to the start (which is the end of the list as this is a reversed iterator)
Replaces the last returned element.
obj | the object to set |
---|
UnsupportedOperationException | if the list is unmodifiable |
---|---|
IllegalStateException | if the iterator is not in a valid state for set |