org.apache.commons.collections.iterators
public class ReverseListIterator extends Object implements ResettableListIterator
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.
Since: Commons Collections 3.2
Version: $Revision: $ $Date: 2006-05-12 23:52:43 +0100 (Fri, 12 May 2006) $
Constructor Summary | |
---|---|
ReverseListIterator(List list)
Constructor that wraps a list.
|
Method Summary | |
---|---|
void | add(Object obj)
Adds a new element to the list between the next and previous elements.
|
boolean | hasNext()
Checks whether there is another element.
|
boolean | hasPrevious()
Checks whether there is a previous element.
|
Object | next()
Gets the next element.
|
int | nextIndex()
Gets the index of the next element.
|
Object | previous()
Gets the previous element.
|
int | previousIndex()
Gets the index of the previous element.
|
void | remove()
Removes the last returned element.
|
void | reset()
Resets the iterator back to the start (which is the
end of the list as this is a reversed iterator) |
void | set(Object obj)
Replaces the last returned element.
|
Parameters: list the list to create a reversed iterator for
Throws: NullPointerException if the list is null
Parameters: obj the object to add
Throws: UnsupportedOperationException if the list is unmodifiable IllegalStateException if the iterator is not in a valid state for set
Returns: true if there is another element
Returns: true if there is a previous element
Returns: the next element in the iterator
Returns: the index of the next element in the iterator
Returns: the previous element in the iterator
Returns: the index of the previous element in the iterator
Throws: UnsupportedOperationException if the list is unmodifiable IllegalStateException if there is no element to remove
Parameters: obj the object to set
Throws: UnsupportedOperationException if the list is unmodifiable IllegalStateException if the iterator is not in a valid state for set