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 removed.
Concurrent modifications are not directly supported, and for most collection implementations will throw a ConcurrentModificationException.
| Modifier and Type | Field and Description |
|---|---|
| private ListIterator | iterator
The current list iterator |
| private final List | list
The list to base the iterator on |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public void | add(final E
the element to insert obj)Implements java. |
| public boolean | Returns: true if there are more elementsImplements java. |
| public boolean | Returns: true if there are more elementsImplements java. |
| public E | Returns: the object after the last element returnedImplements java. |
| public int | Returns: the index of the element that would be returned if next() were calledImplements java. next.
|
| public E | Returns: the object before the last element returnedImplements java. |
| public int | Returns: the index of the element that would be returned if previous() were calledImplements java. previous.
|
| public void | remove()
Overrides default java. Implements java. |
| public void | reset()
Implements org. |
| public void | set(final E
the element with which to replace the last element returned obj)Implements java. next or
previous.
|
| public int |
| iterator | back to summary |
|---|---|
| private ListIterator<E> iterator The current list iterator | |
| list | back to summary |
|---|---|
| private final List<E> list The list to base the iterator on | |
| LoopingListIterator | back to summary |
|---|---|
| public LoopingListIterator(final List<E> list) 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.
| |
| _reset | back to summary |
|---|---|
| private void _reset() | |
| add | back to summary |
|---|---|
| public void add(final E obj) Implements java. Inserts the specified element into the underlying list.
The element is inserted before the next element that would be
returned by
This feature is only supported if the underlying list's
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Returns whether this iterator has any more elements.
Returns false only if the list originally had zero elements, or
all elements have been
| |
| hasPrevious | back to summary |
|---|---|
| public boolean hasPrevious() Implements java. Returns whether this iterator has any more previous elements.
Returns false only if the list originally had zero elements, or
all elements have been
| |
| next | back to summary |
|---|---|
| public E next() Implements java. Returns the next object in the list. If at the end of the list, returns the first element.
| |
| nextIndex | back to summary |
|---|---|
| public int nextIndex() Implements java. Returns the index of the element that would be returned by a
subsequent call to 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.
| |
| previous | back to summary |
|---|---|
| public E previous() Implements java. 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.
| |
| previousIndex | back to summary |
|---|---|
| public int previousIndex() Implements java. Returns the index of the element that would be returned by a
subsequent call to 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.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Implements java. Removes the previously retrieved item from the underlying list.
This feature is only supported if the underlying list's
This method can only be called after at least one
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Resets the iterator back to the start of the list.
| |
| set | back to summary |
|---|---|
| public void set(final E obj) Implements java. Replaces the last element that was returned by
This feature is only supported if the underlying list's
| |
| size | back to summary |
|---|---|
| public int size() Gets the size of the list underlying the iterator.
| |