java.lang.Object
ushiosan.jvm_utilities.internal.collection.ArrsGeneric
ushiosan.jvm_utilities.internal.collection.ArrsPrimitive
All Implemented Interfaces:
IArrsConstants
Direct Known Subclasses:
Arrs

public abstract class ArrsPrimitive extends ArrsGeneric
Auxiliary class that is in charge of handling primitive arrays
See Also:
  • Field Details

  • Constructor Details

    • ArrsPrimitive

      public ArrsPrimitive()
  • Method Details

    • numberOf

      public static Number @NotNull [] numberOf(Number @NotNull ... elements)
      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

      @Contract(pure=true) public static int indexOf(char @NotNull [] array, char element)
      Search elements in the array
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • lastIndexOf

      public static int lastIndexOf(char @NotNull [] array, char element)
      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 search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • contains

      public static boolean contains(char @NotNull [] array, char element)
      Checks if the array contains the selected element.
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      true if the element exists or false otherwise
    • lastElement

      @NotNull public static @NotNull Optional<Character> lastElement(char @NotNull [] array)
      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

      public static char unsafeLastElement(char @NotNull [] array)
      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

      public static byte @NotNull [] byteOf(Number @NotNull ... elements)
      Generate a primitive byte array
      Parameters:
      elements - byte elements
      Returns:
      an array with all bytes
    • indexOf

      @Contract(pure=true) public static int indexOf(byte @NotNull [] array, byte element)
      Search elements in the array
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • lastIndexOf

      public static int lastIndexOf(byte @NotNull [] array, byte element)
      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 search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • contains

      public static boolean contains(byte @NotNull [] array, byte element)
      Checks if the array contains the selected element.
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      true if the element exists or false otherwise
    • lastElement

      @NotNull public static @NotNull Optional<Byte> lastElement(byte @NotNull [] array)
      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

      public static byte unsafeLastElement(byte @NotNull [] array)
      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

      public static short @NotNull [] shortOf(Number @NotNull ... elements)
      Generate a primitive short array
      Parameters:
      elements - short elements
      Returns:
      an array with all shot elements
    • indexOf

      @Contract(pure=true) public static int indexOf(short @NotNull [] array, short element)
      Search elements in the array
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • lastIndexOf

      public static int lastIndexOf(short @NotNull [] array, short element)
      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 search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • contains

      public static boolean contains(short @NotNull [] array, short element)
      Checks if the array contains the selected element.
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      true if the element exists or false otherwise
    • lastElement

      @NotNull public static @NotNull Optional<Short> lastElement(short @NotNull [] array)
      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

      public static short unsafeLastElement(short @NotNull [] array)
      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

      @Contract(pure=true) public static int indexOf(int @NotNull [] array, int element)
      Search elements in the array
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • lastIndexOf

      public static int lastIndexOf(int @NotNull [] array, int element)
      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 search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • contains

      public static boolean contains(int @NotNull [] array, int element)
      Checks if the array contains the selected element.
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      true if the element exists or false otherwise
    • lastElement

      @NotNull public static @NotNull Optional<Integer> lastElement(int @NotNull [] array)
      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

      public static int unsafeLastElement(int @NotNull [] array)
      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

      @Contract(pure=true) public static int indexOf(long @NotNull [] array, long element)
      Search elements in the array
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • lastIndexOf

      public static int lastIndexOf(long @NotNull [] array, long element)
      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 search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • contains

      public static boolean contains(long @NotNull [] array, long element)
      Checks if the array contains the selected element.
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      true if the element exists or false otherwise
    • lastElement

      @NotNull public static @NotNull Optional<Long> lastElement(long @NotNull [] array)
      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

      public static long unsafeLastElement(long @NotNull [] array)
      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

      @Contract(pure=true) public static int indexOf(float @NotNull [] array, float element)
      Search elements in the array
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • lastIndexOf

      public static int lastIndexOf(float @NotNull [] array, float element)
      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 search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • contains

      public static boolean contains(float @NotNull [] array, float element)
      Checks if the array contains the selected element.
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      true if the element exists or false otherwise
    • lastElement

      @NotNull public static @NotNull Optional<Float> lastElement(float @NotNull [] array)
      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

      public static float unsafeLastElement(float @NotNull [] array)
      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

      @Contract(pure=true) public static int indexOf(double @NotNull [] array, double element)
      Search elements in the array
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • lastIndexOf

      public static int lastIndexOf(double @NotNull [] array, double element)
      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 search
      element - the element to search
      Returns:
      the first index element or -1 if element not exists
    • contains

      public static boolean contains(double @NotNull [] array, double element)
      Checks if the array contains the selected element.
      Parameters:
      array - base array to search
      element - the element to search
      Returns:
      true if the element exists or false otherwise
    • lastElement

      @NotNull public static @NotNull Optional<Double> lastElement(double @NotNull [] array)
      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

      public static double unsafeLastElement(double @NotNull [] array)
      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 convert
      mapper - function in charge of transforming each element of the array
      arrFn - 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 convert
      mapper - 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 check
      ar2 - the array to check
      Returns:
      true if the content is the same or false if 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 check
      ar2 - the array to check
      Returns:
      true if the content is the same or false if 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 check
      ar2 - the array to check
      Returns:
      true if the content is the same or false if 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 check
      ar2 - the array to check
      Returns:
      true if the content is the same or false if 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 check
      ar2 - the array to check
      Returns:
      true if the content is the same or false if 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 check
      ar2 - the array to check
      Returns:
      true if the content is the same or false if 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 check
      ar2 - the array to check
      Returns:
      true if the content is the same or false if the size is different or the content is different
    • toNumberArray

      public static Number @NotNull [] toNumberArray(byte[] array)
      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

      public static Number @NotNull [] toNumberArray(short[] array)
      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

      public static Number @NotNull [] toNumberArray(int[] array)
      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

      public static Number @NotNull [] toNumberArray(long[] array)
      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

      public static Number @NotNull [] toNumberArray(float[] array)
      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

      public static Number @NotNull [] toNumberArray(double[] array)
      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 convert
      mapper - function in charge of transforming each element of the array
      arrFn - 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 convert
      mapper - 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 convert
      mapper - function in charge of transforming each element of the array
      arrFn - 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 convert
      mapper - 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 convert
      mapper - function in charge of transforming each element of the array
      arrFn - 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 convert
      mapper - 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 convert
      mapper - function in charge of transforming each element of the array
      arrFn - 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 convert
      mapper - 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 convert
      mapper - function in charge of transforming each element of the array
      arrFn - 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 convert
      mapper - 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 convert
      mapper - function in charge of transforming each element of the array
      arrFn - 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 convert
      mapper - function in charge of transforming each element of the array
      Returns:
      the new array with the converted data