类 ArrayUtils

java.lang.Object
org.beetl.core.util.ArrayUtils

public class ArrayUtils extends Object
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>
    add(@Nullable ArrayList<T> cur, T val)
     
    static <T> @NotNull ArraySet<T>
    add(@Nullable ArraySet<T> cur, T val)
     
    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 boolean
    contains(@org.jetbrains.annotations.Nullable char[] array, char value)
     
    static boolean
    contains(@org.jetbrains.annotations.Nullable int[] array, int value)
     
    static boolean
    contains(@org.jetbrains.annotations.Nullable long[] array, long value)
     
    static <T> boolean
    contains(@Nullable Collection<T> cur, T val)
     
    static <T> boolean
    contains(@Nullable T[] array, T value)
    Checks that value is present as at least one of the elements of the array.
    static <T> boolean
    containsAll(@org.jetbrains.annotations.Nullable char[] array, char[] check)
    Test if all check items are contained in array.
    static <T> boolean
    containsAll(@Nullable T[] array, T[] check)
    Test if all check items are contained in array.
    static <T> boolean
    containsAny(@Nullable T[] array, T[] check)
    Test if any check items are contained in array.
    static int[]
     
    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 boolean
    equals(byte[] array1, byte[] array2, int length)
    Checks if the beginnings of two byte arrays are equal.
    static <T> int
    indexOf(@Nullable T[] array, T value)
    Return first index of value in array, or -1 if not found.
    static boolean
    isEmpty(@org.jetbrains.annotations.Nullable boolean[] array)
    Checks if given array is null or has zero elements.
    static boolean
    isEmpty(@org.jetbrains.annotations.Nullable byte[] array)
    Checks if given array is null or has zero elements.
    static boolean
    isEmpty(@org.jetbrains.annotations.Nullable int[] array)
    Checks if given array is null or has zero elements.
    static boolean
    isEmpty(@org.jetbrains.annotations.Nullable long[] 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 Map<?,?> map)
    Checks if given map is null or has zero elements.
    static <T> boolean
    isEmpty(@Nullable T[] array)
    Checks if given array is null or has zero elements.
    static <T> T[]
    newUnpaddedArray(Class<T> clazz, int minLen)
     
    static boolean[]
     
    static byte[]
     
    static char[]
     
    static float[]
     
    static int[]
    newUnpaddedIntArray(int minLen)
     
    static long[]
     
    static Object[]
     
    static <T> boolean
    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> @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 int
    size(@Nullable Object[] array)
    Length of the given array or 0 if it's null.
    static int
    size(@Nullable Collection<?> collection)
    Length of the given collection or 0 if it's null.
    static long
    total(@org.jetbrains.annotations.Nullable long[] array)
     
    static <T> @Nullable T[]
    trimToSize(@Nullable 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.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 方法详细资料

    • 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

      public static Object[] newUnpaddedObjectArray(int minLen)
    • newUnpaddedArray

      public static <T> T[] newUnpaddedArray(Class<T> clazz, int minLen)
    • 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 array
      array2 - the second byte array
      length - the number of bytes to check
      返回:
      true if they're equal, false otherwise
    • emptyArray

      public static <T> T[] emptyArray(Class<T> kind)
      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

      public static boolean isEmpty(@Nullable @Nullable Collection<?> array)
      Checks if given array is null or has zero elements.
    • isEmpty

      public static boolean isEmpty(@Nullable @Nullable Map<?,?> map)
      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

      public static int size(@Nullable @Nullable Object[] array)
      Length of the given array or 0 if it's null.
    • size

      public static int size(@Nullable @Nullable Collection<?> collection)
      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 in
      value - 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 of value in array, or -1 if not found.
    • containsAll

      public static <T> boolean containsAll(@Nullable @Nullable T[] array, T[] check)
      Test if all check items are contained in array.
    • containsAny

      public static <T> boolean containsAny(@Nullable @Nullable T[] array, T[] check)
      Test if any check items are contained in array.
    • 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 all check items are contained in array.
    • total

      public static long total(@Nullable @org.jetbrains.annotations.Nullable long[] array)
    • convertToIntArray

      public static int[] convertToIntArray(List<Integer> list)
    • 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

      @Nullable public static <T> @Nullable ArraySet<T> cloneOrNull(@Nullable @Nullable ArraySet<T> array)
    • add

      @NotNull public static <T> @NotNull ArraySet<T> add(@Nullable @Nullable ArraySet<T> cur, T val)
    • remove

      @Nullable public static <T> @Nullable ArraySet<T> remove(@Nullable @Nullable ArraySet<T> cur, T val)
    • add

      @NotNull public static <T> @NotNull ArrayList<T> add(@Nullable @Nullable ArrayList<T> cur, T val)
    • remove

      @Nullable public static <T> @Nullable ArrayList<T> remove(@Nullable @Nullable ArrayList<T> cur, T val)
    • contains

      public static <T> boolean contains(@Nullable @Nullable Collection<T> cur, T val)
    • trimToSize

      @Nullable public static <T> @Nullable T[] trimToSize(@Nullable @Nullable T[] array, int size)
    • referenceEquals

      public 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. 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

      @NotNull public static @NotNull String[] defeatNullable(@Nullable @Nullable String[] val)