类 ArrayUtils
java.lang.Object
org.beetl.core.util.ArrayUtils
ArrayUtils contains some methods that you can call to find out
the most efficient increments by which to grow arrays.
-
方法概要
修饰符和类型方法说明static <T> @NotNull ArrayList<T>static <T> @NotNull ArraySet<T>static <T> @NotNull T[]appendElement(Class<T> kind, @Nullable T[] array, T element) Adds value to given array if not already present, providing set-like behavior.static <T> @NotNull T[]appendElement(Class<T> kind, @Nullable T[] array, T element, boolean allowDuplicates) Adds value to given array.static @org.jetbrains.annotations.NotNull int[]appendInt(@org.jetbrains.annotations.Nullable int[] cur, int val) Adds value to given array if not already present, providing set-like behavior.static @org.jetbrains.annotations.NotNull int[]appendInt(@org.jetbrains.annotations.Nullable int[] cur, int val, boolean allowDuplicates) Adds value to given array.static @org.jetbrains.annotations.NotNull long[]appendLong(@org.jetbrains.annotations.Nullable long[] cur, long val) Adds value to given array if not already present, providing set-like behavior.static @org.jetbrains.annotations.NotNull long[]appendLong(@org.jetbrains.annotations.Nullable long[] cur, long val, boolean allowDuplicates) Adds value to given array if not already present, providing set-like behavior.static @org.jetbrains.annotations.Nullable long[]cloneOrNull(@org.jetbrains.annotations.Nullable long[] array) static <T> @Nullable ArraySet<T>cloneOrNull(@Nullable ArraySet<T> array) static booleancontains(@org.jetbrains.annotations.Nullable char[] array, char value) static booleancontains(@org.jetbrains.annotations.Nullable int[] array, int value) static booleancontains(@org.jetbrains.annotations.Nullable long[] array, long value) static <T> booleancontains(@Nullable Collection<T> cur, T val) static <T> booleancontains(@Nullable T[] array, T value) Checks that value is present as at least one of the elements of the array.static <T> booleancontainsAll(@org.jetbrains.annotations.Nullable char[] array, char[] check) Test if allcheckitems are contained inarray.static <T> booleancontainsAll(@Nullable T[] array, T[] check) Test if allcheckitems are contained inarray.static <T> booleancontainsAny(@Nullable T[] array, T[] check) Test if anycheckitems are contained inarray.static int[]convertToIntArray(List<Integer> list) static @org.jetbrains.annotations.Nullable long[]convertToLongArray(@org.jetbrains.annotations.Nullable int[] intArray) static @org.jetbrains.annotations.NotNull int[]defeatNullable(@org.jetbrains.annotations.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 booleanequals(byte[] array1, byte[] array2, int length) Checks if the beginnings of two byte arrays are equal.static <T> intindexOf(@Nullable T[] array, T value) Return first index ofvalueinarray, or-1if not found.static booleanisEmpty(@org.jetbrains.annotations.Nullable boolean[] array) Checks if given array is null or has zero elements.static booleanisEmpty(@org.jetbrains.annotations.Nullable byte[] array) Checks if given array is null or has zero elements.static booleanisEmpty(@org.jetbrains.annotations.Nullable int[] array) Checks if given array is null or has zero elements.static booleanisEmpty(@org.jetbrains.annotations.Nullable long[] array) Checks if given array is null or has zero elements.static booleanisEmpty(@Nullable Collection<?> array) Checks if given array is null or has zero elements.static booleanChecks if given map is null or has zero elements.static <T> booleanisEmpty(@Nullable 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> booleanreferenceEquals(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>static <T> @Nullable ArraySet<T>static <T> @Nullable T[]removeElement(Class<T> kind, @Nullable T[] array, T element) Removes value from given array if present, providing set-like behavior.static @org.jetbrains.annotations.Nullable int[]removeInt(@org.jetbrains.annotations.Nullable int[] cur, int val) Removes value from given array if present, providing set-like behavior.static @org.jetbrains.annotations.Nullable long[]removeLong(@org.jetbrains.annotations.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 intLength of the given array or 0 if it's null.static intsize(@Nullable Collection<?> collection) Length of the given collection or 0 if it's null.static longtotal(@org.jetbrains.annotations.Nullable long[] array) static <T> @Nullable T[]trimToSize(@Nullable T[] array, int size) static <T> intunstableRemoveIf(@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.
-
方法详细资料
-
newUnpaddedByteArray
public static byte[] newUnpaddedByteArray(int minLen) -
newUnpaddedCharArray
public static char[] newUnpaddedCharArray(int minLen) -
newUnpaddedIntArray
public static int[] newUnpaddedIntArray(int minLen) -
newUnpaddedBooleanArray
public static boolean[] newUnpaddedBooleanArray(int minLen) -
newUnpaddedLongArray
public static long[] newUnpaddedLongArray(int minLen) -
newUnpaddedFloatArray
public static float[] newUnpaddedFloatArray(int minLen) -
newUnpaddedObjectArray
-
newUnpaddedArray
-
equals
public static boolean equals(byte[] array1, byte[] array2, int length) Checks if the beginnings of two byte arrays are equal.- 参数:
array1- the first byte arrayarray2- the second byte arraylength- the number of bytes to check- 返回:
- true if they're equal, false otherwise
-
emptyArray
Returns an empty array of the specified type. The intent is that it will return the same empty array every time to avoid reallocation, although this is not guaranteed. -
isEmpty
Checks if given array is null or has zero elements. -
isEmpty
Checks if given map is null or has zero elements. -
isEmpty
public static <T> boolean isEmpty(@Nullable @Nullable T[] array) Checks if given array is null or has zero elements. -
isEmpty
public static boolean isEmpty(@Nullable @org.jetbrains.annotations.Nullable int[] array) Checks if given array is null or has zero elements. -
isEmpty
public static boolean isEmpty(@Nullable @org.jetbrains.annotations.Nullable long[] array) Checks if given array is null or has zero elements. -
isEmpty
public static boolean isEmpty(@Nullable @org.jetbrains.annotations.Nullable byte[] array) Checks if given array is null or has zero elements. -
isEmpty
public static boolean isEmpty(@Nullable @org.jetbrains.annotations.Nullable boolean[] array) Checks if given array is null or has zero elements. -
size
Length of the given array or 0 if it's null. -
size
Length of the given collection or 0 if it's null. -
contains
public static <T> boolean contains(@Nullable @Nullable T[] array, T value) Checks that value is present as at least one of the elements of the array.- 参数:
array- the array to check invalue- the value to check for- 返回:
- true if the value is present in the array
-
indexOf
public static <T> int indexOf(@Nullable @Nullable T[] array, T value) Return first index ofvalueinarray, or-1if not found. -
containsAll
public static <T> boolean containsAll(@Nullable @Nullable T[] array, T[] check) Test if allcheckitems are contained inarray. -
containsAny
public static <T> boolean containsAny(@Nullable @Nullable T[] array, T[] check) Test if anycheckitems are contained inarray. -
contains
public static boolean contains(@Nullable @org.jetbrains.annotations.Nullable int[] array, int value) -
contains
public static boolean contains(@Nullable @org.jetbrains.annotations.Nullable long[] array, long value) -
contains
public static boolean contains(@Nullable @org.jetbrains.annotations.Nullable char[] array, char value) -
containsAll
public static <T> boolean containsAll(@Nullable @org.jetbrains.annotations.Nullable char[] array, char[] check) Test if allcheckitems are contained inarray. -
total
public static long total(@Nullable @org.jetbrains.annotations.Nullable long[] array) -
convertToIntArray
-
convertToLongArray
@Nullable public static @org.jetbrains.annotations.Nullable long[] convertToLongArray(@Nullable @org.jetbrains.annotations.Nullable int[] intArray) -
appendElement
@NotNull public static <T> @NotNull T[] appendElement(Class<T> kind, @Nullable @Nullable T[] array, T element) Adds value to given array if not already present, providing set-like behavior. -
appendElement
@NotNull public static <T> @NotNull T[] appendElement(Class<T> kind, @Nullable @Nullable T[] array, T element, boolean allowDuplicates) Adds value to given array. -
removeElement
@Nullable public static <T> @Nullable T[] removeElement(Class<T> kind, @Nullable @Nullable T[] array, T element) Removes value from given array if present, providing set-like behavior. -
appendInt
@NotNull public static @org.jetbrains.annotations.NotNull int[] appendInt(@Nullable @org.jetbrains.annotations.Nullable int[] cur, int val, boolean allowDuplicates) Adds value to given array. -
appendInt
@NotNull public static @org.jetbrains.annotations.NotNull int[] appendInt(@Nullable @org.jetbrains.annotations.Nullable int[] cur, int val) Adds value to given array if not already present, providing set-like behavior. -
removeInt
@Nullable public static @org.jetbrains.annotations.Nullable int[] removeInt(@Nullable @org.jetbrains.annotations.Nullable int[] cur, int val) Removes value from given array if present, providing set-like behavior. -
removeString
@Nullable public static @Nullable String[] removeString(@Nullable @Nullable String[] cur, String val) Removes value from given array if present, providing set-like behavior. -
appendLong
@NotNull public static @org.jetbrains.annotations.NotNull long[] appendLong(@Nullable @org.jetbrains.annotations.Nullable long[] cur, long val, boolean allowDuplicates) Adds value to given array if not already present, providing set-like behavior. -
appendLong
@NotNull public static @org.jetbrains.annotations.NotNull long[] appendLong(@Nullable @org.jetbrains.annotations.Nullable long[] cur, long val) Adds value to given array if not already present, providing set-like behavior. -
removeLong
@Nullable public static @org.jetbrains.annotations.Nullable long[] removeLong(@Nullable @org.jetbrains.annotations.Nullable long[] cur, long val) Removes value from given array if present, providing set-like behavior. -
cloneOrNull
@Nullable public static @org.jetbrains.annotations.Nullable long[] cloneOrNull(@Nullable @org.jetbrains.annotations.Nullable long[] array) -
cloneOrNull
-
add
-
remove
-
add
-
remove
-
contains
-
trimToSize
@Nullable public static <T> @Nullable T[] trimToSize(@Nullable @Nullable T[] array, int size) -
referenceEquals
Returns true if the two ArrayLists are equal with respect to the objects they contain. The objects must be in the same order and be reference equal (== not .equals()). -
unstableRemoveIf
public static <T> int unstableRemoveIf(@Nullable @Nullable ArrayList<T> collection, @NotNull Predicate<T> predicate) Removes elements that match the predicate in an efficient way that alters the order of elements in the collection. This should only be used if order is not important.- 参数:
collection- The ArrayList from which to remove elements.predicate- The predicate that each element is tested against.- 返回:
- the number of elements removed.
-
defeatNullable
@NotNull public static @org.jetbrains.annotations.NotNull int[] defeatNullable(@Nullable @org.jetbrains.annotations.Nullable int[] val) -
defeatNullable
-