Class ConcurrentAppendOnlyChunkedList<E>


  • public final class ConcurrentAppendOnlyChunkedList<E>
    extends java.lang.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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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.
      E get​(int index)
      Returns the element at the specified position in this collection or null if not found.
      int size()
      It returns the number of elements currently added.
      E[] toArray​(java.util.function.IntFunction<E[]> arrayAllocator)  
      E[] toArray​(java.util.function.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 Detail

      • ConcurrentAppendOnlyChunkedList

        public ConcurrentAppendOnlyChunkedList​(int chunkSize)
        Throws:
        java.lang.IllegalArgumentException - if chunkSize is <0 or not a power of 2
    • Method Detail

      • 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.
      • add

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

        public E[] toArray​(java.util.function.IntFunction<E[]> arrayAllocator)
      • toArray

        public E[] toArray​(java.util.function.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.