The iterator will loop continuously around the provided elements, unless
there are no elements in the collection to begin with, or all 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 final Collection | collection
The collection to base the iterator on |
| private Iterator | iterator
The current iterator |
| Access | Constructor and Description |
|---|---|
| public | LoopingIterator(final Collection<? extends E>
the collection to wrap coll)Constructor that wraps a collection. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if there are more elementsImplements java. |
| public E | Returns: the next objectImplements java. |
| public void | remove()
Overrides default java. |
| public void | reset()
Implements org. |
| public int |
| collection | back to summary |
|---|---|
| private final Collection<? extends E> collection The collection to base the iterator on | |
| iterator | back to summary |
|---|---|
| private Iterator<? extends E> iterator The current iterator | |
| LoopingIterator | back to summary |
|---|---|
| public LoopingIterator(final Collection<? extends E> coll) Constructor that wraps a collection. There is no way to reset an Iterator instance without recreating it from the original source, so the Collection must be passed in.
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Has the iterator any more elements.
Returns false only if the collection originally had zero elements, or
all the elements have been
| |
| next | back to summary |
|---|---|
| public E next() Implements java. Returns the next object in the collection. If at the end of the collection, return the first element.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Removes the previously retrieved item from the underlying collection.
This feature is only supported if the underlying collection'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 collection.
| |
| size | back to summary |
|---|---|
| public int size() Gets the size of the collection underlying the iterator.
| |