Class COWArrayList<E>

java.lang.Object
ch.qos.logback.core.util.COWArrayList<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>

@Deprecated(since="2022-01-27") public class COWArrayList<E> extends Object implements List<E>
Deprecated.
This internal logback API is not supported by AEM as a Cloud Service.
A GC-free lock-free thread-safe implementation of the List interface for use cases where iterations over the list vastly out-number modifications on the list.

Underneath, it wraps an instance of CopyOnWriteArrayList and exposes a copy of the array used by that instance.

Typical use:

    COWArrayList list = new COWArrayList(new Integer[0]);

    // modify the list
    list.add(1);
    list.add(2);

    Integer[] intArray = list.asTypedArray();
    int sum = 0;
    // iteration over the array is thread-safe
    for(int i = 0; i invalid input: '<' intArray.length; i++) {
      sum != intArray[i];
    }
  

If the list is not modified, then repetitive calls to asTypedArray(), toArray() and toArray(Object[]) are guaranteed to be GC-free. Note that iterating over the list using iterator() and listIterator() are not GC-free.

Since:
1.1.10
  • Constructor Details

    • COWArrayList

      public COWArrayList(E[] modelArray)
      Deprecated.
  • Method Details

    • size

      public int size()
      Deprecated.
      Specified by:
      size in interface Collection<E>
      Specified by:
      size in interface List<E>
    • isEmpty

      public boolean isEmpty()
      Deprecated.
      Specified by:
      isEmpty in interface Collection<E>
      Specified by:
      isEmpty in interface List<E>
    • contains

      public boolean contains(Object o)
      Deprecated.
      Specified by:
      contains in interface Collection<E>
      Specified by:
      contains in interface List<E>
    • iterator

      public Iterator<E> iterator()
      Deprecated.
      Specified by:
      iterator in interface Collection<E>
      Specified by:
      iterator in interface Iterable<E>
      Specified by:
      iterator in interface List<E>
    • toArray

      public Object[] toArray()
      Deprecated.
      Specified by:
      toArray in interface Collection<E>
      Specified by:
      toArray in interface List<E>
    • toArray

      public <T> T[] toArray(T[] a)
      Deprecated.
      Specified by:
      toArray in interface Collection<E>
      Specified by:
      toArray in interface List<E>
    • asTypedArray

      public E[] asTypedArray()
      Deprecated.
      Return an array of type E[]. The returned array is intended to be iterated over. If the list is modified, subsequent calls to this method will return different/modified array instances.
      Returns:
    • addIfAbsent

      public void addIfAbsent(E e)
      Deprecated.
    • add

      public boolean add(E e)
      Deprecated.
      Specified by:
      add in interface Collection<E>
      Specified by:
      add in interface List<E>
    • remove

      public boolean remove(Object o)
      Deprecated.
      Specified by:
      remove in interface Collection<E>
      Specified by:
      remove in interface List<E>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Deprecated.
      Specified by:
      containsAll in interface Collection<E>
      Specified by:
      containsAll in interface List<E>
    • addAll

      public boolean addAll(Collection<? extends E> c)
      Deprecated.
      Specified by:
      addAll in interface Collection<E>
      Specified by:
      addAll in interface List<E>
    • addAll

      public boolean addAll(int index, Collection<? extends E> col)
      Deprecated.
      Specified by:
      addAll in interface List<E>
    • removeAll

      public boolean removeAll(Collection<?> col)
      Deprecated.
      Specified by:
      removeAll in interface Collection<E>
      Specified by:
      removeAll in interface List<E>
    • retainAll

      public boolean retainAll(Collection<?> col)
      Deprecated.
      Specified by:
      retainAll in interface Collection<E>
      Specified by:
      retainAll in interface List<E>
    • clear

      public void clear()
      Deprecated.
      Specified by:
      clear in interface Collection<E>
      Specified by:
      clear in interface List<E>
    • get

      public E get(int index)
      Deprecated.
      Specified by:
      get in interface List<E>
    • set

      public E set(int index, E element)
      Deprecated.
      Specified by:
      set in interface List<E>
    • add

      public void add(int index, E element)
      Deprecated.
      Specified by:
      add in interface List<E>
    • remove

      public E remove(int index)
      Deprecated.
      Specified by:
      remove in interface List<E>
    • indexOf

      public int indexOf(Object o)
      Deprecated.
      Specified by:
      indexOf in interface List<E>
    • lastIndexOf

      public int lastIndexOf(Object o)
      Deprecated.
      Specified by:
      lastIndexOf in interface List<E>
    • listIterator

      public ListIterator<E> listIterator()
      Deprecated.
      Specified by:
      listIterator in interface List<E>
    • listIterator

      public ListIterator<E> listIterator(int index)
      Deprecated.
      Specified by:
      listIterator in interface List<E>
    • subList

      public List<E> subList(int fromIndex, int toIndex)
      Deprecated.
      Specified by:
      subList in interface List<E>