Class ConcurrentAppendOnlyChunkedList<E>

java.lang.Object
org.apache.activemq.artemis.utils.collections.ConcurrentAppendOnlyChunkedList<E>

public final class ConcurrentAppendOnlyChunkedList<E> extends Object
This collection is a concurrent append-only list that grows in chunks.

It's safe to be used by many threads concurrently and has a max capacity of Integer.MAX_VALUE.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(E e)
    Appends the specified element to the end of this collection.
    void
    addAll(E[] elements)
    It appends elements to the collection.
    get(int index)
    Returns the element at the specified position in this collection or null if not found..
    int
    It returns the number of elements currently added.
    E[]
    toArray(IntFunction<E[]> arrayAllocator)
     
    E[]
    toArray(IntFunction<E[]> arrayAllocator, int startIndex)
    Returns an array containing all of the elements in this collection in proper sequence (from first to last element); arrayAllocator will be used to instantiate the array of the correct size with the right runtime type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConcurrentAppendOnlyChunkedList

      public ConcurrentAppendOnlyChunkedList(int chunkSize)
      Throws:
      IllegalArgumentException - if chunkSize is <0 or not a power of 2
  • Method Details

    • size

      public int size()
      It returns the number of elements currently added.
    • addAll

      public void addAll(E[] elements)
      It appends elements to the collection.
    • get

      public E get(int index)
      Returns the element at the specified position in this collection or null if not found..
      Returns:
      the element at the specified position in this collection or null if not found.
    • add

      public void add(E e)
      Appends the specified element to the end of this collection.
      Throws:
      NullPointerException - if e is null
    • toArray

      public E[] toArray(IntFunction<E[]> arrayAllocator)
    • toArray

      public E[] toArray(IntFunction<E[]> arrayAllocator, int startIndex)
      Returns an array containing all of the elements in this collection in proper sequence (from first to last element); arrayAllocator will be used to instantiate the array of the correct size with the right runtime type.
      Returns:
      an array containing all of the elements in this collection in proper sequence (from first to last element); arrayAllocator will be used to instantiate the array of the correct size with the right runtime type