public class ArrayUtils extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> @NotNull ArrayList<T> |
add(@Nullable ArrayList<T> cur,
T val) |
static <T> @NotNull ArraySet<T> |
add(@Nullable 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 <T> T[] |
appendElement(Class<T> kind,
T[] array,
T element,
boolean allowDuplicates)
Adds value to given array.
|
static @NotNull int[] |
appendInt(@Nullable int[] cur,
int val)
Adds value to given array if not already present, providing set-like
behavior.
|
static @NotNull int[] |
appendInt(@Nullable int[] cur,
int val,
boolean allowDuplicates)
Adds value to given array.
|
static @NotNull long[] |
appendLong(@Nullable long[] cur,
long val)
Adds value to given array if not already present, providing set-like
behavior.
|
static @NotNull long[] |
appendLong(@Nullable long[] cur,
long val,
boolean allowDuplicates)
Adds value to given array if not already present, providing set-like
behavior.
|
static <T> @Nullable ArraySet<T> |
cloneOrNull(@Nullable ArraySet<T> array) |
static @Nullable long[] |
cloneOrNull(@Nullable long[] array) |
static boolean |
contains(@Nullable char[] array,
char value) |
static <T> boolean |
contains(@Nullable Collection<T> cur,
T val) |
static boolean |
contains(@Nullable int[] array,
int value) |
static boolean |
contains(@Nullable 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(@Nullable char[] array,
char[] check)
Test if all
check items are contained in 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 @Nullable long[] |
convertToLongArray(@Nullable int[] intArray) |
static @NotNull int[] |
defeatNullable(@Nullable int[] val) |
static @NotNull String[] |
defeatNullable(@Nullable String[] val) |
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(@Nullable boolean[] array)
Checks if given array is null or has zero elements.
|
static boolean |
isEmpty(@Nullable byte[] array)
Checks if given array is null or has zero elements.
|
static boolean |
isEmpty(@Nullable Collection<?> array)
Checks if given array is null or has zero elements.
|
static boolean |
isEmpty(@Nullable int[] array)
Checks if given array is null or has zero elements.
|
static boolean |
isEmpty(@Nullable long[] array)
Checks if given array is null or has zero elements.
|
static boolean |
isEmpty(@Nullable Map<?,?> map)
Checks if given map 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> @Nullable ArrayList<T> |
remove(@Nullable ArrayList<T> cur,
T val) |
static <T> @Nullable ArraySet<T> |
remove(@Nullable 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 @Nullable int[] |
removeInt(@Nullable int[] cur,
int val)
Removes value from given array if present, providing set-like behavior.
|
static @Nullable long[] |
removeLong(@Nullable long[] cur,
long val)
Removes value from given array if present, providing set-like behavior.
|
static @Nullable String[] |
removeString(@Nullable String[] cur,
String val)
Removes value from given array if present, providing set-like behavior.
|
static int |
size(@Nullable Collection<?> collection)
Length of the given collection or 0 if it's null.
|
static int |
size(@Nullable Object[] array)
Length of the given array or 0 if it's null.
|
static long |
total(@Nullable long[] array) |
static <T> T[] |
trimToSize(T[] array,
int size) |
static <T> int |
unstableRemoveIf(@Nullable 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(@Nullable
@Nullable Collection<?> array)
public static boolean isEmpty(@Nullable
@Nullable Map<?,?> map)
public static <T> boolean isEmpty(@Nullable
T[] array)
public static boolean isEmpty(@Nullable
@Nullable int[] array)
public static boolean isEmpty(@Nullable
@Nullable long[] array)
public static boolean isEmpty(@Nullable
@Nullable byte[] array)
public static boolean isEmpty(@Nullable
@Nullable boolean[] array)
public static int size(@Nullable
@Nullable Object[] array)
public static int size(@Nullable
@Nullable Collection<?> collection)
public static <T> boolean contains(@Nullable
T[] array,
T value)
array - the array to check invalue - the value to check forpublic static <T> int indexOf(@Nullable
T[] array,
T value)
value in array, or -1 if
not found.public static <T> boolean containsAll(@Nullable
T[] array,
T[] check)
check items are contained in array.public static <T> boolean containsAny(@Nullable
T[] array,
T[] check)
check items are contained in array.public static boolean contains(@Nullable
@Nullable int[] array,
int value)
public static boolean contains(@Nullable
@Nullable long[] array,
long value)
public static boolean contains(@Nullable
@Nullable char[] array,
char value)
public static <T> boolean containsAll(@Nullable
@Nullable char[] array,
char[] check)
check items are contained in array.public static long total(@Nullable
@Nullable long[] array)
@Nullable
public static @Nullable long[] convertToLongArray(@Nullable
@Nullable int[] intArray)
@NotNull public static <T> T[] appendElement(Class<T> kind, @Nullable T[] array, T element)
@NotNull public static <T> T[] appendElement(Class<T> kind, @Nullable T[] array, T element, boolean allowDuplicates)
@Nullable public static <T> T[] removeElement(Class<T> kind, @Nullable T[] array, T element)
@NotNull
public static @NotNull int[] appendInt(@Nullable
@Nullable int[] cur,
int val,
boolean allowDuplicates)
@NotNull
public static @NotNull int[] appendInt(@Nullable
@Nullable int[] cur,
int val)
@Nullable
public static @Nullable int[] removeInt(@Nullable
@Nullable int[] cur,
int val)
@Nullable public static @Nullable String[] removeString(@Nullable @Nullable String[] cur, String val)
@NotNull
public static @NotNull long[] appendLong(@Nullable
@Nullable long[] cur,
long val,
boolean allowDuplicates)
@NotNull
public static @NotNull long[] appendLong(@Nullable
@Nullable long[] cur,
long val)
@Nullable
public static @Nullable long[] removeLong(@Nullable
@Nullable long[] cur,
long val)
@Nullable
public static @Nullable long[] cloneOrNull(@Nullable
@Nullable long[] array)
@Nullable public static <T> @Nullable ArraySet<T> cloneOrNull(@Nullable @Nullable ArraySet<T> array)
@Nullable public static <T> @Nullable ArraySet<T> remove(@Nullable @Nullable ArraySet<T> cur, T val)
@NotNull public static <T> @NotNull ArrayList<T> add(@Nullable @Nullable ArrayList<T> cur, T val)
@Nullable public static <T> @Nullable ArrayList<T> remove(@Nullable @Nullable ArrayList<T> cur, T val)
public static <T> boolean contains(@Nullable
@Nullable Collection<T> cur,
T val)
@Nullable
public static <T> T[] trimToSize(@Nullable
T[] array,
int size)
public static <T> boolean referenceEquals(ArrayList<T> a, ArrayList<T> b)
public static <T> int unstableRemoveIf(@Nullable
@Nullable ArrayList<T> collection,
@NotNull
Predicate<T> predicate)
collection - The ArrayList from which to remove elements.predicate - The predicate that each element is tested against.@NotNull
public static @NotNull int[] defeatNullable(@Nullable
@Nullable int[] val)
Copyright © 2021. All rights reserved.