E - type of elements in this listpublic class CachedIteratorArrayList<E> extends ArrayList<E>
Extends ArrayList to provide per-thread reusable iterator instances, avoiding the creation of new iterator objects during repeated iteration operations. This reduces garbage collection pressure and improves performance for frequently traversed collections.
Each thread gets its own cached iterator to allow safe concurrent iteration. Iterator state is maintained between iterations to support the standard iterator contract while allowing remove() operations with proper fail-fast behavior on concurrent modifications.
modCount| Constructor and Description |
|---|
CachedIteratorArrayList()Creates a new empty CachedIteratorArrayList. |
CachedIteratorArrayList(Collection<? extends E> c)Creates a CachedIteratorArrayList containing the elements of the given collection. |
CachedIteratorArrayList(int initialCapacity)Creates a CachedIteratorArrayList with the specified initial capacity. |
| Modifier and Type | Method and Description |
|---|---|
void | clear()Clear the list and release the ThreadLocal so its entries can be
reclaimed from all threads' ThreadLocalMaps. |
CachedIteratorArrayList | clone()Returns a shallow copy of this list. |
Iterator<E> | iterator()Returns a per-thread cached iterator over the elements in this list. |
add, add, addAll, addAll, 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)
c - the collection whose elements are to be placed into this listpublic CachedIteratorArrayList(int initialCapacity)
initialCapacity - the initial capacity of the listpublic void clear()
public CachedIteratorArrayList clone()