Class UArray

All Implemented Interfaces:
UArraysConstants

public final class UArray extends UArrayPrimitive
  • Method Details

    • makeDouble

      public static double[] makeDouble(double... elements)
      Generate a primitive double array
      Parameters:
      elements - double elements
      Returns:
      an array with double bytes
    • makeDoubleObj

      @Contract(pure=true) public static double @NotNull [] makeDoubleObj(Double @NotNull ... elements)
      Generate a primitive double array
      Parameters:
      elements - double elements
      Returns:
      an array with double bytes
    • primitiveIndexOf

      public static int primitiveIndexOf(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 an element not exists
    • primitiveLastIndexOf

      public static int primitiveLastIndexOf(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 an element not exists
    • primitiveContains

      public static boolean primitiveContains(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
    • primitiveLastElement

      @NotNull public static @NotNull Optional<Double> primitiveLastElement(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
    • primitiveUnsafeLastElement

      public static double primitiveUnsafeLastElement(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
    • toObjectArray

      public static Double @NotNull [] toObjectArray(double[] array)
      Convert any array to an object array. This also applies to primitive types.
      Parameters:
      array - the array to convert
      Returns:
      a converted array object
    • primitiveTransform

      public static <T> T @NotNull [] primitiveTransform(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
    • primitiveTransform

      public static <T> Object @NotNull [] primitiveTransform(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
    • primitiveContentEquals

      public static boolean primitiveContentEquals(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
    • makeFloat

      public static float[] makeFloat(float... elements)
      Generate a primitive float array
      Parameters:
      elements - float elements
      Returns:
      an array with all float elements
    • makeFloatObj

      @Contract(pure=true) public static float @NotNull [] makeFloatObj(Float @NotNull ... elements)
      Generate a primitive float array
      Parameters:
      elements - float elements
      Returns:
      an array with all float elements
    • primitiveIndexOf

      public static int primitiveIndexOf(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 the element not exists
    • primitiveLastIndexOf

      public static int primitiveLastIndexOf(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 the element not exists
    • primitiveContains

      public static boolean primitiveContains(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
    • primitiveLastElement

      @NotNull public static @NotNull Optional<Float> primitiveLastElement(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
    • primitiveUnsafeLastElement

      public static float primitiveUnsafeLastElement(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
    • toObjectArray

      public static Float @NotNull [] toObjectArray(float[] array)
      Convert any array to an object array. This also applies to primitive types.
      Parameters:
      array - the array to convert
      Returns:
      a converted array object
    • primitiveTransform

      public static <T> T @NotNull [] primitiveTransform(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
    • primitiveTransform

      public static <T> Object @NotNull [] primitiveTransform(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
    • primitiveContentEquals

      public static boolean primitiveContentEquals(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
    • makeLong

      public static long[] makeLong(long... elements)
      Generate a primitive long array
      Parameters:
      elements - long elements
      Returns:
      an array with all long elements
    • makeLongObj

      @Contract(pure=true) public static long @NotNull [] makeLongObj(Long @NotNull ... elements)
      Generate a primitive long array
      Parameters:
      elements - long elements
      Returns:
      an array with all long elements
    • primitiveIndexOf

      public static int primitiveIndexOf(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 the element not exists
    • primitiveLastIndexOf

      public static int primitiveLastIndexOf(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 the element not exists
    • primitiveContains

      public static boolean primitiveContains(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
    • primitiveLastElement

      @NotNull public static @NotNull Optional<Long> primitiveLastElement(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
    • primitiveUnsafeLastElement

      public static long primitiveUnsafeLastElement(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
    • toObjectArray

      public static Long @NotNull [] toObjectArray(long[] array)
      Convert any array to an object array. This also applies to primitive types.
      Parameters:
      array - the array to convert
      Returns:
      a converted array object
    • primitiveTransform

      public static <T> T @NotNull [] primitiveTransform(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
    • primitiveTransform

      public static <T> Object @NotNull [] primitiveTransform(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
    • primitiveContentEquals

      public static boolean primitiveContentEquals(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
    • makeInt

      public static int[] makeInt(int... elements)
      Generate a primitive int array
      Parameters:
      elements - int elements
      Returns:
      an array with all int elements
    • makeIntObj

      public static int @NotNull [] makeIntObj(Integer @NotNull ... elements)
      Generate a primitive int array
      Parameters:
      elements - int elements
      Returns:
      an array with all int elements
    • primitiveIndexOf

      public static int primitiveIndexOf(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 the element not exists
    • primitiveLastIndexOf

      public static int primitiveLastIndexOf(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 the element not exists
    • primitiveContains

      public static boolean primitiveContains(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
    • primitiveLastElement

      @NotNull public static @NotNull Optional<Integer> primitiveLastElement(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
    • primitiveUnsafeLastElement

      public static int primitiveUnsafeLastElement(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
    • toObjectArray

      public static Integer @NotNull [] toObjectArray(int[] array)
      Convert any array to an object array. This also applies to primitive types.
      Parameters:
      array - the array to convert
      Returns:
      a converted array object
    • primitiveTransform

      public static <T> T @NotNull [] primitiveTransform(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
    • primitiveTransform

      public static <T> Object @NotNull [] primitiveTransform(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
    • primitiveContentEquals

      public static boolean primitiveContentEquals(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
    • makeShort

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

      @Contract(pure=true) public static short @NotNull [] makeShortObj(Short @NotNull ... elements)
      Generate a primitive short array
      Parameters:
      elements - short elements
      Returns:
      an array with all shot elements
    • primitiveIndexOf

      public static int primitiveIndexOf(short @NotNull [] array, @org.jetbrains.annotations.Range(from=-32768L, to=32767L) 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 an element not exists
    • primitiveLastIndexOf

      public static int primitiveLastIndexOf(short @NotNull [] array, @org.jetbrains.annotations.Range(from=-32768L, to=32767L) 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 the element not exists
    • primitiveContains

      public static boolean primitiveContains(short @NotNull [] array, @org.jetbrains.annotations.Range(from=-32768L, to=32767L) 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
    • primitiveLastElement

      @NotNull public static @NotNull Optional<Short> primitiveLastElement(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
    • primitiveUnsafeLastElement

      public static short primitiveUnsafeLastElement(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
    • toObjectArray

      public static Short @NotNull [] toObjectArray(short[] array)
      Convert any array to an object array. This also applies to primitive types.
      Parameters:
      array - the array to convert
      Returns:
      a converted array object
    • primitiveTransform

      public static <T> T @NotNull [] primitiveTransform(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
    • primitiveTransform

      public static <T> Object @NotNull [] primitiveTransform(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
    • primitiveContentEquals

      public static boolean primitiveContentEquals(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
    • makeByte

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

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

      public static int primitiveIndexOf(byte @NotNull [] array, @org.jetbrains.annotations.Range(from=-128L, to=127L) 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 an element not exists
    • primitiveLastIndexOf

      public static int primitiveLastIndexOf(byte @NotNull [] array, @org.jetbrains.annotations.Range(from=-128L, to=127L) 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 UArraysConstants.INDEX_NOT_FOUND if an element not exists
    • primitiveContains

      public static boolean primitiveContains(byte @NotNull [] array, @org.jetbrains.annotations.Range(from=-128L, to=127L) 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
    • primitiveLastElement

      @NotNull public static @NotNull Optional<Byte> primitiveLastElement(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
    • primitiveUnsafeLastElement

      public static byte primitiveUnsafeLastElement(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
    • toObjectArray

      public static Byte @NotNull [] toObjectArray(byte[] array)
      Convert any array to an object array. This also applies to primitive types.
      Parameters:
      array - the array to convert
      Returns:
      a converted array object
    • primitiveTransform

      public static <T> T @NotNull [] primitiveTransform(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
    • primitiveTransform

      public static <T> Object @NotNull [] primitiveTransform(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
    • primitiveContentEquals

      public static boolean primitiveContentEquals(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
    • primitiveUnsignedByteArray

      public static int @NotNull [] primitiveUnsignedByteArray(byte[] array)
      Gets a new array but removing the sign to only get positive integers and not get invalid data.
      Parameters:
      array - the array you want to transform
      Returns:
      the result of the conversion to positive unsigned integers
    • makeChar

      public static char[] makeChar(char... elements)
      Generate a primitive char array
      Parameters:
      elements - char elements
      Returns:
      an array with all char elements
    • makeCharObj

      @Contract(pure=true) public static char @NotNull [] makeCharObj(Character @NotNull ... elements)
      Generate a primitive char array
      Parameters:
      elements - char elements
      Returns:
      an array with all char elements
    • primitiveIndexOf

      public static int primitiveIndexOf(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 an element not exists
    • primitiveLastIndexOf

      public static int primitiveLastIndexOf(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 an element not exists
    • primitiveContains

      public static boolean primitiveContains(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
    • primitiveLastElement

      @NotNull public static @NotNull Optional<Character> primitiveLastElement(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
    • primitiveUnsafeLastElement

      public static char primitiveUnsafeLastElement(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
    • toObjectArray

      public static Character @NotNull [] toObjectArray(char[] array)
      Convert any array to an object array. This also applies to primitive types.
      Parameters:
      array - the array to convert
      Returns:
      a converted array object
    • PrimitiveTransform

      public static <T> T @NotNull [] PrimitiveTransform(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
    • PrimitiveTransform

      public static <T> Object @NotNull [] PrimitiveTransform(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
    • primitiveContentEquals

      public static boolean primitiveContentEquals(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
    • makeBoolean

      public static boolean[] makeBoolean(boolean... elements)
      Generate a primitive boolean array
      Parameters:
      elements - boolean elements
      Returns:
      an array with all boolean elements
    • makeBooleanObj

      public static boolean @NotNull [] makeBooleanObj(Boolean @NotNull ... elements)
      Generate a primitive boolean array
      Parameters:
      elements - int elements
      Returns:
      an array with all boolean elements
    • toObjectArray

      public static Boolean[] toObjectArray(boolean[] array)
      Convert any array to an object array. This also applies to primitive types.
      Parameters:
      array - the array to convert
      Returns:
      a converted array object
    • primitiveTransform

      public static <T> T @NotNull [] primitiveTransform(boolean[] original, @NotNull @NotNull Function<Boolean,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
    • primitiveTransform

      public static <T> Object @NotNull [] primitiveTransform(boolean[] original, @NotNull @NotNull Function<Boolean,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