Class AtomicArray<E>

java.lang.Object
org.opensearch.common.util.concurrent.AtomicArray<E>

@PublicApi(since="1.0.0") public class AtomicArray<E> extends Object
A list backed by an AtomicReferenceArray with potential null values, easily allowing to get the concrete values as a list using asList().
Opensearch.api:
  • Constructor Summary

    Constructors
    Constructor
    Description
    AtomicArray(int size)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the it as a non null list.
    get(int i)
    Gets the current value at position i.
    int
    The size of the expected results, including potential null values.
    void
    set(int i, E value)
    Sets the element at position i to the given value.
    final void
    setOnce(int i, E value)
     
    E[]
    toArray(E[] a)
    Copies the content of the underlying atomic array to a normal one.

    Methods inherited from class java.lang.Object

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

    • AtomicArray

      public AtomicArray(int size)
  • Method Details

    • length

      public int length()
      The size of the expected results, including potential null values.
    • set

      public void set(int i, E value)
      Sets the element at position i to the given value.
      Parameters:
      i - the index
      value - the new value
    • setOnce

      public final void setOnce(int i, E value)
    • get

      public E get(int i)
      Gets the current value at position i.
      Parameters:
      i - the index
      Returns:
      the current value
    • asList

      public List<E> asList()
      Returns the it as a non null list.
    • toArray

      public E[] toArray(E[] a)
      Copies the content of the underlying atomic array to a normal one.