Type Parameters:
E - type of elements in this list
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess, SequencedCollection<E>

public class CachedIteratorArrayList<E>extends ArrayList<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:
  • Field Details

  • Constructor Details

    • CachedIteratorArrayList

      public CachedIteratorArrayList()
      Creates a new empty CachedIteratorArrayList.
    • CachedIteratorArrayList

      public CachedIteratorArrayList(Collection<? extends E> c)
      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