java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<E>
net.i2p.router.util.CachedIteratorArrayList<E>
- Type Parameters:
E- type of elements in this list
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess, SequencedCollection<E>
ArrayList with per-thread cached iterators for reduced object allocation overhead.
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 ArrayList.remove(int) operations with proper fail-fast behavior on concurrent modifications.
- See Also:
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classAn iterator reused across traversals of the list.Field Summary
FieldsModifier and TypeFieldDescriptionThread local.private static final longPinned for serialized-form compatibility.Fields inherited from class AbstractList
modCountConstructor Summary
ConstructorsConstructorDescriptionCreates a new empty CachedIteratorArrayList.CachedIteratorArrayList(int initialCapacity) Creates a CachedIteratorArrayList with the specified initial capacity.CachedIteratorArrayList(Collection<? extends E> c) Creates a CachedIteratorArrayList containing the elements of the given collection.Method Summary
All MethodsMethods inherited from class ArrayList
add, add, addAll, addAll, addFirst, addLast, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class AbstractCollection
containsAll, toStringMethods inherited from interface Collection
parallelStream, stream, toArrayMethods inherited from interface List
containsAll, reversed
Field Details
serialVersionUID
private static final long serialVersionUIDPinned for serialized-form compatibility.- See Also:
iterator
Thread local.
Constructor Details
CachedIteratorArrayList
public CachedIteratorArrayList()Creates a new empty CachedIteratorArrayList.CachedIteratorArrayList
Creates a CachedIteratorArrayList containing the elements of the given collection.- Parameters:
c- the collection whose elements are to be placed into this list
CachedIteratorArrayList
public CachedIteratorArrayList(int initialCapacity) Creates a CachedIteratorArrayList with the specified initial capacity.- Parameters:
initialCapacity- the initial capacity of the list
Method Details