Class COWArrayList<E>

  • All Implemented Interfaces:
    Iterable<E>, Collection<E>, List<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 < 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 Detail

      • COWArrayList

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

      • size

        public int size()
        Deprecated.
        Specified by:
        size in interface Collection<E>
        Specified by:
        size 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>
      • addAll

        public boolean addAll​(int index,
                              Collection<? extends E> col)
        Deprecated.
        Specified by:
        addAll 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>
      • subList

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