Interface BaseArray<E>

Type Parameters:
E - The type of element this array should hold
All Superinterfaces:
Iterable<E>, Serializable
All Known Subinterfaces:
DoubleArray, FloatArray, IntArray, LongArray, SafeArray<E>
All Known Implementing Classes:
AtomicArray, DoubleFastArray, FastArray, FloatFastArray, IntFastArray, LongFastArray, SyncArray

public interface BaseArray<E> extends Iterable<E>, Serializable
The base class for all type-safe arrays, including primitive specialized arrays.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    equals(BaseArray<?> a1, BaseArray<?> a2)
    Checks for equality between two instances of arrays.
    void
    forEach(BiConsumer<? super Integer,? super E> a)
    Executes the provided action a once for each element of this array.
    void
    forEach(Consumer<? super E> a)
    Executes the provided action a once for each element of this array.
    Returns an iterator over every element of this array.
    int
    Returns the length of this array.
    Returns an unmodifiable list containing the elements of this array in their proper order.
    void
    Shuffles this array, randomizing its elements' order.
    void
    Sorts this array by its natural ascending order.
    void
    sort(Comparator<? super E> c)
    Sorts this array using the provided comparator function c.

    Methods inherited from interface java.lang.Iterable

    spliterator
  • Method Details

    • equals

      static boolean equals(@Nullable BaseArray<?> a1, @Nullable BaseArray<?> a2)
      Checks for equality between two instances of arrays. This will return true if the length, order of elements, and the elements' values are all equal. In other words, this returns true if the list representations are equal. (or both arrays are null, in which case null == null)
      Parameters:
      a1 - The first array to compare
      a2 - The second array to compare
      Returns:
      true if the arrays are considered equal according to the criteria mentioned above
    • length

      int length()
      Returns the length of this array.
      Returns:
      The number of elements this array contains
    • shuffle

      void shuffle()
      Shuffles this array, randomizing its elements' order.
    • sort

      void sort() throws UnsupportedOperationException
      Sorts this array by its natural ascending order. This operation will only succeed if the element E is an instance of Comparable.
      Throws:
      UnsupportedOperationException - When at least one element cannot be cast to Comparable
    • sort

      void sort(@Nonnull Comparator<? super E> c)
      Sorts this array using the provided comparator function c.
      Parameters:
      c - The comparator function of which to sort this array with
    • iterator

      @Nonnull Iterator<E> iterator()
      Returns an iterator over every element of this array.
      Specified by:
      iterator in interface Iterable<E>
      Returns:
      An iterator over every element of this array
    • forEach

      void forEach(@Nonnull Consumer<? super E> a)
      Executes the provided action a once for each element of this array. A reference to the element is provided as the first parameter of the action.
      Specified by:
      forEach in interface Iterable<E>
      Parameters:
      a - The action to be performed for each element
    • forEach

      void forEach(@Nonnull BiConsumer<? super Integer,? super E> a)
      Executes the provided action a once for each element of this array. The index of the element is provided as the first parameter of the action, and a reference to the element is provided as the second parameter of the action.
      Parameters:
      a - The action to be performed for each element
    • list

      @Nonnull List<E> list()
      Returns an unmodifiable list containing the elements of this array in their proper order.
      Returns:
      The list representation of this array
      Throws:
      NullPointerException - When this array contains at least one instance of null
      See Also: