public class ArrayUtil
extends java.lang.Object
Constructor and Description |
---|
ArrayUtil() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
add(byte[] array,
int size,
byte element)
Adds the given element to the given array.
|
static char[] |
add(char[] array,
int size,
char element)
Adds the given element to the given array.
|
static double[] |
add(double[] array,
int size,
double element)
Adds the given element to the given array.
|
static float[] |
add(float[] array,
int size,
float element)
Adds the given element to the given array.
|
static int[] |
add(int[] array,
int size,
int element)
Adds the given element to the given array.
|
static long[] |
add(long[] array,
int size,
long element)
Adds the given element to the given array.
|
static short[] |
add(short[] array,
int size,
short element)
Adds the given element to the given array.
|
static <T> T[] |
add(T[] array,
int size,
T element)
Adds the given element to the given array.
|
static <T> T[] |
cloneOrNull(T[] array)
Returns a shallow copy of the given array, or null if the input is null.
|
static int |
compare(boolean[] array1,
int size1,
boolean[] array2,
int size2)
Compares the elements of the two given arrays.
|
static int |
compare(byte[] array1,
int size1,
byte[] array2,
int size2)
Compares the elements of the two given arrays.
|
static int |
compare(char[] array1,
int size1,
char[] array2,
int size2)
Compares the elements of the two given arrays.
|
static int |
compare(java.lang.Comparable[] array1,
int size1,
java.lang.Comparable[] array2,
int size2)
Compares the elements of the two given arrays.
|
static int |
compare(double[] array1,
int size1,
double[] array2,
int size2)
Compares the elements of the two given arrays.
|
static int |
compare(float[] array1,
int size1,
float[] array2,
int size2)
Compares the elements of the two given arrays.
|
static int |
compare(int[] array1,
int size1,
int[] array2,
int size2)
Compares the elements of the two given arrays.
|
static int |
compare(long[] array1,
int size1,
long[] array2,
int size2)
Compares the elements of the two given arrays.
|
static int |
compare(short[] array1,
int size1,
short[] array2,
int size2)
Compares the elements of the two given arrays.
|
static <T> T[] |
concat(T[] first,
T[] second)
Concatenates two arrays into a single one.
|
static boolean[] |
ensureArraySize(boolean[] array,
int size,
boolean initialValue)
Ensures the given array has a given size.
|
static byte[] |
ensureArraySize(byte[] array,
int size,
byte initialValue)
Ensures the given array has a given size.
|
static char[] |
ensureArraySize(char[] array,
int size,
char initialValue)
Ensures the given array has a given size.
|
static double[] |
ensureArraySize(double[] array,
int size,
double initialValue)
Ensures the given array has a given size.
|
static float[] |
ensureArraySize(float[] array,
int size,
float initialValue)
Ensures the given array has a given size.
|
static int[] |
ensureArraySize(int[] array,
int size,
int initialValue)
Ensures the given array has a given size.
|
static long[] |
ensureArraySize(long[] array,
int size,
long initialValue)
Ensures the given array has a given size.
|
static short[] |
ensureArraySize(short[] array,
int size,
short initialValue)
Ensures the given array has a given size.
|
static <T> T[] |
ensureArraySize(T[] array,
int size,
T initialValue)
Ensures the given array has a given size.
|
static boolean |
equal(boolean[] array1,
boolean[] array2,
int size)
Returns whether the elements of the two given arrays are the same.
|
static boolean |
equal(byte[] array1,
byte[] array2,
int size)
Returns whether the elements of the two given arrays are the same.
|
static boolean |
equal(char[] array1,
char[] array2,
int size)
Returns whether the elements of the two given arrays are the same.
|
static boolean |
equal(double[] array1,
double[] array2,
int size)
Returns whether the elements of the two given arrays are the same.
|
static boolean |
equal(float[] array1,
float[] array2,
int size)
Returns whether the elements of the two given arrays are the same.
|
static boolean |
equal(int[] array1,
int[] array2,
int size)
Returns whether the elements of the two given arrays are the same.
|
static boolean |
equal(long[] array1,
long[] array2,
int size)
Returns whether the elements of the two given arrays are the same.
|
static boolean |
equal(java.lang.Object[] array1,
java.lang.Object[] array2,
int size)
Returns whether the elements of the two given arrays are the same.
|
static boolean |
equal(short[] array1,
short[] array2,
int size)
Returns whether the elements of the two given arrays are the same.
|
static boolean |
equalOrNull(java.lang.Object[] array1,
java.lang.Object[] array2)
Returns whether the elements of the two given arrays are the same, or both arrays are null.
|
static boolean |
equalOrNull(java.lang.Object[] array1,
java.lang.Object[] array2,
int size)
Returns whether the elements of the two given arrays are the same, or both arrays are null.
|
static boolean[] |
extendArray(boolean[] array,
int size)
Ensures the given array has a given size.
|
static byte[] |
extendArray(byte[] array,
int size)
Ensures the given array has a given size.
|
static char[] |
extendArray(char[] array,
int size)
Ensures the given array has a given size.
|
static double[] |
extendArray(double[] array,
int size)
Ensures the given array has a given size.
|
static float[] |
extendArray(float[] array,
int size)
Ensures the given array has a given size.
|
static int[] |
extendArray(int[] array,
int size)
Ensures the given array has a given size.
|
static long[] |
extendArray(long[] array,
int size)
Ensures the given array has a given size.
|
static short[] |
extendArray(short[] array,
int size)
Ensures the given array has a given size.
|
static <T> T[] |
extendArray(T[] array,
int size)
Ensures the given array has a given size.
|
static int |
hashCode(boolean[] array,
int size)
Returns a hash code for the elements of the given array.
|
static int |
hashCode(byte[] array,
int size)
Returns a hash code for the elements of the given array.
|
static int |
hashCode(char[] array,
int size)
Returns a hash code for the elements of the given array.
|
static int |
hashCode(double[] array,
int size)
Returns a hash code for the elements of the given array.
|
static int |
hashCode(float[] array,
int size)
Returns a hash code for the elements of the given array.
|
static int |
hashCode(int[] array,
int size)
Returns a hash code for the elements of the given array.
|
static int |
hashCode(long[] array,
int size)
Returns a hash code for the elements of the given array.
|
static int |
hashCode(java.lang.Object[] array,
int size)
Returns a hash code for the elements of the given array.
|
static int |
hashCode(short[] array,
int size)
Returns a hash code for the elements of the given array.
|
static int |
hashCodeOrNull(java.lang.Object[] array)
Returns a hash code for the elements of the given array, or 0 if it is null.
|
static int |
hashCodeOrNull(java.lang.Object[] array,
int size)
Returns a hash code for the elements of the given array, or 0 if it is null.
|
static int |
indexOf(boolean[] array,
int size,
boolean value)
Returns the index of the given value in the given array.
|
static int |
indexOf(byte[] array,
int size,
byte value)
Returns the index of the given value in the given array.
|
static int |
indexOf(char[] array,
int size,
char value)
Returns the index of the given value in the given array.
|
static int |
indexOf(double[] array,
int size,
double value)
Returns the index of the given value in the given array.
|
static int |
indexOf(float[] array,
int size,
float value)
Returns the index of the given value in the given array.
|
static int |
indexOf(int[] array,
int size,
int value)
Returns the index of the given value in the given array.
|
static int |
indexOf(long[] array,
int size,
long value)
Returns the index of the given value in the given array.
|
static int |
indexOf(java.lang.Object[] array,
int size,
java.lang.Object value)
Returns the index of the given value in the given array.
|
static int |
indexOf(short[] array,
int size,
short value)
Returns the index of the given value in the given array.
|
static byte[] |
insert(byte[] array,
int size,
int index,
byte element)
Inserts the given element in the given array.
|
static char[] |
insert(char[] array,
int size,
int index,
char element)
Inserts the given element in the given array.
|
static double[] |
insert(double[] array,
int size,
int index,
double element)
Inserts the given element in the given array.
|
static float[] |
insert(float[] array,
int size,
int index,
float element)
Inserts the given element in the given array.
|
static int[] |
insert(int[] array,
int size,
int index,
int element)
Inserts the given element in the given array.
|
static long[] |
insert(long[] array,
int size,
int index,
long element)
Inserts the given element in the given array.
|
static short[] |
insert(short[] array,
int size,
int index,
short element)
Inserts the given element in the given array.
|
static <T> T[] |
insert(T[] array,
int size,
int index,
T element)
Inserts the given element in the given array.
|
static void |
remove(byte[] array,
int size,
int index)
Removes the specified element from the given array.
|
static void |
remove(char[] array,
int size,
int index)
Removes the specified element from the given array.
|
static void |
remove(double[] array,
int size,
int index)
Removes the specified element from the given array.
|
static void |
remove(float[] array,
int size,
int index)
Removes the specified element from the given array.
|
static void |
remove(int[] array,
int size,
int index)
Removes the specified element from the given array.
|
static void |
remove(long[] array,
int size,
int index)
Removes the specified element from the given array.
|
static void |
remove(java.lang.Object[] array,
int size,
int index)
Removes the specified element from the given array.
|
static void |
remove(short[] array,
int size,
int index)
Removes the specified element from the given array.
|
public static int indexOf(boolean[] array, int size, boolean value)
array
- the array.size
- the size of the array to be checked.value
- the value to look for.public static int indexOf(byte[] array, int size, byte value)
array
- the array.size
- the size of the array to be checked.value
- the value to look for.public static int indexOf(char[] array, int size, char value)
array
- the array.size
- the size of the array to be checked.value
- the value to look for.public static int indexOf(short[] array, int size, short value)
array
- the array.size
- the size of the array to be checked.value
- the value to look for.public static int indexOf(int[] array, int size, int value)
array
- the array.size
- the size of the array to be checked.value
- the value to look for.public static int indexOf(long[] array, int size, long value)
array
- the array.size
- the size of the array to be checked.value
- the value to look for.public static int indexOf(float[] array, int size, float value)
array
- the array.size
- the size of the array to be checked.value
- the value to look for.public static int indexOf(double[] array, int size, double value)
array
- the array.size
- the size of the array to be checked.value
- the value to look for.public static int indexOf(java.lang.Object[] array, int size, java.lang.Object value)
array
- the array.size
- the size of the array to be checked.value
- the value to look for.public static boolean equal(boolean[] array1, boolean[] array2, int size)
array1
- the first array.array2
- the second array.size
- the size of the arrays to be checked.public static boolean equal(byte[] array1, byte[] array2, int size)
array1
- the first array.array2
- the second array.size
- the size of the arrays to be checked.public static boolean equal(char[] array1, char[] array2, int size)
array1
- the first array.array2
- the second array.size
- the size of the arrays to be checked.public static boolean equal(short[] array1, short[] array2, int size)
array1
- the first array.array2
- the second array.size
- the size of the arrays to be checked.public static boolean equal(int[] array1, int[] array2, int size)
array1
- the first array.array2
- the second array.size
- the size of the arrays to be checked.public static boolean equal(long[] array1, long[] array2, int size)
array1
- the first array.array2
- the second array.size
- the size of the arrays to be checked.public static boolean equal(float[] array1, float[] array2, int size)
array1
- the first array.array2
- the second array.size
- the size of the arrays to be checked.public static boolean equal(double[] array1, double[] array2, int size)
array1
- the first array.array2
- the second array.size
- the size of the arrays to be checked.public static boolean equal(java.lang.Object[] array1, java.lang.Object[] array2, int size)
array1
- the first array.array2
- the second array.size
- the size of the arrays to be checked.public static boolean equalOrNull(java.lang.Object[] array1, java.lang.Object[] array2)
array1
- the first array.array2
- the second array.public static boolean equalOrNull(java.lang.Object[] array1, java.lang.Object[] array2, int size)
array1
- the first array.array2
- the second array.size
- the size of the arrays to be checked.public static int hashCode(boolean[] array, int size)
array
- the array.size
- the size of the array to be taken into account.public static int hashCode(byte[] array, int size)
array
- the array.size
- the size of the array to be taken into account.public static int hashCode(char[] array, int size)
array
- the array.size
- the size of the array to be taken into account.public static int hashCode(short[] array, int size)
array
- the array.size
- the size of the array to be taken into account.public static int hashCode(int[] array, int size)
array
- the array.size
- the size of the array to be taken into account.public static int hashCode(long[] array, int size)
array
- the array.size
- the size of the array to be taken into account.public static int hashCode(float[] array, int size)
array
- the array.size
- the size of the array to be taken into account.public static int hashCode(double[] array, int size)
array
- the array.size
- the size of the array to be taken into account.public static int hashCode(java.lang.Object[] array, int size)
array
- the array.size
- the size of the array to be taken into account.public static int hashCodeOrNull(java.lang.Object[] array)
array
- the array.public static int hashCodeOrNull(java.lang.Object[] array, int size)
array
- the array.size
- the size of the array to be taken into account.public static int compare(boolean[] array1, int size1, boolean[] array2, int size2)
array1
- the first array.size1
- the size of the first array.array2
- the second array.size2
- the size of the second array.public static int compare(byte[] array1, int size1, byte[] array2, int size2)
array1
- the first array.size1
- the size of the first array.array2
- the second array.size2
- the size of the second array.public static int compare(char[] array1, int size1, char[] array2, int size2)
array1
- the first array.size1
- the size of the first array.array2
- the second array.size2
- the size of the second array.public static int compare(short[] array1, int size1, short[] array2, int size2)
array1
- the first array.size1
- the size of the first array.array2
- the second array.size2
- the size of the second array.public static int compare(int[] array1, int size1, int[] array2, int size2)
array1
- the first array.size1
- the size of the first array.array2
- the second array.size2
- the size of the second array.public static int compare(long[] array1, int size1, long[] array2, int size2)
array1
- the first array.size1
- the size of the first array.array2
- the second array.size2
- the size of the second array.public static int compare(float[] array1, int size1, float[] array2, int size2)
array1
- the first array.size1
- the size of the first array.array2
- the second array.size2
- the size of the second array.public static int compare(double[] array1, int size1, double[] array2, int size2)
array1
- the first array.size1
- the size of the first array.array2
- the second array.size2
- the size of the second array.public static int compare(java.lang.Comparable[] array1, int size1, java.lang.Comparable[] array2, int size2)
array1
- the first array.size1
- the size of the first array.array2
- the second array.size2
- the size of the second array.public static <T> T[] cloneOrNull(T[] array)
array
- the array.public static boolean[] extendArray(boolean[] array, int size)
array
- the array.size
- the target size of the array.public static boolean[] ensureArraySize(boolean[] array, int size, boolean initialValue)
array
- the array.size
- the target size of the array.initialValue
- the initial value of the elements.public static byte[] add(byte[] array, int size, byte element)
array
- the array.size
- the original size of the array.element
- the element to be added.public static byte[] insert(byte[] array, int size, int index, byte element)
array
- the array.size
- the original size of the array.index
- the index at which the element is to be added.element
- the element to be added.public static void remove(byte[] array, int size, int index)
array
- the array.size
- the original size of the array.index
- the index of the element to be removed.public static byte[] extendArray(byte[] array, int size)
array
- the array.size
- the target size of the array.public static byte[] ensureArraySize(byte[] array, int size, byte initialValue)
array
- the array.size
- the target size of the array.initialValue
- the initial value of the elements.public static char[] add(char[] array, int size, char element)
array
- the array.size
- the original size of the array.element
- the element to be added.public static char[] insert(char[] array, int size, int index, char element)
array
- the array.size
- the original size of the array.index
- the index at which the element is to be added.element
- the element to be added.public static void remove(char[] array, int size, int index)
array
- the array.size
- the original size of the array.index
- the index of the element to be removed.public static char[] extendArray(char[] array, int size)
array
- the array.size
- the target size of the array.public static char[] ensureArraySize(char[] array, int size, char initialValue)
array
- the array.size
- the target size of the array.initialValue
- the initial value of the elements.public static short[] add(short[] array, int size, short element)
array
- the array.size
- the original size of the array.element
- the element to be added.public static short[] insert(short[] array, int size, int index, short element)
array
- the array.size
- the original size of the array.index
- the index at which the element is to be added.element
- the element to be added.public static void remove(short[] array, int size, int index)
array
- the array.size
- the original size of the array.index
- the index of the element to be removed.public static short[] extendArray(short[] array, int size)
array
- the array.size
- the target size of the array.public static short[] ensureArraySize(short[] array, int size, short initialValue)
array
- the array.size
- the target size of the array.initialValue
- the initial value of the elements.public static int[] add(int[] array, int size, int element)
array
- the array.size
- the original size of the array.element
- the element to be added.public static int[] insert(int[] array, int size, int index, int element)
array
- the array.size
- the original size of the array.index
- the index at which the element is to be added.element
- the element to be added.public static void remove(int[] array, int size, int index)
array
- the array.size
- the original size of the array.index
- the index of the element to be removed.public static int[] extendArray(int[] array, int size)
array
- the array.size
- the target size of the array.public static int[] ensureArraySize(int[] array, int size, int initialValue)
array
- the array.size
- the target size of the array.initialValue
- the initial value of the elements.public static long[] add(long[] array, int size, long element)
array
- the array.size
- the original size of the array.element
- the element to be added.public static long[] insert(long[] array, int size, int index, long element)
array
- the array.size
- the original size of the array.index
- the index at which the element is to be added.element
- the element to be added.public static void remove(long[] array, int size, int index)
array
- the array.size
- the original size of the array.index
- the index of the element to be removed.public static long[] extendArray(long[] array, int size)
array
- the array.size
- the target size of the array.public static long[] ensureArraySize(long[] array, int size, long initialValue)
array
- the array.size
- the target size of the array.initialValue
- the initial value of the elements.public static float[] add(float[] array, int size, float element)
array
- the array.size
- the original size of the array.element
- the element to be added.public static float[] insert(float[] array, int size, int index, float element)
array
- the array.size
- the original size of the array.index
- the index at which the element is to be added.element
- the element to be added.public static void remove(float[] array, int size, int index)
array
- the array.size
- the original size of the array.index
- the index of the element to be removed.public static float[] extendArray(float[] array, int size)
array
- the array.size
- the target size of the array.public static float[] ensureArraySize(float[] array, int size, float initialValue)
array
- the array.size
- the target size of the array.initialValue
- the initial value of the elements.public static double[] add(double[] array, int size, double element)
array
- the array.size
- the original size of the array.element
- the element to be added.public static double[] insert(double[] array, int size, int index, double element)
array
- the array.size
- the original size of the array.index
- the index at which the element is to be added.element
- the element to be added.public static void remove(double[] array, int size, int index)
array
- the array.size
- the original size of the array.index
- the index of the element to be removed.public static double[] extendArray(double[] array, int size)
array
- the array.size
- the target size of the array.public static double[] ensureArraySize(double[] array, int size, double initialValue)
array
- the array.size
- the target size of the array.initialValue
- the initial value of the elements.public static <T> T[] add(T[] array, int size, T element)
array
- the array.size
- the original size of the array.element
- the element to be added.public static <T> T[] insert(T[] array, int size, int index, T element)
array
- the array.size
- the original size of the array.index
- the index at which the element is to be added.element
- the element to be added.public static void remove(java.lang.Object[] array, int size, int index)
array
- the array.size
- the original size of the array.index
- the index of the element to be removed.public static <T> T[] extendArray(T[] array, int size)
array
- the array.size
- the target size of the array.public static <T> T[] ensureArraySize(T[] array, int size, T initialValue)
array
- the array.size
- the target size of the array.initialValue
- the initial value of the elements.public static <T> T[] concat(T[] first, T[] second)