E - type of elements in this listpublic class CachedIteratorArrayList<E> extends ArrayList<E>
Extends ArrayList to provide a single reusable iterator instance, avoiding the creation of new iterator objects during repeated iteration operations. This reduces garbage collection pressure and improves performance for frequently traversed collections.
Maintains iterator state between iterations to support the standard iterator contract while allowing remove() operations with proper fail-fast behavior on concurrent modifications.
Particularly useful in scenarios where the same collection is iterated over multiple times, providing both the convenience of an iterator interface and the performance benefits of object reuse.
modCount| Constructor and Description |
|---|
CachedIteratorArrayList() |
CachedIteratorArrayList(Collection<? extends E> c) |
CachedIteratorArrayList(int initialCapacity) |
| Modifier and Type | Method and Description |
|---|---|
Iterator<E> |
iterator() |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeequals, hashCodecontainsAll, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcontainsAll, equals, hashCodeparallelStream, streampublic CachedIteratorArrayList()
public CachedIteratorArrayList(Collection<? extends E> c)
public CachedIteratorArrayList(int initialCapacity)