| java.lang.Object org.apache.commons.collections.iterators.LoopingListIterator
LoopingListIterator | public class LoopingListIterator implements ResettableListIterator(Code) | | A ListIterator that restarts when it reaches the end or when it
reaches the beginning.
The iterator will loop continuously around the provided list,
unless there are no elements in the collection to begin with, or
all of the elements have been
LoopingListIterator.remove removed .
Concurrent modifications are not directly supported, and for most
collection implementations will throw a
ConcurrentModificationException.
since: Commons Collections 3.2 version: $Revision: 405920 $ $Date: 2006-05-12 23:48:04 +0100 (Fri, 12 May 2006) $ author: Eric Crampton |
LoopingListIterator | public LoopingListIterator(List list)(Code) | | Constructor that wraps a list.
There is no way to reset a ListIterator instance without
recreating it from the original source, so the List must be
passed in and a reference to it held.
Parameters: list - the list to wrap throws: NullPointerException - if the list it null |
add | public void add(Object obj)(Code) | | Inserts the specified element into the underlying list.
The element is inserted before the next element that would be
returned by
LoopingListIterator.next , if any, and after the next element
that would be returned by
LoopingListIterator.previous , if any.
This feature is only supported if the underlying list's
List.listIterator method returns an implementation
that supports it.
Parameters: obj - the element to insert throws: UnsupportedOperationException - if the add method is notsupported by the iterator implementation of the underlying list |
hasNext | public boolean hasNext()(Code) | | Returns whether this iterator has any more elements.
Returns false only if the list originally had zero elements, or
all elements have been
LoopingListIterator.remove removed .
true if there are more elements |
hasPrevious | public boolean hasPrevious()(Code) | | Returns whether this iterator has any more previous elements.
Returns false only if the list originally had zero elements, or
all elements have been
LoopingListIterator.remove removed .
true if there are more elements |
next | public Object next()(Code) | | Returns the next object in the list.
If at the end of the list, returns the first element.
the object after the last element returned throws: NoSuchElementException - if there are no elements in the list |
nextIndex | public int nextIndex()(Code) | | Returns the index of the element that would be returned by a
subsequent call to
LoopingListIterator.next .
As would be expected, if the iterator is at the physical end of
the underlying list, 0 is returned, signifying the beginning of
the list.
the index of the element that would be returned if next() were called throws: NoSuchElementException - if there are no elements in the list |
previous | public Object previous()(Code) | | Returns the previous object in the list.
If at the beginning of the list, return the last element. Note
that in this case, traversal to find that element takes linear time.
the object before the last element returned throws: NoSuchElementException - if there are no elements in the list |
previousIndex | public int previousIndex()(Code) | | Returns the index of the element that would be returned by a
subsequent call to
LoopingListIterator.previous .
As would be expected, if at the iterator is at the physical
beginning of the underlying list, the list's size minus one is
returned, signifying the end of the list.
the index of the element that would be returned if previous() were called throws: NoSuchElementException - if there are no elements in the list |
reset | public void reset()(Code) | | Resets the iterator back to the start of the list.
|
size | public int size()(Code) | | Gets the size of the list underlying the iterator.
the current list size |
|
|