Class ArrsPrimitive
java.lang.Object
ushiosan.jvm_utilities.internal.collection.ArrsGeneric
ushiosan.jvm_utilities.internal.collection.ArrsPrimitive
- All Implemented Interfaces:
IArrsConstants
- Direct Known Subclasses:
Arrs
Auxiliary class that is in charge of handling primitive arrays
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Pair<Class<?>,Apply.Result<Object, Object[]>>[] Map of actions for data conversionFields inherited from interface ushiosan.jvm_utilities.internal.collection.IArrsConstants
BYTE_EMPTY, CHAR_EMPTY, DOUBLE_EMPTY, EMPTY_SIZE, FLOAT_EMPTY, INDEX_NOT_FOUND, INT_EMPTY, LONG_EMPTY, OBJ_EMPTY, SHORT_EMPTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean[]booleanOf(boolean... elements) Generate a primitive boolean arraystatic byte @NotNull []Generate a primitive byte arraystatic char[]charOf(char... elements) Generate a primitive char arraystatic booleanChecks if the array contains the selected element.static booleanChecks if the array contains the selected element.static booleanChecks if the array contains the selected element.static booleanChecks if the array contains the selected element.static booleanChecks if the array contains the selected element.static booleanChecks if the array contains the selected element.static booleanChecks if the array contains the selected element.static booleancontentEquals(byte[] ar1, byte[] ar2) Verify that the contents of two arrays are the samestatic booleancontentEquals(char[] ar1, char[] ar2) Verify that the contents of two arrays are the samestatic booleancontentEquals(double[] ar1, double[] ar2) Verify that the contents of two arrays are the samestatic booleancontentEquals(float[] ar1, float[] ar2) Verify that the contents of two arrays are the samestatic booleancontentEquals(int[] ar1, int[] ar2) Verify that the contents of two arrays are the samestatic booleancontentEquals(long[] ar1, long[] ar2) Verify that the contents of two arrays are the samestatic booleancontentEquals(short[] ar1, short[] ar2) Verify that the contents of two arrays are the samestatic double[]doubleOf(double... elements) Generate a primitive double arraystatic float[]floatOf(float... elements) Generate a primitive float arraystatic intSearch elements in the arraystatic intSearch elements in the arraystatic intSearch elements in the arraystatic intSearch elements in the arraystatic intSearch elements in the arraystatic intSearch elements in the arraystatic intSearch elements in the arraystatic int[]intOf(int... elements) Generate a primitive int arraylastElement(byte @NotNull [] array) Returns the last element of the arraylastElement(char @NotNull [] array) Returns the last element of the arraylastElement(double @NotNull [] array) Returns the last element of the arraylastElement(float @NotNull [] array) Returns the last element of the arraylastElement(int @NotNull [] array) Returns the last element of the arraylastElement(long @NotNull [] array) Returns the last element of the arraylastElement(short @NotNull [] array) Returns the last element of the arraystatic intlastIndexOf(byte @NotNull [] array, byte element) Search an element in the array.static intlastIndexOf(char @NotNull [] array, char element) Search an element in the array.static intlastIndexOf(double @NotNull [] array, double element) Search an element in the array.static intlastIndexOf(float @NotNull [] array, float element) Search an element in the array.static intlastIndexOf(int @NotNull [] array, int element) Search an element in the array.static intlastIndexOf(long @NotNull [] array, long element) Search an element in the array.static intlastIndexOf(short @NotNull [] array, short element) Search an element in the array.static long[]longOf(long... elements) Generate a primitive long arrayGenerates a generic array with numeric objects.static short @NotNull []Generate a primitive short arraytoNumberArray(byte[] array) Convert any array of primitive numbers to an array of numeric objectstoNumberArray(double[] array) Convert any array of primitive numbers to an array of numeric objectstoNumberArray(float[] array) Convert any array of primitive numbers to an array of numeric objectstoNumberArray(int[] array) Convert any array of primitive numbers to an array of numeric objectstoNumberArray(long[] array) Convert any array of primitive numbers to an array of numeric objectstoNumberArray(short[] array) Convert any array of primitive numbers to an array of numeric objectstransformByte(byte[] original, @NotNull Function<Byte, T> mapper) Converts one array to another but with a different data type.static <T> T @NotNull []transformByte(byte[] original, @NotNull Function<Byte, T> mapper, @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.transformChar(char[] original, @NotNull Function<Character, T> mapper) Converts one array to another but with a different data type.static <T> T @NotNull []transformChar(char[] original, @NotNull Function<Character, T> mapper, @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.transformDouble(double[] original, @NotNull Function<Double, T> mapper) Converts one array to another but with a different data type.static <T> T @NotNull []transformDouble(double[] original, @NotNull Function<Double, T> mapper, @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.transformFloat(float[] original, @NotNull Function<Float, T> mapper) Converts one array to another but with a different data type.static <T> T @NotNull []transformFloat(float[] original, @NotNull Function<Float, T> mapper, @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.transformInt(int[] original, @NotNull Function<Integer, T> mapper) Converts one array to another but with a different data type.static <T> T @NotNull []transformInt(int[] original, @NotNull Function<Integer, T> mapper, @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.transformLong(long[] original, @NotNull Function<Long, T> mapper) Converts one array to another but with a different data type.static <T> T @NotNull []transformLong(long[] original, @NotNull Function<Long, T> mapper, @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.transformShort(short[] original, @NotNull Function<Short, T> mapper) Converts one array to another but with a different data type.static <T> T @NotNull []transformShort(short[] original, @NotNull Function<Short, T> mapper, @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.static byteunsafeLastElement(byte @NotNull [] array) Returns the last element of the arraystatic charunsafeLastElement(char @NotNull [] array) Returns the last element of the arraystatic doubleunsafeLastElement(double @NotNull [] array) Returns the last element of the arraystatic floatunsafeLastElement(float @NotNull [] array) Returns the last element of the arraystatic intunsafeLastElement(int @NotNull [] array) Returns the last element of the arraystatic longunsafeLastElement(long @NotNull [] array) Returns the last element of the arraystatic shortunsafeLastElement(short @NotNull [] array) Returns the last element of the arrayMethods inherited from class ushiosan.jvm_utilities.internal.collection.ArrsGeneric
contains, contentEquals, indexOf, join, join, joinAll, joinAll, lastElement, lastIndexOf, of, of, transform, transform, unsafeLastElement
-
Field Details
-
CONVERSION_MAP
Map of actions for data conversion
-
-
Constructor Details
-
ArrsPrimitive
public ArrsPrimitive()
-
-
Method Details
-
numberOf
Generates a generic array with numeric objects.- Parameters:
elements- numeric elements- Returns:
- an array with all numeric elements
-
booleanOf
public static boolean[] booleanOf(boolean... elements) Generate a primitive boolean array- Parameters:
elements- boolean elements- Returns:
- an array with all boolean elements
-
charOf
public static char[] charOf(char... elements) Generate a primitive char array- Parameters:
elements- char elements- Returns:
- an array with all char elements
-
indexOf
Search elements in the array- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
lastIndexOf
Search an element in the array. This method tries to search in reverse, first starting at the end of the array, to find the desired element.- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
contains
Checks if the array contains the selected element.- Parameters:
array- base array to searchelement- the element to search- Returns:
trueif the element exists orfalseotherwise
-
lastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array or
Optional.empty()if array is empty
-
unsafeLastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array
- Throws:
IllegalStateException- if the array is empty
-
byteOf
Generate a primitive byte array- Parameters:
elements- byte elements- Returns:
- an array with all bytes
-
indexOf
Search elements in the array- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
lastIndexOf
Search an element in the array. This method tries to search in reverse, first starting at the end of the array, to find the desired element.- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
contains
Checks if the array contains the selected element.- Parameters:
array- base array to searchelement- the element to search- Returns:
trueif the element exists orfalseotherwise
-
lastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array or
Optional.empty()if array is empty
-
unsafeLastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array
- Throws:
IllegalStateException- if the array is empty
-
shortOf
Generate a primitive short array- Parameters:
elements- short elements- Returns:
- an array with all shot elements
-
indexOf
Search elements in the array- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
lastIndexOf
Search an element in the array. This method tries to search in reverse, first starting at the end of the array, to find the desired element.- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
contains
Checks if the array contains the selected element.- Parameters:
array- base array to searchelement- the element to search- Returns:
trueif the element exists orfalseotherwise
-
lastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array or
Optional.empty()if array is empty
-
unsafeLastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array
- Throws:
IllegalStateException- if the array is empty
-
intOf
public static int[] intOf(int... elements) Generate a primitive int array- Parameters:
elements- int elements- Returns:
- an array with all int elements
-
indexOf
Search elements in the array- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
lastIndexOf
Search an element in the array. This method tries to search in reverse, first starting at the end of the array, to find the desired element.- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
contains
Checks if the array contains the selected element.- Parameters:
array- base array to searchelement- the element to search- Returns:
trueif the element exists orfalseotherwise
-
lastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array or
Optional.empty()if array is empty
-
unsafeLastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array
- Throws:
IllegalStateException- if the array is empty
-
longOf
public static long[] longOf(long... elements) Generate a primitive long array- Parameters:
elements- long elements- Returns:
- an array with all long elements
-
indexOf
Search elements in the array- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
lastIndexOf
Search an element in the array. This method tries to search in reverse, first starting at the end of the array, to find the desired element.- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
contains
Checks if the array contains the selected element.- Parameters:
array- base array to searchelement- the element to search- Returns:
trueif the element exists orfalseotherwise
-
lastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array or
Optional.empty()if array is empty
-
unsafeLastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array
- Throws:
IllegalStateException- if the array is empty
-
floatOf
public static float[] floatOf(float... elements) Generate a primitive float array- Parameters:
elements- float elements- Returns:
- an array with all float elements
-
indexOf
Search elements in the array- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
lastIndexOf
Search an element in the array. This method tries to search in reverse, first starting at the end of the array, to find the desired element.- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
contains
Checks if the array contains the selected element.- Parameters:
array- base array to searchelement- the element to search- Returns:
trueif the element exists orfalseotherwise
-
lastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array or
Optional.empty()if array is empty
-
unsafeLastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array
- Throws:
IllegalStateException- if the array is empty
-
doubleOf
public static double[] doubleOf(double... elements) Generate a primitive double array- Parameters:
elements- double elements- Returns:
- an array with double bytes
-
indexOf
Search elements in the array- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
lastIndexOf
Search an element in the array. This method tries to search in reverse, first starting at the end of the array, to find the desired element.- Parameters:
array- base array to searchelement- the element to search- Returns:
- the first index element or
-1if element not exists
-
contains
Checks if the array contains the selected element.- Parameters:
array- base array to searchelement- the element to search- Returns:
trueif the element exists orfalseotherwise
-
lastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array or
Optional.empty()if array is empty
-
unsafeLastElement
Returns the last element of the array- Parameters:
array- base array to search- Returns:
- the last element of the array
- Throws:
IllegalStateException- if the array is empty
-
transformChar
public static <T> T @NotNull [] transformChar(char[] original, @NotNull @NotNull Function<Character, T> mapper, @NotNull @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the arrayarrFn- function that generates the required type of array- Returns:
- the new array with the converted data
-
transformChar
public static <T> Object @NotNull [] transformChar(char[] original, @NotNull @NotNull Function<Character, T> mapper) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the array- Returns:
- the new array with the converted data
-
contentEquals
public static boolean contentEquals(char[] ar1, char[] ar2) Verify that the contents of two arrays are the same- Parameters:
ar1- the array to checkar2- the array to check- Returns:
trueif the content is the same orfalseif the size is different or the content is different
-
contentEquals
public static boolean contentEquals(byte[] ar1, byte[] ar2) Verify that the contents of two arrays are the same- Parameters:
ar1- the array to checkar2- the array to check- Returns:
trueif the content is the same orfalseif the size is different or the content is different
-
contentEquals
public static boolean contentEquals(short[] ar1, short[] ar2) Verify that the contents of two arrays are the same- Parameters:
ar1- the array to checkar2- the array to check- Returns:
trueif the content is the same orfalseif the size is different or the content is different
-
contentEquals
public static boolean contentEquals(int[] ar1, int[] ar2) Verify that the contents of two arrays are the same- Parameters:
ar1- the array to checkar2- the array to check- Returns:
trueif the content is the same orfalseif the size is different or the content is different
-
contentEquals
public static boolean contentEquals(long[] ar1, long[] ar2) Verify that the contents of two arrays are the same- Parameters:
ar1- the array to checkar2- the array to check- Returns:
trueif the content is the same orfalseif the size is different or the content is different
-
contentEquals
public static boolean contentEquals(float[] ar1, float[] ar2) Verify that the contents of two arrays are the same- Parameters:
ar1- the array to checkar2- the array to check- Returns:
trueif the content is the same orfalseif the size is different or the content is different
-
contentEquals
public static boolean contentEquals(double[] ar1, double[] ar2) Verify that the contents of two arrays are the same- Parameters:
ar1- the array to checkar2- the array to check- Returns:
trueif the content is the same orfalseif the size is different or the content is different
-
toNumberArray
Convert any array of primitive numbers to an array of numeric objects- Parameters:
array- the array to convert- Returns:
- an array with all numeric objects
-
toNumberArray
Convert any array of primitive numbers to an array of numeric objects- Parameters:
array- the array to convert- Returns:
- an array with all numeric objects
-
toNumberArray
Convert any array of primitive numbers to an array of numeric objects- Parameters:
array- the array to convert- Returns:
- an array with all numeric objects
-
toNumberArray
Convert any array of primitive numbers to an array of numeric objects- Parameters:
array- the array to convert- Returns:
- an array with all numeric objects
-
toNumberArray
Convert any array of primitive numbers to an array of numeric objects- Parameters:
array- the array to convert- Returns:
- an array with all numeric objects
-
toNumberArray
Convert any array of primitive numbers to an array of numeric objects- Parameters:
array- the array to convert- Returns:
- an array with all numeric objects
-
transformByte
public static <T> T @NotNull [] transformByte(byte[] original, @NotNull @NotNull Function<Byte, T> mapper, @NotNull @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the arrayarrFn- function that generates the required type of array- Returns:
- the new array with the converted data
-
transformByte
public static <T> Object @NotNull [] transformByte(byte[] original, @NotNull @NotNull Function<Byte, T> mapper) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the array- Returns:
- the new array with the converted data
-
transformShort
public static <T> T @NotNull [] transformShort(short[] original, @NotNull @NotNull Function<Short, T> mapper, @NotNull @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the arrayarrFn- function that generates the required type of array- Returns:
- the new array with the converted data
-
transformShort
public static <T> Object @NotNull [] transformShort(short[] original, @NotNull @NotNull Function<Short, T> mapper) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the array- Returns:
- the new array with the converted data
-
transformInt
public static <T> T @NotNull [] transformInt(int[] original, @NotNull @NotNull Function<Integer, T> mapper, @NotNull @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the arrayarrFn- function that generates the required type of array- Returns:
- the new array with the converted data
-
transformInt
public static <T> Object @NotNull [] transformInt(int[] original, @NotNull @NotNull Function<Integer, T> mapper) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the array- Returns:
- the new array with the converted data
-
transformLong
public static <T> T @NotNull [] transformLong(long[] original, @NotNull @NotNull Function<Long, T> mapper, @NotNull @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the arrayarrFn- function that generates the required type of array- Returns:
- the new array with the converted data
-
transformLong
public static <T> Object @NotNull [] transformLong(long[] original, @NotNull @NotNull Function<Long, T> mapper) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the array- Returns:
- the new array with the converted data
-
transformFloat
public static <T> T @NotNull [] transformFloat(float[] original, @NotNull @NotNull Function<Float, T> mapper, @NotNull @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the arrayarrFn- function that generates the required type of array- Returns:
- the new array with the converted data
-
transformFloat
public static <T> Object @NotNull [] transformFloat(float[] original, @NotNull @NotNull Function<Float, T> mapper) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the array- Returns:
- the new array with the converted data
-
transformDouble
public static <T> T @NotNull [] transformDouble(double[] original, @NotNull @NotNull Function<Double, T> mapper, @NotNull @NotNull IntFunction<T[]> arrFn) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the arrayarrFn- function that generates the required type of array- Returns:
- the new array with the converted data
-
transformDouble
public static <T> Object @NotNull [] transformDouble(double[] original, @NotNull @NotNull Function<Double, T> mapper) Converts one array to another but with a different data type.- Type Parameters:
T- the original data type- Parameters:
original- the original array that you want to convertmapper- function in charge of transforming each element of the array- Returns:
- the new array with the converted data
-