public class ArrayUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T> ArrayList<T> |
add(ArrayList<T> cur,
T val) |
static <T> ArraySet<T> |
add(ArraySet<T> cur,
T val) |
static <T> T[] |
appendElement(Class<T> kind,
T[] array,
T element)
Adds value to given array if not already present, providing set-like
behavior.
|
static int[] |
appendInt(int[] cur,
int val)
Adds value to given array if not already present, providing set-like
behavior.
|
static long[] |
appendLong(long[] cur,
long val)
Adds value to given array if not already present, providing set-like
behavior.
|
static <T> ArraySet<T> |
cloneOrNull(ArraySet<T> array) |
static long[] |
cloneOrNull(long[] array) |
static <T> boolean |
contains(ArraySet<T> cur,
T val) |
static <T> boolean |
contains(Collection<T> cur,
T val) |
static boolean |
contains(int[] array,
int value) |
static boolean |
contains(long[] array,
long value) |
static <T> boolean |
contains(T[] array,
T value)
Checks that value is present as at least one of the elements of the array.
|
static <T> boolean |
containsAll(T[] array,
T[] check)
Test if all
check items are contained in array . |
static <T> boolean |
containsAny(T[] array,
T[] check)
Test if any
check items are contained in array . |
static int[] |
convertToIntArray(List<Integer> list) |
static <T> T[] |
emptyArray(Class<T> kind)
Returns an empty array of the specified type.
|
static boolean |
equals(byte[] array1,
byte[] array2,
int length)
Checks if the beginnings of two byte arrays are equal.
|
static <T> int |
indexOf(T[] array,
T value)
Return first index of
value in array , or -1 if
not found. |
static boolean |
isEmpty(boolean[] array)
Checks if given array is null or has zero elements.
|
static boolean |
isEmpty(byte[] array)
Checks if given array is null or has zero elements.
|
static boolean |
isEmpty(Collection<?> array)
Checks if given array is null or has zero elements.
|
static boolean |
isEmpty(int[] array)
Checks if given array is null or has zero elements.
|
static boolean |
isEmpty(long[] array)
Checks if given array is null or has zero elements.
|
static <T> boolean |
isEmpty(T[] array)
Checks if given array is null or has zero elements.
|
static <T> T[] |
newUnpaddedArray(Class<T> clazz,
int minLen) |
static boolean[] |
newUnpaddedBooleanArray(int minLen) |
static byte[] |
newUnpaddedByteArray(int minLen) |
static char[] |
newUnpaddedCharArray(int minLen) |
static float[] |
newUnpaddedFloatArray(int minLen) |
static int[] |
newUnpaddedIntArray(int minLen) |
static long[] |
newUnpaddedLongArray(int minLen) |
static Object[] |
newUnpaddedObjectArray(int minLen) |
static <T> boolean |
referenceEquals(ArrayList<T> a,
ArrayList<T> b)
Returns true if the two ArrayLists are equal with respect to the objects they contain.
|
static <T> ArrayList<T> |
remove(ArrayList<T> cur,
T val) |
static <T> ArraySet<T> |
remove(ArraySet<T> cur,
T val) |
static <T> T[] |
removeElement(Class<T> kind,
T[] array,
T element)
Removes value from given array if present, providing set-like behavior.
|
static int[] |
removeInt(int[] cur,
int val)
Removes value from given array if present, providing set-like behavior.
|
static long[] |
removeLong(long[] cur,
long val)
Removes value from given array if present, providing set-like behavior.
|
static String[] |
removeString(String[] cur,
String val)
Removes value from given array if present, providing set-like behavior.
|
static long |
total(long[] array) |
static <T> T[] |
trimToSize(T[] array,
int size) |
static <T> int |
unstableRemoveIf(ArrayList<T> collection,
Predicate<T> predicate)
Removes elements that match the predicate in an efficient way that alters the order of
elements in the collection.
|
public static byte[] newUnpaddedByteArray(int minLen)
public static char[] newUnpaddedCharArray(int minLen)
public static int[] newUnpaddedIntArray(int minLen)
public static boolean[] newUnpaddedBooleanArray(int minLen)
public static long[] newUnpaddedLongArray(int minLen)
public static float[] newUnpaddedFloatArray(int minLen)
public static Object[] newUnpaddedObjectArray(int minLen)
public static <T> T[] newUnpaddedArray(Class<T> clazz, int minLen)
public static boolean equals(byte[] array1, byte[] array2, int length)
array1
- the first byte arrayarray2
- the second byte arraylength
- the number of bytes to checkpublic static <T> T[] emptyArray(Class<T> kind)
public static boolean isEmpty(Collection<?> array)
public static <T> boolean isEmpty(T[] array)
public static boolean isEmpty(int[] array)
public static boolean isEmpty(long[] array)
public static boolean isEmpty(byte[] array)
public static boolean isEmpty(boolean[] array)
public static <T> boolean contains(T[] array, T value)
array
- the array to check invalue
- the value to check forpublic static <T> int indexOf(T[] array, T value)
value
in array
, or -1
if
not found.public static <T> boolean containsAll(T[] array, T[] check)
check
items are contained in array
.public static <T> boolean containsAny(T[] array, T[] check)
check
items are contained in array
.public static boolean contains(int[] array, int value)
public static boolean contains(long[] array, long value)
public static long total(long[] array)
public static <T> T[] appendElement(Class<T> kind, T[] array, T element)
public static <T> T[] removeElement(Class<T> kind, T[] array, T element)
public static int[] appendInt(int[] cur, int val)
public static int[] removeInt(int[] cur, int val)
public static String[] removeString(String[] cur, String val)
public static long[] appendLong(long[] cur, long val)
public static long[] removeLong(long[] cur, long val)
public static long[] cloneOrNull(long[] array)
public static <T> boolean contains(ArraySet<T> cur, T val)
public static <T> boolean contains(Collection<T> cur, T val)
public static <T> T[] trimToSize(T[] array, int size)
public static <T> boolean referenceEquals(ArrayList<T> a, ArrayList<T> b)
public static <T> int unstableRemoveIf(ArrayList<T> collection, Predicate<T> predicate)
collection
- The ArrayList from which to remove elements.predicate
- The predicate that each element is tested against.