net.i2p.router.util

## Class CachedIteratorArrayList<E>

- 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

      public class CachedIteratorArrayList<E>
      extends ArrayList<E>

  ArrayList with cached iterator for reduced object allocation overhead.

  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.

  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class java.util.AbstractList

      `modCount`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CachedIteratorArrayList()`
    `CachedIteratorArrayList(Collection<? extends E> c)`
    `CachedIteratorArrayList(int initialCapacity)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Iterator<E>` | `iterator()`

    - ### Methods inherited from class java.util.ArrayList

      `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, trimToSize`

    - ### Methods inherited from class java.util.AbstractList

      `equals, hashCode`

    - ### Methods inherited from class java.util.AbstractCollection

      `containsAll, toString`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.List

      `containsAll, equals, hashCode`

    - ### Methods inherited from interface java.util.Collection

      `parallelStream, stream`

- - ### Constructor Detail

    - #### CachedIteratorArrayList

          public CachedIteratorArrayList()

    - #### CachedIteratorArrayList

          public CachedIteratorArrayList(Collection<? extends E> c)

    - #### CachedIteratorArrayList

          public CachedIteratorArrayList(int initialCapacity)

  - ### Method Detail

    - #### iterator

          public Iterator<E> iterator()

      Specified by:
        `iterator` in interface `Iterable<E>`
      Specified by:
        `iterator` in interface `Collection<E>`
      Specified by:
        `iterator` in interface `List<E>`
      Overrides:
        `iterator` in class `ArrayList<E>`