Package civitas.celestis.util.array
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
The base class for all type-safe arrays, including primitive specialized arrays.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks for equality between two instances ofarrays.voidforEach(BiConsumer<? super Integer, ? super E> a) Executes the provided actionaonce for each element of this array.voidExecutes the provided actionaonce for each element of this array.iterator()Returns an iterator over every element of this array.intlength()Returns the length of this array.list()Returns an unmodifiable list containing the elements of this array in their proper order.voidshuffle()Shuffles this array, randomizing its elements' order.voidsort()Sorts this array by its natural ascending order.voidsort(Comparator<? super E> c) Sorts this array using the provided comparator functionc.Methods inherited from interface java.lang.Iterable
spliterator
-
Method Details
-
equals
Checks for equality between two instances ofarrays. This will returntrueif the length, order of elements, and the elements' values are all equal. In other words, this returnstrueif the list representations are equal. (or both arrays arenull, in which casenull == null)- Parameters:
a1- The first array to comparea2- The second array to compare- Returns:
trueif 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
Sorts this array by its natural ascending order. This operation will only succeed if the elementEis an instance ofComparable.- Throws:
UnsupportedOperationException- When at least one element cannot be cast toComparable
-
sort
Sorts this array using the provided comparator functionc.- Parameters:
c- The comparator function of which to sort this array with
-
iterator
Returns an iterator over every element of this array. -
forEach
Executes the provided actionaonce for each element of this array. A reference to the element is provided as the first parameter of the action. -
forEach
Executes the provided actionaonce 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
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 ofnull- See Also:
-