FloatArrayList (Lucene 10.5.1 core API)
Description: declaration: package: org.apache.lucene.internal.hppc, class: FloatArrayList

Package org.apache.lucene.internal.hppc

# Class FloatArrayList

java.lang.Object
org.apache.lucene.internal.hppc.FloatArrayList

All Implemented Interfaces:
  `Cloneable`, `Iterable<FloatCursor>`, `Accountable`

Direct Known Subclasses:
  `MaxSizedFloatArrayList`

public class FloatArrayList extends Object implements Iterable<FloatCursor>, Cloneable, Accountable
An array-backed list of `float`.

Mostly forked and trimmed from com.carrotsearch.hppc.FloatArrayList

github: https://github.com/carrotsearch/hppc release 0.10.0

NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `float[]`
  `buffer`
  Internal array for storing the list.
  `int`
  `elementsCount`
  Current number of elements stored in `buffer`.
  `static final float[]`
  `EMPTY_ARRAY`
  An immutable empty buffer (array).

  ### Fields inherited from interface org.apache.lucene.util.Accountable

  `NULL_ACCOUNTABLE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FloatArrayList()`
  New instance with sane defaults.
  `FloatArrayList(int expectedElements)`
  New instance with sane defaults.
  `FloatArrayList(FloatArrayList list)`
  Creates a new list from the elements of another list in its iteration order.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(float e1)`
  `final void`
  `add(float... elements)`
  Vararg-signature method for adding elements at the end of the list.
  `void`
  `add(float[] elements, int start, int length)`
  Add all elements from a range of given array to the list.
  `int`
  `addAll(Iterable<? extends FloatCursor> iterable)`
  Adds all elements from another iterable.
  `int`
  `addAll(FloatArrayList list)`
  Adds all elements from another list.
  `void`
  `clear()`
  Sets the number of stored elements to zero.
  `FloatArrayList`
  `clone()`
  Clone this object.
  `boolean`
  `contains(float e1)`
  `protected void`
  `ensureBufferSpace(int expectedAdditions)`
  Ensures the internal buffer has enough free slots to store `expectedAdditions`.
  `void`
  `ensureCapacity(int expectedElements)`
  Ensure this container can hold at least the given number of elements without resizing its buffers.
  `protected boolean`
  `equalElements(FloatArrayList other)`
  Compare index-aligned elements against another `FloatArrayList`.
  `boolean`
  `equals(Object obj)`
  Returns `true` only if the other object is an instance of the same class and with the same elements.
  `static FloatArrayList`
  `from(float... elements)`
  Create a list from a variable number of arguments or an array of `int`.
  `float`
  `get(int index)`
  `int`
  `hashCode()`
  `int`
  `indexOf(float e1)`
  `void`
  `insert(int index, float e1)`
  `boolean`
  `isEmpty()`
  `Iterator<FloatCursor>`
  `iterator()`
  `int`
  `lastIndexOf(float e1)`
  `long`
  `ramBytesUsed()`
  Returns an estimate of the JVM heap memory used by this object in bytes.
  `void`
  `release()`
  Sets the number of stored elements to zero and releases the internal storage array.
  `int`
  `removeAll(float e)`
  Removes all occurrences of `e` from this collection.
  `float`
  `removeAt(int index)`
  Removes the element at the specified position in this container and returns it.
  `boolean`
  `removeElement(float e)`
  Removes the first element that equals `e`, returning whether an element has been removed.
  `int`
  `removeFirst(float e1)`
  Removes the first element that equals `e1`, returning its deleted position or `-1` if the element was not found.
  `float`
  `removeLast()`
  Removes and returns the last element of this list.
  `int`
  `removeLast(float e1)`
  Removes the last element that equals `e1`, returning its deleted position or `-1` if the element was not found.
  `void`
  `removeRange(int fromIndex, int toIndex)`
  Removes from this list all the elements with indexes between `fromIndex`, inclusive, and `toIndex`, exclusive.
  `void`
  `resize(int newSize)`
  Truncate or expand the list to the new size.
  `FloatArrayList`
  `reverse()`
  Reverses the elements in this list and returns this list.
  `float`
  `set(int index, float e1)`
  `int`
  `size()`
  `FloatArrayList`
  `sort()`
  Sorts the elements in this list and returns this list.
  `float[]`
  `toArray()`
  The returned array is sized to match exactly the number of elements of the stack.
  `String`
  `toString()`
  Convert the contents of this list to a human-friendly string.
  `void`
  `trimToSize()`
  Trim the internal buffer to the current size.

  ### Methods inherited from class java.lang.Object

  `finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.apache.lucene.util.Accountable

  `getChildResources`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Field Details

  - ### EMPTY_ARRAY

    public static final float[] EMPTY_ARRAY
    An immutable empty buffer (array).

  - ### buffer

    public float[] buffer
    Internal array for storing the list. The array may be larger than the current size (`size()`).

  - ### elementsCount

    public int elementsCount
    Current number of elements stored in `buffer`.

- ## Constructor Details

  - ### FloatArrayList

    public FloatArrayList()
    New instance with sane defaults.

  - ### FloatArrayList

    public FloatArrayList(int expectedElements)
    New instance with sane defaults.
    Parameters:
      `expectedElements` - The expected number of elements guaranteed not to cause buffer expansion (inclusive).

  - ### FloatArrayList

    public FloatArrayList(FloatArrayList list)
    Creates a new list from the elements of another list in its iteration order.

- ## Method Details

  - ### add

    public void add(float e1)

  - ### add

    public void add(float[] elements, int start, int length)
    Add all elements from a range of given array to the list.

  - ### add

    public final void add(float... elements)
    Vararg-signature method for adding elements at the end of the list.

    This method is handy, but costly if used in tight loops (anonymous array passing)

  - ### addAll

    public int addAll(FloatArrayList list)
    Adds all elements from another list.

  - ### addAll

    public int addAll(Iterable<? extends FloatCursor> iterable)
    Adds all elements from another iterable.

  - ### insert

    public void insert(int index, float e1)

  - ### get

    public float get(int index)

  - ### set

    public float set(int index, float e1)

  - ### removeAt

    public float removeAt(int index)
    Removes the element at the specified position in this container and returns it.

  - ### removeLast

    public float removeLast()
    Removes and returns the last element of this list.

  - ### removeRange

    public void removeRange(int fromIndex, int toIndex)
    Removes from this list all the elements with indexes between `fromIndex`, inclusive, and `toIndex`, exclusive.

  - ### removeElement

    public boolean removeElement(float e)
    Removes the first element that equals `e`, returning whether an element has been removed.

  - ### removeFirst

    public int removeFirst(float e1)
    Removes the first element that equals `e1`, returning its deleted position or `-1` if the element was not found.

  - ### removeLast

    public int removeLast(float e1)
    Removes the last element that equals `e1`, returning its deleted position or `-1` if the element was not found.

  - ### removeAll

    public int removeAll(float e)
    Removes all occurrences of `e` from this collection.
    Parameters:
      `e` - Element to be removed from this collection, if present.
    Returns:
      The number of removed elements as a result of this call.

  - ### contains

    public boolean contains(float e1)

  - ### indexOf

    public int indexOf(float e1)

  - ### lastIndexOf

    public int lastIndexOf(float e1)

  - ### isEmpty

    public boolean isEmpty()

  - ### ensureCapacity

    public void ensureCapacity(int expectedElements)
    Ensure this container can hold at least the given number of elements without resizing its buffers.
    Parameters:
      `expectedElements` - The total number of elements, inclusive.

  - ### ensureBufferSpace

    protected void ensureBufferSpace(int expectedAdditions)
    Ensures the internal buffer has enough free slots to store `expectedAdditions`. Increases internal buffer size if needed.

  - ### resize

    public void resize(int newSize)
    Truncate or expand the list to the new size. If the list is truncated, the buffer will not be reallocated (use `trimToSize()` if you need a truncated buffer), but the truncated values will be reset to the default value (zero). If the list is expanded, the elements beyond the current size are initialized with JVM-defaults (zero or `null` values).

  - ### size

    public int size()

  - ### trimToSize

    public void trimToSize()
    Trim the internal buffer to the current size.

  - ### clear

    public void clear()
    Sets the number of stored elements to zero. Releases and initializes the internal storage array to default values. To clear the list without cleaning the buffer, simply set the `elementsCount` field to zero.

  - ### release

    public void release()
    Sets the number of stored elements to zero and releases the internal storage array.

  - ### toArray

    public float[] toArray()
    The returned array is sized to match exactly the number of elements of the stack.

  - ### clone

    public FloatArrayList clone()
    Clone this object. The returned clone will reuse the same hash function and array resizing strategy.
    Overrides:
      `clone` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Returns `true` only if the other object is an instance of the same class and with the same elements.
    Overrides:
      `equals` in class `Object`

  - ### equalElements

    protected boolean equalElements(FloatArrayList other)
    Compare index-aligned elements against another `FloatArrayList`.

  - ### toString

    public String toString()
    Convert the contents of this list to a human-friendly string.
    Overrides:
      `toString` in class `Object`

  - ### ramBytesUsed

    public long ramBytesUsed()
    Description copied from interface: `Accountable`
    Returns an estimate of the JVM heap memory used by this object in bytes. The method name uses "ram" for historical reasons; only JVM heap memory should be reported. Off-heap resources such as memory-mapped files or native direct buffers should not be included. Negative values are illegal.
    Specified by:
      `ramBytesUsed` in interface `Accountable`

  - ### sort

    public FloatArrayList sort()
    Sorts the elements in this list and returns this list.

  - ### reverse

    public FloatArrayList reverse()
    Reverses the elements in this list and returns this list.

  - ### iterator

    public Iterator<FloatCursor> iterator()
    Specified by:
      `iterator` in interface `Iterable<FloatCursor>`

  - ### from

    public static FloatArrayList from(float... elements)
    Create a list from a variable number of arguments or an array of `int`. The elements are copied from the argument to the internal buffer.