Package dev.prozilla.pine.common.util
Class ArrayUtils
java.lang.Object
dev.prozilla.pine.common.util.ArrayUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E> booleancontains(E[] array, E element) Checks if an array contains an element.static <E> EfindByString(E[] array, String string) Finds the element in an array of which the result ofObject.toString()is equal to a given string.static <E> EfindByString(E[] array, String string, boolean ignoreCase) static <E> booleanoverlaps(E[] arrayA, E[] arrayB) Checks if two arrays have any overlapping elements.static <E> E[]removeFirst(int count, E[] array) Creates a copy of an array without the first element(s).static <E> E[]removeFirst(E[] array) Creates a copy of an array without the first element.static <E> E[]removeLast(int count, E[] array) Creates a copy of an array without the last element(s).static <E> E[]removeLast(E[] array) Creates a copy of an array without the last element.static voidshuffle(double[] array, long seed) static <E> voidshuffle(E[] array, long seed) static <E> String
-
Method Details
-
toString
-
overlaps
@Contract("_, null -> false; null, _ -> false") public static <E> boolean overlaps(E[] arrayA, E[] arrayB) Checks if two arrays have any overlapping elements.- Type Parameters:
E- Type of the array elements- Parameters:
arrayA- First arrayarrayB- Second array- Returns:
- True if any of the elements in
arrayAalso appear inarrayB.
-
contains
public static <E> boolean contains(E[] array, E element) Checks if an array contains an element.- Type Parameters:
E- Type of the array elements- Returns:
- True if one of the elements of the array is equal to
element.
-
findByString
Finds the element in an array of which the result ofObject.toString()is equal to a given string.- Type Parameters:
E- Type of the array elements- Parameters:
array- The array to search instring- The string representation of the element to search for- Returns:
- The element of which the string representation matches
string, ornullif there isn't one.
-
findByString
-
shuffle
public static <E> void shuffle(E[] array, long seed) -
shuffle
public static void shuffle(double[] array, long seed) -
removeFirst
public static <E> E[] removeFirst(E[] array) Creates a copy of an array without the first element.- Parameters:
array- The original array- Returns:
- The copy of the array
-
removeFirst
public static <E> E[] removeFirst(int count, E[] array) Creates a copy of an array without the first element(s).- Parameters:
count- The amount of elements to exclude in the copyarray- The original array- Returns:
- The copy of the array
-
removeLast
public static <E> E[] removeLast(E[] array) Creates a copy of an array without the last element.- Parameters:
array- The original array- Returns:
- The copy of the array
-
removeLast
public static <E> E[] removeLast(int count, E[] array) Creates a copy of an array without the last element(s).- Parameters:
count- The amount of elements to exclude in the copyarray- The original array- Returns:
- The copy of the array
-