java.lang.Object
net.i2p.router.util.CachedIteratorArrayList.CachedIterator<E>
- Type Parameters:
E- the element type of the list
- All Implemented Interfaces:
Serializable, Iterator<E>
- Enclosing class:
CachedIteratorArrayList<E>
private static class CachedIteratorArrayList.CachedIterator<E>extends Object implements Iterator<E>, Serializable
An iterator reused across traversals of the list.
Field Summary
FieldsModifier and TypeFieldDescription(package private) intIndex of element to be returned by subsequent call to next.(package private) intThe modCount value that the iterator believes that the backing List should have.(package private) intIndex of element returned by most recent call to next or previous.private WeakReference<CachedIteratorArrayList<E>> Reference to the owning list, set on each call toCachedIteratorArrayList.iterator().Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescription(package private) final voidFails if the list changed since the iterator was created.booleanhasNext()Whether there is a next element available.private CachedIteratorArrayList<E> list()Gives the list this iterator belongs to.next()The next element in the iteration.voidremove()Removes from the underlying list the last element returned bynext().(package private) voidreset(CachedIteratorArrayList<E> list) Reset iterator state for the given list.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterator
forEachRemaining
Field Details
cursor
int cursorIndex of element to be returned by subsequent call to next.lastRet
int lastRetIndex of element returned by most recent call to next or previous. Reset to -1 if this element is deleted by a call to remove.expectedModCount
int expectedModCountThe modCount value that the iterator believes that the backing List should have. If this expectation is violated, the iterator has detected concurrent modification.listRef
Reference to the owning list, set on each call toCachedIteratorArrayList.iterator().
Constructor Details
CachedIterator
private CachedIterator()An iterator that keeps its own position.
Method Details
reset
Reset iterator state for the given list.- Parameters:
list- the list to iterate
list
Gives the list this iterator belongs to.- Returns:
- the owning list, null if it was collected
hasNext
next
The next element in the iteration.- Specified by:
nextin interfaceIterator<E>- Returns:
- the next element
- Throws:
NoSuchElementException- if the iteration is finished
remove
checkForComodification
Fails if the list changed since the iterator was created.- Parameters:
l- the list to check