Package com.android.internal.util
Class ArrayUtils
- java.lang.Object
-
- com.android.internal.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.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> ArraySet<T>add(ArraySet<T> cur, T val)static <T> ArrayList<T>add(ArrayList<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 long[]cloneOrNull(long[] array)static booleancontains(int[] array, int value)static booleancontains(long[] array, long value)static <T> booleancontains(ArraySet<T> cur, T val)static <T> booleancontains(ArrayList<T> cur, T val)static <T> booleancontains(T[] array, T value)Checks that value is present as at least one of the elements of the array.static <T> booleancontainsAll(T[] array, T[] check)Test if allcheckitems are contained inarray.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(T[] array, T value)Return first index ofvalueinarray, or-1if not found.static booleanisEmpty(int[] array)Checks if given array is null or has zero elements.static booleanisEmpty(long[] array)Checks if given array is null or has zero elements.static <T> booleanisEmpty(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> ArraySet<T>remove(ArraySet<T> cur, T val)static <T> ArrayList<T>remove(ArrayList<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 longtotal(long[] array)
-
-
-
Method Detail
-
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.- Parameters:
array1- the first byte arrayarray2- the second byte arraylength- the number of bytes to check- Returns:
- 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 <T> boolean isEmpty(T[] array)
Checks if given array is null or has zero elements.
-
isEmpty
public static boolean isEmpty(int[] array)
Checks if given array is null or has zero elements.
-
isEmpty
public static boolean isEmpty(long[] array)
Checks if given array is null or has zero elements.
-
contains
public static <T> boolean contains(T[] array, T value)Checks that value is present as at least one of the elements of the array.- Parameters:
array- the array to check invalue- the value to check for- Returns:
- true if the value is present in the array
-
indexOf
public static <T> int indexOf(T[] array, T value)Return first index ofvalueinarray, or-1if not found.
-
containsAll
public static <T> boolean containsAll(T[] array, T[] check)Test if allcheckitems are contained inarray.
-
contains
public static boolean contains(int[] array, int value)
-
contains
public static boolean contains(long[] array, long value)
-
total
public static long total(long[] array)
-
appendElement
public static <T> T[] appendElement(Class<T> kind, T[] array, T element)
Adds value to given array if not already present, providing set-like behavior.
-
removeElement
public static <T> T[] removeElement(Class<T> kind, T[] array, T element)
Removes value from given array if present, providing set-like behavior.
-
appendInt
public static int[] appendInt(int[] cur, int val)Adds value to given array if not already present, providing set-like behavior.
-
removeInt
public static int[] removeInt(int[] cur, int val)Removes value from given array if present, providing set-like behavior.
-
removeString
public static String[] removeString(String[] cur, String val)
Removes value from given array if present, providing set-like behavior.
-
appendLong
public static long[] appendLong(long[] cur, long val)Adds value to given array if not already present, providing set-like behavior.
-
removeLong
public static long[] removeLong(long[] cur, long val)Removes value from given array if present, providing set-like behavior.
-
cloneOrNull
public static long[] cloneOrNull(long[] array)
-
contains
public static <T> boolean contains(ArraySet<T> cur, T val)
-
contains
public static <T> boolean contains(ArrayList<T> cur, T val)
-
-