Class ArrayUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean[]add(boolean[] array, boolean el, int index) Copies the array and inserts the specified element at the specified index.static byte[]add(byte[] array, byte el, int index) Copies the array and inserts the specified element at the specified index.static char[]add(char[] array, char el, int index) Copies the array and inserts the specified element at the specified index.static double[]add(double[] array, double el, int index) Copies the array and inserts the specified element at the specified index.static float[]add(float[] array, float el, int index) Copies the array and inserts the specified element at the specified index.static int[]add(int[] array, int el, int index) Copies the array and inserts the specified element at the specified index.static long[]add(long[] array, long el, int index) Copies the array and inserts the specified element at the specified index.static short[]add(short[] array, short el, int index) Copies the array and inserts the specified element at the specified index.static <T> T[]add(T[] array, T el, int index, IntFunction<T[]> arrayFactory) Copies the array and inserts the specified element at the specified index.static boolean[]addFirst(boolean[] array, boolean el) Copies the array and inserts the specified element to the front.static byte[]addFirst(byte[] array, byte el) Copies the array and inserts the specified element to the front.static char[]addFirst(char[] array, char el) Copies the array and inserts the specified element to the front.static double[]addFirst(double[] array, double el) Copies the array and inserts the specified element to the front.static float[]addFirst(float[] array, float el) Copies the array and inserts the specified element to the front.static int[]addFirst(int[] array, int el) Copies the array and inserts the specified element to the front.static long[]addFirst(long[] array, long el) Copies the array and inserts the specified element to the front.static short[]addFirst(short[] array, short el) Copies the array and inserts the specified element to the front.static <T> T[]addFirst(T[] array, T el, IntFunction<T[]> arrayFactory) Copies the array and inserts the specified element to the front.static boolean[]addLast(boolean[] array, boolean el) Copies the array and inserts the specified element at the end.static byte[]addLast(byte[] array, byte el) Copies the array and inserts the specified element at the end.static char[]addLast(char[] array, char el) Copies the array and inserts the specified element at the end.static double[]addLast(double[] array, double el) Copies the array and inserts the specified element at the end.static float[]addLast(float[] array, float el) Copies the array and inserts the specified element at the end.static int[]addLast(int[] array, int el) Copies the array and inserts the specified element at the end.static long[]addLast(long[] array, long el) Copies the array and inserts the specified element at the end.static short[]addLast(short[] array, short el) Copies the array and inserts the specified element at the end.static <T> T[]addLast(T[] array, T el, IntFunction<T[]> arrayFactory) Copies the array and inserts the specified element at the end.static boolean[]concat(boolean[]... arrays) Concatenates all specified arrays.static boolean[]concat(boolean[] array1, boolean[] array2) Concatenates both arrays.static byte[]concat(byte[]... arrays) Concatenates all specified arrays.static byte[]concat(byte[] array1, byte[] array2) Concatenates both arrays.static char[]concat(char[]... arrays) Concatenates all specified arrays.static char[]concat(char[] array1, char[] array2) Concatenates both arrays.static double[]concat(double[]... arrays) Concatenates all specified arrays.static double[]concat(double[] array1, double[] array2) Concatenates both arrays.static float[]concat(float[]... arrays) Concatenates all specified arrays.static float[]concat(float[] array1, float[] array2) Concatenates both arrays.static int[]concat(int[]... arrays) Concatenates all specified arrays.static int[]concat(int[] array1, int[] array2) Concatenates both arrays.static long[]concat(long[]... arrays) Concatenates all specified arrays.static long[]concat(long[] array1, long[] array2) Concatenates both arrays.static short[]concat(short[]... arrays) Concatenates all specified arrays.static short[]concat(short[] array1, short[] array2) Concatenates both arrays.static <T> T[]concat(IntFunction<T[]> arrayFactory, T[]... arrays) Concatenates all specified arrays.static <T, C extends Collection<T>>
Cconcat(Supplier<C> factory, Collection<? extends T>... collections) Concatenates the specified collections to a single one.static <T> T[]concat(T[] array1, T[] array2, IntFunction<T[]> arrayFactory) Concatenates both arrays.static booleancontains(boolean[] array, boolean element) Returns if the specified array contains the specified element.static booleancontains(byte[] array, byte element) Returns if the specified array contains the specified element.static booleancontains(char[] array, char element) Returns if the specified array contains the specified element.static booleancontains(double[] array, double element) Returns if the specified array contains the specified element.static booleancontains(float[] array, float element) Returns if the specified array contains the specified element.static booleancontains(int[] array, int element) Returns if the specified array contains the specified element.static booleancontains(long[] array, long element) Returns if the specified array contains the specified element.static booleancontains(short[] array, short element) Returns if the specified array contains the specified element.static <T> booleancontains(T[] array, T element) Returns if the specified array contains the specified element.static <T> booleancontainsEqual(T[] array, T element) Returns if the specified array contains an element that is equal to the specified element.static intindexOf(boolean[] array, boolean element) Returns the first index of the specified element in the array.static intindexOf(boolean[] array, boolean element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies.static intindexOf(byte[] array, byte element) Returns the first index of the specified element in the array.static intindexOf(byte[] array, byte element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies.static intindexOf(char[] array, char element) Returns the first index of the specified element in the array.static intindexOf(char[] array, char element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies.static intindexOf(double[] array, double element) Returns the first index of the specified element in the array.static intindexOf(double[] array, double element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies.static intindexOf(float[] array, float element) Returns the first index of the specified element in the array.static intindexOf(float[] array, float element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies.static intindexOf(int[] array, int element) Returns the first index of the specified element in the array.static intindexOf(int[] array, int element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies.static intindexOf(long[] array, long element) Returns the first index of the specified element in the array.static intindexOf(long[] array, long element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies.static intindexOf(short[] array, short element) Returns the first index of the specified element in the array.static intindexOf(short[] array, short element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies.static <T> intindexOf(T[] array, T element) Returns the first index of the specified element in the array.static <T> intindexOf(T[] array, T element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies.static <T> intindexOfEqual(T[] array, T element) Returns the first index of an element in the array that is equal to the specified element.static <T> intindexOfEqual(T[] array, T element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] equals elementapplies.static booleanisEqualCT(byte[] expected, byte[] actual) Performs a near-constant-time comparison for the specified arrays.static booleanisEqualCT(char[] expected, char[] actual) Performs a near-constant-time comparison for the specified arrays.static booleanisEqualCT(int[] expected, int[] actual) Performs a near-constant-time comparison for the specified arrays.static booleanisEqualCT(long[] expected, long[] actual) Performs a near-constant-time comparison for the specified arrays.static booleanisEqualCT(short[] expected, short[] actual) Performs a near-constant-time comparison for the specified arrays.static intlastIndexOf(boolean[] array, boolean element) Returns the last index of the specified element in the array.static intlastIndexOf(boolean[] array, boolean element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies.static intlastIndexOf(byte[] array, byte element) Returns the last index of the specified element in the array.static intlastIndexOf(byte[] array, byte element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies.static intlastIndexOf(char[] array, char element) Returns the last index of the specified element in the array.static intlastIndexOf(char[] array, char element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies.static intlastIndexOf(double[] array, double element) Returns the last index of the specified element in the array.static intlastIndexOf(double[] array, double element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies.static intlastIndexOf(float[] array, float element) Returns the last index of the specified element in the array.static intlastIndexOf(float[] array, float element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies.static intlastIndexOf(int[] array, int element) Returns the last index of the specified element in the array.static intlastIndexOf(int[] array, int element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies.static intlastIndexOf(long[] array, long element) Returns the last index of the specified element in the array.static intlastIndexOf(long[] array, long element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies.static intlastIndexOf(short[] array, short element) Returns the last index of the specified element in the array.static intlastIndexOf(short[] array, short element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies.static <T> intlastIndexOf(T[] array, T element) Returns the last index of the specified element in the array.static <T> intlastIndexOf(T[] array, T element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies.static <T> intlastIndexOfEqual(T[] array, T element) Returns the last index of an element in the array that is equal to the specified element.static <T> intlastIndexOfEqual(T[] array, T element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] equals elementapplies.static boolean[]remove(boolean[] array, boolean el) Copies the array, but skips the first appearance of the specified element.static byte[]remove(byte[] array, byte el) Copies the array, but skips the first appearance of the specified element.static char[]remove(char[] array, char el) Copies the array, but skips the first appearance of the specified element.static double[]remove(double[] array, double el) Copies the array, but skips the first appearance of the specified element.static float[]remove(float[] array, float el) Copies the array, but skips the first appearance of the specified element.static int[]remove(int[] array, int el) Copies the array, but skips the first appearance of the specified element.static long[]remove(long[] array, long el) Copies the array, but skips the first appearance of the specified element.static short[]remove(short[] array, short el) Copies the array, but skips the first appearance of the specified element.static <T> T[]remove(T[] array, T el, IntFunction<T[]> arrayFactory) Copies the array, but skips the first appearance of the specified element.static <T> T[]removeEqual(T[] array, T el, IntFunction<T[]> arrayFactory) Copies the array, but skips the first appearance an element that is equal to the specified element.static boolean[]removeIndex(boolean[] array, int index) Copies the array, but skips the specified index.static byte[]removeIndex(byte[] array, int index) Copies the array, but skips the specified index.static char[]removeIndex(char[] array, int index) Copies the array, but skips the specified index.static double[]removeIndex(double[] array, int index) Copies the array, but skips the specified index.static float[]removeIndex(float[] array, int index) Copies the array, but skips the specified index.static int[]removeIndex(int[] array, int index) Copies the array, but skips the specified index.static long[]removeIndex(long[] array, int index) Copies the array, but skips the specified index.static short[]removeIndex(short[] array, int index) Copies the array, but skips the specified index.static <T> T[]removeIndex(T[] array, int index, IntFunction<T[]> arrayFactory) Copies the array, but skips the specified index.static boolean[]reverse(boolean[] array) Reverses the specified array inplace.static byte[]reverse(byte[] array) Reverses the specified array inplace.static char[]reverse(char[] array) Reverses the specified array inplace.static double[]reverse(double[] array) Reverses the specified array inplace.static float[]reverse(float[] array) Reverses the specified array inplace.static int[]reverse(int[] array) Reverses the specified array inplace.static long[]reverse(long[] array) Reverses the specified array inplace.static short[]reverse(short[] array) Reverses the specified array inplace.static <T> T[]reverse(T[] array) Reverses the specified array inplace.
-
Method Details
-
indexOfEqual
public static <T> int indexOfEqual(T[] array, T element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] equals elementapplies. If the array isnull, it does not contain any elements.- Type Parameters:
T- The type of the elements.- Parameters:
array- The array. May benull.element- The element. May benull.startIndex- The index where to start the search.- Returns:
- The first index of the specified element ≥ startIndex.
If no such index exists,
-1is returned.
-
indexOfEqual
public static <T> int indexOfEqual(T[] array, T element) Returns the first index of an element in the array that is equal to the specified element. If the array isnull, it does not contain any elements.- Type Parameters:
T- The type of the elements.- Parameters:
array- The array. May benull.element- The element. May benull.- Returns:
- The first index of the specified element.
If the array does not contain the specified element,
-1is returned.
-
lastIndexOfEqual
public static <T> int lastIndexOfEqual(T[] array, T element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] equals elementapplies. If the array isnull, it does not contain any elements.- Type Parameters:
T- The type of the elements.- Parameters:
array- The array. May benull.element- The element. May benull.startIndex- The index where to start the search.- Returns:
- The last index of the specified element ≤ startIndex.
If no such index exists,
-1is returned.
-
lastIndexOfEqual
public static <T> int lastIndexOfEqual(T[] array, T element) Returns the last index of an element in the array that is equal to the specified element. If the array isnull, it does not contain any elements.- Type Parameters:
T- The type of the elements.- Parameters:
array- The array. May benull.element- The element. May benull.- Returns:
- The last index of the specified element.
If the array does not contain the element,
-1is returned.
-
containsEqual
public static <T> boolean containsEqual(T[] array, T element) Returns if the specified array contains an element that is equal to the specified element. The arraynulldoes not contain any elements.- Type Parameters:
T- The type of the elements.- Parameters:
array- The array. May benull.element- The element. May benull.- Returns:
- If the array contains the specified element.
-
indexOf
public static <T> int indexOf(T[] array, T element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Type Parameters:
T- The type of the elements.- Parameters:
array- The array. May benull.element- The element. May benull.startIndex- The index where to start the search.- Returns:
- The first index of the specified element ≥ startIndex.
If no such index exists,
-1is returned.
-
indexOf
public static <T> int indexOf(T[] array, T element) Returns the first index of the specified element in the array. If the array isnull, it does not contain any elements.- Type Parameters:
T- The type of the elements.- Parameters:
array- The array. May benull.element- The element. May benull.- Returns:
- The first index of the specified element.
If the array does not contain the specified element,
-1is returned.
-
lastIndexOf
public static <T> int lastIndexOf(T[] array, T element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Type Parameters:
T- The type of the elements.- Parameters:
array- The array. May benull.element- The element. May benull.startIndex- The index where to start the search.- Returns:
- The last index of the specified element ≤ startIndex.
If no such index exists,
-1is returned.
-
lastIndexOf
public static <T> int lastIndexOf(T[] array, T element) Returns the last index of the specified element in the array. If the array isnull, it does not contain any elements.- Type Parameters:
T- The type of the elements.- Parameters:
array- The array. May benull.element- The element. May benull.- Returns:
- The last index of the specified element.
If the array does not contain the element,
-1is returned.
-
contains
public static <T> boolean contains(T[] array, T element) Returns if the specified array contains the specified element. The arraynulldoes not contain any elements.- Type Parameters:
T- The type of the elements.- Parameters:
array- The array. May benull.element- The element. May benull.- Returns:
- If the array contains the specified element.
-
indexOf
public static int indexOf(int[] array, int element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The first index of the specified element ≥ startIndex.
If no such index exists,
-1is returned.
-
indexOf
public static int indexOf(int[] array, int element) Returns the first index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The first index of the specified element.
If the array does not contain the specified element,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(int[] array, int element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The last index of the specified element ≤ startIndex.
If no such index exists,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(int[] array, int element) Returns the last index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The last index of the specified element.
If the array does not contain the element,
-1is returned.
-
contains
public static boolean contains(int[] array, int element) Returns if the specified array contains the specified element. The arraynulldoes not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- If the array contains the specified element.
-
indexOf
public static int indexOf(long[] array, long element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The first index of the specified element ≥ startIndex.
If no such index exists,
-1is returned.
-
indexOf
public static int indexOf(long[] array, long element) Returns the first index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The first index of the specified element.
If the array does not contain the specified element,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(long[] array, long element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The last index of the specified element ≤ startIndex.
If no such index exists,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(long[] array, long element) Returns the last index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The last index of the specified element.
If the array does not contain the element,
-1is returned.
-
contains
public static boolean contains(long[] array, long element) Returns if the specified array contains the specified element. The arraynulldoes not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- If the array contains the specified element.
-
indexOf
public static int indexOf(byte[] array, byte element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The first index of the specified element ≥ startIndex.
If no such index exists,
-1is returned.
-
indexOf
public static int indexOf(byte[] array, byte element) Returns the first index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The first index of the specified element.
If the array does not contain the specified element,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(byte[] array, byte element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The last index of the specified element ≤ startIndex.
If no such index exists,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(byte[] array, byte element) Returns the last index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The last index of the specified element.
If the array does not contain the element,
-1is returned.
-
contains
public static boolean contains(byte[] array, byte element) Returns if the specified array contains the specified element. The arraynulldoes not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- If the array contains the specified element.
-
indexOf
public static int indexOf(short[] array, short element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The first index of the specified element ≥ startIndex.
If no such index exists,
-1is returned.
-
indexOf
public static int indexOf(short[] array, short element) Returns the first index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The first index of the specified element.
If the array does not contain the specified element,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(short[] array, short element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The last index of the specified element ≤ startIndex.
If no such index exists,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(short[] array, short element) Returns the last index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The last index of the specified element.
If the array does not contain the element,
-1is returned.
-
contains
public static boolean contains(short[] array, short element) Returns if the specified array contains the specified element. The arraynulldoes not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- If the array contains the specified element.
-
indexOf
public static int indexOf(char[] array, char element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The first index of the specified element ≥ startIndex.
If no such index exists,
-1is returned.
-
indexOf
public static int indexOf(char[] array, char element) Returns the first index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The first index of the specified element.
If the array does not contain the specified element,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(char[] array, char element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The last index of the specified element ≤ startIndex.
If no such index exists,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(char[] array, char element) Returns the last index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The last index of the specified element.
If the array does not contain the element,
-1is returned.
-
contains
public static boolean contains(char[] array, char element) Returns if the specified array contains the specified element. The arraynulldoes not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- If the array contains the specified element.
-
indexOf
public static int indexOf(float[] array, float element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The first index of the specified element ≥ startIndex.
If no such index exists,
-1is returned.
-
indexOf
public static int indexOf(float[] array, float element) Returns the first index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The first index of the specified element.
If the array does not contain the specified element,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(float[] array, float element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The last index of the specified element ≤ startIndex.
If no such index exists,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(float[] array, float element) Returns the last index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The last index of the specified element.
If the array does not contain the element,
-1is returned.
-
contains
public static boolean contains(float[] array, float element) Returns if the specified array contains the specified element. The arraynulldoes not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- If the array contains the specified element.
-
indexOf
public static int indexOf(double[] array, double element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The first index of the specified element ≥ startIndex.
If no such index exists,
-1is returned.
-
indexOf
public static int indexOf(double[] array, double element) Returns the first index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The first index of the specified element.
If the array does not contain the specified element,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(double[] array, double element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The last index of the specified element ≤ startIndex.
If no such index exists,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(double[] array, double element) Returns the last index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The last index of the specified element.
If the array does not contain the element,
-1is returned.
-
contains
public static boolean contains(double[] array, double element) Returns if the specified array contains the specified element. The arraynulldoes not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- If the array contains the specified element.
-
indexOf
public static int indexOf(boolean[] array, boolean element, int startIndex) Returns the first index that is greater than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The first index of the specified element ≥ startIndex.
If no such index exists,
-1is returned.
-
indexOf
public static int indexOf(boolean[] array, boolean element) Returns the first index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The first index of the specified element.
If the array does not contain the specified element,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(boolean[] array, boolean element, int startIndex) Returns the last index in the array that is less than or equal to thestartIndexfor whicharray[index] == elementapplies. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.startIndex- The index where to start the search.- Returns:
- The last index of the specified element ≤ startIndex.
If no such index exists,
-1is returned.
-
lastIndexOf
public static int lastIndexOf(boolean[] array, boolean element) Returns the last index of the specified element in the array. If the array isnull, it does not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- The last index of the specified element.
If the array does not contain the element,
-1is returned.
-
contains
public static boolean contains(boolean[] array, boolean element) Returns if the specified array contains the specified element. The arraynulldoes not contain any elements.- Parameters:
array- The array. May benull.element- The element.- Returns:
- If the array contains the specified element.
-
concat
Concatenates both arrays. If an array isnull, it is handled like an empty array.All elements from
array1are before all fromarray2. The order of the elements is preserved.- Type Parameters:
T- The type of the array elements.- Parameters:
array1- The first array. May benull.array2- The second array. May benull.arrayFactory- A factory that should create new arrays of the typeT. Should be implemented likeT[]::new.- Returns:
- An array that contains all elements from both specified arrays.
The returned array is always created using the array factory.
The returned array is not
null. - Throws:
NullPointerException- If the array factory isnullor creates an arraynull.ArrayStoreException- If the array factory does not create aT[]and a type mismatch occurs.
-
concat
Concatenates all specified arrays. If an array isnull, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.- Type Parameters:
T- The type of the array elements.- Parameters:
arrayFactory- A factory that should create new arrays of the typeT. Should be implemented likeT[]::new.arrays- The arrays that should be concatenated. Must not benull, but the arrays inside may benull.- Returns:
- An array that contains all elements from all specified arrays.
- Throws:
NullPointerException- If the array factory isnullor creates an arraynull.ArrayStoreException- If the array factory does not create aT[]and a type mismatch occurs.
-
concat
@SafeVarargs public static <T, C extends Collection<T>> C concat(Supplier<C> factory, Collection<? extends T>... collections) Concatenates the specified collections to a single one. The type of the resulting collection is specified by the factory.- Type Parameters:
T- The element type.C- The type of the resulting collection. Must not benull.- Parameters:
factory- The factory that produces an empty collection.collections- The collections that should be concatenated. Must not benull, but the inner collections may benull.- Returns:
- A collection that contains all elements of the specified collections.
The resulting collection is created using the factory.
If the factory does not return
null, the result is notnull.
-
concat
public static int[] concat(int[] array1, int[] array2) Concatenates both arrays. If an array isnull, it is handled like an empty array.All elements from
array1are before all fromarray2. The order of the elements is preserved.- Parameters:
array1- The first array. May benull.array2- The second array. May benull.- Returns:
- An array that contains all elements from both specified arrays.
Not
null. A new array is created.
-
concat
public static int[] concat(int[]... arrays) Concatenates all specified arrays. If an array isnull, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.- Parameters:
arrays- The arrays that should be concatenated. Must not benull, but the arrays inside may benull.- Returns:
- An array that contains all elements from all specified arrays.
Not
null. A new array is created.
-
concat
public static long[] concat(long[] array1, long[] array2) Concatenates both arrays. If an array isnull, it is handled like an empty array.All elements from
array1are before all fromarray2. The order of the elements is preserved.- Parameters:
array1- The first array. May benull.array2- The second array. May benull.- Returns:
- An array that contains all elements from both specified arrays.
Not
null. A new array is created.
-
concat
public static long[] concat(long[]... arrays) Concatenates all specified arrays. If an array isnull, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.- Parameters:
arrays- The arrays that should be concatenated. Must not benull, but the arrays inside may benull.- Returns:
- An array that contains all elements from all specified arrays.
Not
null. A new array is created.
-
concat
public static byte[] concat(byte[] array1, byte[] array2) Concatenates both arrays. If an array isnull, it is handled like an empty array.All elements from
array1are before all fromarray2. The order of the elements is preserved.- Parameters:
array1- The first array. May benull.array2- The second array. May benull.- Returns:
- An array that contains all elements from both specified arrays.
Not
null. A new array is created.
-
concat
public static byte[] concat(byte[]... arrays) Concatenates all specified arrays. If an array isnull, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.- Parameters:
arrays- The arrays that should be concatenated. Must not benull, but the arrays inside may benull.- Returns:
- An array that contains all elements from all specified arrays.
Not
null. A new array is created.
-
concat
public static short[] concat(short[] array1, short[] array2) Concatenates both arrays. If an array isnull, it is handled like an empty array.All elements from
array1are before all fromarray2. The order of the elements is preserved.- Parameters:
array1- The first array. May benull.array2- The second array. May benull.- Returns:
- An array that contains all elements from both specified arrays.
Not
null. A new array is created.
-
concat
public static short[] concat(short[]... arrays) Concatenates all specified arrays. If an array isnull, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.- Parameters:
arrays- The arrays that should be concatenated. Must not benull, but the arrays inside may benull.- Returns:
- An array that contains all elements from all specified arrays.
Not
null. A new array is created.
-
concat
public static char[] concat(char[] array1, char[] array2) Concatenates both arrays. If an array isnull, it is handled like an empty array.All elements from
array1are before all fromarray2. The order of the elements is preserved.- Parameters:
array1- The first array. May benull.array2- The second array. May benull.- Returns:
- An array that contains all elements from both specified arrays.
Not
null. A new array is created.
-
concat
public static char[] concat(char[]... arrays) Concatenates all specified arrays. If an array isnull, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.- Parameters:
arrays- The arrays that should be concatenated. Must not benull, but the arrays inside may benull.- Returns:
- An array that contains all elements from all specified arrays.
Not
null. A new array is created.
-
concat
public static float[] concat(float[] array1, float[] array2) Concatenates both arrays. If an array isnull, it is handled like an empty array.All elements from
array1are before all fromarray2. The order of the elements is preserved.- Parameters:
array1- The first array. May benull.array2- The second array. May benull.- Returns:
- An array that contains all elements from both specified arrays.
Not
null. A new array is created.
-
concat
public static float[] concat(float[]... arrays) Concatenates all specified arrays. If an array isnull, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.- Parameters:
arrays- The arrays that should be concatenated. Must not benull, but the arrays inside may benull.- Returns:
- An array that contains all elements from all specified arrays.
Not
null. A new array is created.
-
concat
public static double[] concat(double[] array1, double[] array2) Concatenates both arrays. If an array isnull, it is handled like an empty array.All elements from
array1are before all fromarray2. The order of the elements is preserved.- Parameters:
array1- The first array. May benull.array2- The second array. May benull.- Returns:
- An array that contains all elements from both specified arrays.
Not
null. A new array is created.
-
concat
public static double[] concat(double[]... arrays) Concatenates all specified arrays. If an array isnull, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.- Parameters:
arrays- The arrays that should be concatenated. Must not benull, but the arrays inside may benull.- Returns:
- An array that contains all elements from all specified arrays.
Not
null. A new array is created.
-
concat
public static boolean[] concat(boolean[] array1, boolean[] array2) Concatenates both arrays. If an array isnull, it is handled like an empty array.All elements from
array1are before all fromarray2. The order of the elements is preserved.- Parameters:
array1- The first array. May benull.array2- The second array. May benull.- Returns:
- An array that contains all elements from both specified arrays.
Not
null. A new array is created.
-
concat
public static boolean[] concat(boolean[]... arrays) Concatenates all specified arrays. If an array isnull, it is handled like an empty array. The order of the arrays and the order of the elements inside each array are preserved.- Parameters:
arrays- The arrays that should be concatenated. Must not benull, but the arrays inside may benull.- Returns:
- An array that contains all elements from all specified arrays.
Not
null. A new array is created.
-
reverse
public static <T> T[] reverse(T[] array) Reverses the specified array inplace. If the array isnull, nothing happens andnullis returned.- Type Parameters:
T- The element type.- Parameters:
array- The array that should be reversed. May benull.- Returns:
- The specified array for piping.
-
reverse
public static int[] reverse(int[] array) Reverses the specified array inplace. If the array isnull, nothing happens andnullis returned.- Parameters:
array- The array that should be reversed. May benull.- Returns:
- The specified array for piping.
-
reverse
public static long[] reverse(long[] array) Reverses the specified array inplace. If the array isnull, nothing happens andnullis returned.- Parameters:
array- The array that should be reversed. May benull.- Returns:
- The specified array for piping.
-
reverse
public static byte[] reverse(byte[] array) Reverses the specified array inplace. If the array isnull, nothing happens andnullis returned.- Parameters:
array- The array that should be reversed. May benull.- Returns:
- The specified array for piping.
-
reverse
public static short[] reverse(short[] array) Reverses the specified array inplace. If the array isnull, nothing happens andnullis returned.- Parameters:
array- The array that should be reversed. May benull.- Returns:
- The specified array for piping.
-
reverse
public static char[] reverse(char[] array) Reverses the specified array inplace. If the array isnull, nothing happens andnullis returned.- Parameters:
array- The array that should be reversed. May benull.- Returns:
- The specified array for piping.
-
reverse
public static float[] reverse(float[] array) Reverses the specified array inplace. If the array isnull, nothing happens andnullis returned.- Parameters:
array- The array that should be reversed. May benull.- Returns:
- The specified array for piping.
-
reverse
public static double[] reverse(double[] array) Reverses the specified array inplace. If the array isnull, nothing happens andnullis returned.- Parameters:
array- The array that should be reversed. May benull.- Returns:
- The specified array for piping.
-
reverse
public static boolean[] reverse(boolean[] array) Reverses the specified array inplace. If the array isnull, nothing happens andnullis returned.- Parameters:
array- The array that should be reversed. May benull.- Returns:
- The specified array for piping.
-
add
Copies the array and inserts the specified element at the specified index. If the array isnull, it is handled like an empty array.- Type Parameters:
T- The element type.- Parameters:
array- The array. May benull.el- The element that should be inserted. May benull.index- The index where the element should be inserted. Must not be negative and must not be greater thanarray.length.arrayFactory- A factory that creates arrays of a given size. Should be implemented likeT[]::new.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Throws:
IndexOutOfBoundsException- If the index is negative or greater than the length of the array.- Since:
- 1.1
-
addFirst
Copies the array and inserts the specified element to the front. The resulting array is[el, array...]
If the array isnull, it is handled like an empty array.- Type Parameters:
T- The element type.- Parameters:
array- The array. May benull.el- The element that should be inserted. May benull.arrayFactory- A factory that creates arrays of a given size. Should be implemented likeT[]::new.- Returns:
- A new array that contains the specified element and all elements from the specified array.
Not
null. - Since:
- 1.1
-
addLast
Copies the array and inserts the specified element at the end. The resulting array is[array..., el]
If the array isnull, it is handled like an empty array.- Type Parameters:
T- The element type.- Parameters:
array- The array. May benull.el- The element that should be inserted. May benull.arrayFactory- A factory that creates arrays of a given size. Should be implemented likeT[]::new.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Since:
- 1.1
-
removeIndex
Copies the array, but skips the specified index. The result is an array with one element less. If the array isnull, it is handled like an empty array.- Type Parameters:
T- The element type.- Parameters:
array- The array. May benull.index- The index that should be removed. Must be in range.arrayFactory- A factory that creates arrays of a given size. Should be implemented likeT[]::new.- Returns:
- A new array without the element at the specified index. Not
null. - Throws:
IndexOutOfBoundsException- Ifindex < 0orindex >= array.length. Occurs always if the array is empty ornull.- Since:
- 1.1
-
remove
Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array isnull, it is handled as an empty array.- Type Parameters:
T- The element type.- Parameters:
array- The array. May benull.el- The element that should be removed. May benull.arrayFactory- A factory that creates arrays of a given size. Should be implemented likeT[]::new.- Returns:
- A new array without the first appearance of the specified element.
Might be
nullif the input array isnull. - Since:
- 1.1
-
removeEqual
Copies the array, but skips the first appearance an element that is equal to the specified element. The result is an array with one element less if the array contains such an element. If the array does not contain such an element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array isnull, it is handled as an empty array.- Type Parameters:
T- The element type.- Parameters:
array- The array. May benull.el- The element that should be removed. May benull.arrayFactory- A factory that creates arrays of a given size. Should be implemented likeT[]::new.- Returns:
- A new array without the first appearance of an element that is equal to the specified element.
Might be
nullif the input array isnull. - Since:
- 1.1
-
add
public static int[] add(int[] array, int el, int index) Copies the array and inserts the specified element at the specified index. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.index- The index where the element should be inserted. Must not be negative and must not be greater thanarray.length.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Throws:
IndexOutOfBoundsException- If the index is negative or greater than the length of the array.- Since:
- 1.1
-
addFirst
public static int[] addFirst(int[] array, int el) Copies the array and inserts the specified element to the front. The resulting array is[el, array...]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains the specified element and all elements from the specified array.
Not
null. - Since:
- 1.1
-
addLast
public static int[] addLast(int[] array, int el) Copies the array and inserts the specified element at the end. The resulting array is[array..., el]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Since:
- 1.1
-
removeIndex
public static int[] removeIndex(int[] array, int index) Copies the array, but skips the specified index. The result is an array with one element less. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.index- The index that should be removed. Must be in range.- Returns:
- A new array without the element at the specified index. Not
null. - Throws:
IndexOutOfBoundsException- Ifindex < 0orindex >= array.length. Occurs always if the array is empty ornull.- Since:
- 1.1
-
remove
public static int[] remove(int[] array, int el) Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array isnull, it is handled as an empty array.- Parameters:
array- The array. May benull.el- The element that should be removed.- Returns:
- A new array without the first appearance of the specified element.
Might be
nullif the input array isnull. - Since:
- 1.1
-
add
public static long[] add(long[] array, long el, int index) Copies the array and inserts the specified element at the specified index. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.index- The index where the element should be inserted. Must not be negative and must not be greater thanarray.length.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Throws:
IndexOutOfBoundsException- If the index is negative or greater than the length of the array.- Since:
- 1.1
-
addFirst
public static long[] addFirst(long[] array, long el) Copies the array and inserts the specified element to the front. The resulting array is[el, array...]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains the specified element and all elements from the specified array.
Not
null. - Since:
- 1.1
-
addLast
public static long[] addLast(long[] array, long el) Copies the array and inserts the specified element at the end. The resulting array is[array..., el]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Since:
- 1.1
-
removeIndex
public static long[] removeIndex(long[] array, int index) Copies the array, but skips the specified index. The result is an array with one element less. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.index- The index that should be removed. Must be in range.- Returns:
- A new array without the element at the specified index. Not
null. - Throws:
IndexOutOfBoundsException- Ifindex < 0orindex >= array.length. Occurs always if the array is empty ornull.- Since:
- 1.1
-
remove
public static long[] remove(long[] array, long el) Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array isnull, it is handled as an empty array.- Parameters:
array- The array. May benull.el- The element that should be removed.- Returns:
- A new array without the first appearance of the specified element.
Might be
nullif the input array isnull. - Since:
- 1.1
-
add
public static byte[] add(byte[] array, byte el, int index) Copies the array and inserts the specified element at the specified index. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.index- The index where the element should be inserted. Must not be negative and must not be greater thanarray.length.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Throws:
IndexOutOfBoundsException- If the index is negative or greater than the length of the array.- Since:
- 1.1
-
addFirst
public static byte[] addFirst(byte[] array, byte el) Copies the array and inserts the specified element to the front. The resulting array is[el, array...]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains the specified element and all elements from the specified array.
Not
null. - Since:
- 1.1
-
addLast
public static byte[] addLast(byte[] array, byte el) Copies the array and inserts the specified element at the end. The resulting array is[array..., el]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Since:
- 1.1
-
removeIndex
public static byte[] removeIndex(byte[] array, int index) Copies the array, but skips the specified index. The result is an array with one element less. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.index- The index that should be removed. Must be in range.- Returns:
- A new array without the element at the specified index. Not
null. - Throws:
IndexOutOfBoundsException- Ifindex < 0orindex >= array.length. Occurs always if the array is empty ornull.- Since:
- 1.1
-
remove
public static byte[] remove(byte[] array, byte el) Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array isnull, it is handled as an empty array.- Parameters:
array- The array. May benull.el- The element that should be removed.- Returns:
- A new array without the first appearance of the specified element.
Might be
nullif the input array isnull. - Since:
- 1.1
-
add
public static short[] add(short[] array, short el, int index) Copies the array and inserts the specified element at the specified index. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.index- The index where the element should be inserted. Must not be negative and must not be greater thanarray.length.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Throws:
IndexOutOfBoundsException- If the index is negative or greater than the length of the array.- Since:
- 1.1
-
addFirst
public static short[] addFirst(short[] array, short el) Copies the array and inserts the specified element to the front. The resulting array is[el, array...]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains the specified element and all elements from the specified array.
Not
null. - Since:
- 1.1
-
addLast
public static short[] addLast(short[] array, short el) Copies the array and inserts the specified element at the end. The resulting array is[array..., el]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Since:
- 1.1
-
removeIndex
public static short[] removeIndex(short[] array, int index) Copies the array, but skips the specified index. The result is an array with one element less. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.index- The index that should be removed. Must be in range.- Returns:
- A new array without the element at the specified index. Not
null. - Throws:
IndexOutOfBoundsException- Ifindex < 0orindex >= array.length. Occurs always if the array is empty ornull.- Since:
- 1.1
-
remove
public static short[] remove(short[] array, short el) Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array isnull, it is handled as an empty array.- Parameters:
array- The array. May benull.el- The element that should be removed.- Returns:
- A new array without the first appearance of the specified element.
Might be
nullif the input array isnull. - Since:
- 1.1
-
add
public static char[] add(char[] array, char el, int index) Copies the array and inserts the specified element at the specified index. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.index- The index where the element should be inserted. Must not be negative and must not be greater thanarray.length.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Throws:
IndexOutOfBoundsException- If the index is negative or greater than the length of the array.- Since:
- 1.1
-
addFirst
public static char[] addFirst(char[] array, char el) Copies the array and inserts the specified element to the front. The resulting array is[el, array...]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains the specified element and all elements from the specified array.
Not
null. - Since:
- 1.1
-
addLast
public static char[] addLast(char[] array, char el) Copies the array and inserts the specified element at the end. The resulting array is[array..., el]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Since:
- 1.1
-
removeIndex
public static char[] removeIndex(char[] array, int index) Copies the array, but skips the specified index. The result is an array with one element less. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.index- The index that should be removed. Must be in range.- Returns:
- A new array without the element at the specified index. Not
null. - Throws:
IndexOutOfBoundsException- Ifindex < 0orindex >= array.length. Occurs always if the array is empty ornull.- Since:
- 1.1
-
remove
public static char[] remove(char[] array, char el) Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array isnull, it is handled as an empty array.- Parameters:
array- The array. May benull.el- The element that should be removed.- Returns:
- A new array without the first appearance of the specified element.
Might be
nullif the input array isnull. - Since:
- 1.1
-
add
public static float[] add(float[] array, float el, int index) Copies the array and inserts the specified element at the specified index. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.index- The index where the element should be inserted. Must not be negative and must not be greater thanarray.length.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Throws:
IndexOutOfBoundsException- If the index is negative or greater than the length of the array.- Since:
- 1.1
-
addFirst
public static float[] addFirst(float[] array, float el) Copies the array and inserts the specified element to the front. The resulting array is[el, array...]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains the specified element and all elements from the specified array.
Not
null. - Since:
- 1.1
-
addLast
public static float[] addLast(float[] array, float el) Copies the array and inserts the specified element at the end. The resulting array is[array..., el]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Since:
- 1.1
-
removeIndex
public static float[] removeIndex(float[] array, int index) Copies the array, but skips the specified index. The result is an array with one element less. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.index- The index that should be removed. Must be in range.- Returns:
- A new array without the element at the specified index. Not
null. - Throws:
IndexOutOfBoundsException- Ifindex < 0orindex >= array.length. Occurs always if the array is empty ornull.- Since:
- 1.1
-
remove
public static float[] remove(float[] array, float el) Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array isnull, it is handled as an empty array.- Parameters:
array- The array. May benull.el- The element that should be removed.- Returns:
- A new array without the first appearance of the specified element.
Might be
nullif the input array isnull. - Since:
- 1.1
-
add
public static double[] add(double[] array, double el, int index) Copies the array and inserts the specified element at the specified index. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.index- The index where the element should be inserted. Must not be negative and must not be greater thanarray.length.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Throws:
IndexOutOfBoundsException- If the index is negative or greater than the length of the array.- Since:
- 1.1
-
addFirst
public static double[] addFirst(double[] array, double el) Copies the array and inserts the specified element to the front. The resulting array is[el, array...]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains the specified element and all elements from the specified array.
Not
null. - Since:
- 1.1
-
addLast
public static double[] addLast(double[] array, double el) Copies the array and inserts the specified element at the end. The resulting array is[array..., el]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Since:
- 1.1
-
removeIndex
public static double[] removeIndex(double[] array, int index) Copies the array, but skips the specified index. The result is an array with one element less. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.index- The index that should be removed. Must be in range.- Returns:
- A new array without the element at the specified index. Not
null. - Throws:
IndexOutOfBoundsException- Ifindex < 0orindex >= array.length. Occurs always if the array is empty ornull.- Since:
- 1.1
-
remove
public static double[] remove(double[] array, double el) Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array isnull, it is handled as an empty array.- Parameters:
array- The array. May benull.el- The element that should be removed.- Returns:
- A new array without the first appearance of the specified element.
Might be
nullif the input array isnull. - Since:
- 1.1
-
add
public static boolean[] add(boolean[] array, boolean el, int index) Copies the array and inserts the specified element at the specified index. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.index- The index where the element should be inserted. Must not be negative and must not be greater thanarray.length.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Throws:
IndexOutOfBoundsException- If the index is negative or greater than the length of the array.- Since:
- 1.1
-
addFirst
public static boolean[] addFirst(boolean[] array, boolean el) Copies the array and inserts the specified element to the front. The resulting array is[el, array...]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains the specified element and all elements from the specified array.
Not
null. - Since:
- 1.1
-
addLast
public static boolean[] addLast(boolean[] array, boolean el) Copies the array and inserts the specified element at the end. The resulting array is[array..., el]
If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.el- The element that should be inserted.- Returns:
- A new array that contains all elements from the specified array and the specified element.
Not
null. - Since:
- 1.1
-
removeIndex
public static boolean[] removeIndex(boolean[] array, int index) Copies the array, but skips the specified index. The result is an array with one element less. If the array isnull, it is handled like an empty array.- Parameters:
array- The array. May benull.index- The index that should be removed. Must be in range.- Returns:
- A new array without the element at the specified index. Not
null. - Throws:
IndexOutOfBoundsException- Ifindex < 0orindex >= array.length. Occurs always if the array is empty ornull.- Since:
- 1.1
-
remove
public static boolean[] remove(boolean[] array, boolean el) Copies the array, but skips the first appearance of the specified element. The result is an array with one element less if the array contains the specified element. If the array does not contain the specified element, the input array is returned and not copied. To find out if an element was removed, the length of the input array and the result array can be compared. If the array isnull, it is handled as an empty array.- Parameters:
array- The array. May benull.el- The element that should be removed.- Returns:
- A new array without the first appearance of the specified element.
Might be
nullif the input array isnull. - Since:
- 1.1
-
isEqualCT
public static boolean isEqualCT(int[] expected, int[] actual) Performs a near-constant-time comparison for the specified arrays.The calculation time depends mostly on the length of
actual. In some situations it may depend slightly on the length ofexpected. It does not depend on the contents of both arrays.- Parameters:
expected- The expected array. Notnull.actual- The array that should be tested to match the expected array. Notnull.- Returns:
- If both arrays are equal.
- Since:
- 1.4
-
isEqualCT
public static boolean isEqualCT(long[] expected, long[] actual) Performs a near-constant-time comparison for the specified arrays.The calculation time depends mostly on the length of
actual. In some situations it may depend slightly on the length ofexpected. It does not depend on the contents of both arrays.- Parameters:
expected- The expected array. Notnull.actual- The array that should be tested to match the expected array. Notnull.- Returns:
- If both arrays are equal.
- Since:
- 1.4
-
isEqualCT
public static boolean isEqualCT(byte[] expected, byte[] actual) Performs a near-constant-time comparison for the specified arrays.The calculation time depends mostly on the length of
actual. In some situations it may depend slightly on the length ofexpected. It does not depend on the contents of both arrays.- Parameters:
expected- The expected array. Notnull.actual- The array that should be tested to match the expected array. Notnull.- Returns:
- If both arrays are equal.
- Since:
- 1.4
-
isEqualCT
public static boolean isEqualCT(char[] expected, char[] actual) Performs a near-constant-time comparison for the specified arrays.The calculation time depends mostly on the length of
actual. In some situations it may depend slightly on the length ofexpected. It does not depend on the contents of both arrays.- Parameters:
expected- The expected array. Notnull.actual- The array that should be tested to match the expected array. Notnull.- Returns:
- If both arrays are equal.
- Since:
- 1.4
-
isEqualCT
public static boolean isEqualCT(short[] expected, short[] actual) Performs a near-constant-time comparison for the specified arrays.The calculation time depends mostly on the length of
actual. In some situations it may depend slightly on the length ofexpected. It does not depend on the contents of both arrays.- Parameters:
expected- The expected array. Notnull.actual- The array that should be tested to match the expected array. Notnull.- Returns:
- If both arrays are equal.
- Since:
- 1.4
-