Package com.intellij.util
Class ArrayUtil
java.lang.Object
com.intellij.util.ArrayUtilRt
com.intellij.util.ArrayUtil
Author: msk
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean[]static final byte[]static final char[]static final Class[]static final Collection[]static final File[]static final int[]static final long[]static final Object[]static final Runnable[]static final short[]static final String[]static final ArrayFactory<Object> static final ArrayFactory<String> -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean[]append(boolean[] array, boolean value) static byte[]append(byte[] array, byte value) static int[]append(int[] array, int value) static long[]append(long[] array, long value) static <T> T[]append(T[] src, T element) Appendselementto thesrcarray.static <T> T[]append(T[] src, T element, ArrayFactory<T> factory) static <T> T[]static longaverageAmongMedians(int[] time, int part) static longaverageAmongMedians(long[] time, int part) static booleanstatic <T> booleancontains(T o, T... objects) static <T> voidcopy(Collection<? extends T> src, T[] dst, int dstOffset) static <E> E[]ensureExactSize(int count, E[] sample) static <T> booleanstatic <T> booleanequals(T[] a1, T[] a2, Comparator<? super T> comparator) static intfind(int[] src, int obj) static <T> intfind(T[] src, T obj) static <T> TgetFirstElement(T[] array) static <T> TgetLastElement(T[] array) static intindexOf(int[] ints, int value) static intindexOf(long[] ints, long value) static intindexOf(short[] ints, short value) static intstatic intstatic <T> intstatic <T> intindexOf(List<T> objects, T object, Comparator<T> comparator) static <T> intstatic int[]insert(int[] array, int index, int value) static <T> T[]insert(T[] array, int index, T value) static <T> booleanisEmpty(T[] array) static <T> intlastIndexOf(int[] src, int obj) static <T> intlastIndexOf(List<T> src, T obj, Equality<? super T> comparator) static <T> intlastIndexOf(T[] src, T obj) static <T> intlastIndexOf(T[] src, T obj, Equality<? super T> comparator) static intlexicographicCompare(String[] obj1, String[] obj2) static <T> intlexicographicCompare(T[] obj1, T[] obj2) static <T> T[]mergeArrayAndCollection(T[] array, Collection<T> collection, ArrayFactory<T> factory) Allocates new array of sizearray.length + collection.size()and copies elements ofarrayandcollectionto it.static byte[]mergeArrays(byte[] a1, byte[] a2) static int[]mergeArrays(int[] a1, int[] a2) static String[]mergeArrays(String[] a1, String... a2) static <T> T[]mergeArrays(T[] a1, T[] a2) static <T> T[]mergeArrays(T[] a1, T[] a2, ArrayFactory<T> factory) static <T> T[]mergeCollections(Collection<? extends T> c1, Collection<? extends T> c2, ArrayFactory<T> factory) static intmin(int[] values) static int[]newIntArray(int count) static long[]newLongArray(int count) static Object[]newObjectArray(int count) static String[]newStringArray(int count) static byte[]prepend(byte element, byte[] array) static <T> T[]prepend(T element, T[] array) static <T> T[]prepend(T element, T[] src, ArrayFactory<T> factory) static <T> T[]static boolean[]realloc(boolean[] array, int newSize) static byte[]realloc(byte[] array, int newSize) static char[]realloc(char[] array, int newSize) static int[]realloc(int[] array, int newSize) static long[]realloc(long[] array, int newSize) static <T> T[]realloc(T[] array, int newSize, ArrayFactory<T> factory) static int[]remove(int[] src, int idx) static short[]remove(short[] src, int idx) static <T> T[]remove(T[] src, int idx) Removes element with indexidxfrom arraysrc.static <T> T[]remove(T[] src, int idx, ArrayFactory<T> factory) static <T> T[]remove(T[] src, T element) static <T> T[]remove(T[] src, T element, ArrayFactory<T> factory) static int[]reverseArray(int[] array) static <T> T[]reverseArray(T[] array) static <T> voidrotateLeft(T[] array, int i1, int i2) static <T> voidrotateRight(T[] array, int i1, int i2) static booleanstartsWith(byte[] array, byte[] prefix) static booleanstartsWith(byte[] array, int start, byte[] subArray) static <E> booleanstartsWith(E[] array, E[] subArray) static <T> T[]stripTrailingNulls(T[] array) static voidswap(boolean[] array, int i1, int i2) static voidswap(char[] array, int i1, int i2) static voidswap(int[] array, int i1, int i2) static <T> voidswap(T[] array, int i1, int i2) static int[]toIntArray(Collection<Integer> list) static <T> T[]toObjectArray(Class<T> aClass, Object... source) static Object[]toObjectArray(Collection<?> collection) static <T> T[]toObjectArray(Collection<T> collection, Class<T> aClass) static String[]toStringArray(Collection<String> collection)
-
Field Details
-
EMPTY_SHORT_ARRAY
public static final short[] EMPTY_SHORT_ARRAY -
EMPTY_CHAR_ARRAY
public static final char[] EMPTY_CHAR_ARRAY -
EMPTY_BYTE_ARRAY
public static final byte[] EMPTY_BYTE_ARRAY -
EMPTY_INT_ARRAY
public static final int[] EMPTY_INT_ARRAY -
EMPTY_BOOLEAN_ARRAY
public static final boolean[] EMPTY_BOOLEAN_ARRAY -
EMPTY_OBJECT_ARRAY
-
EMPTY_STRING_ARRAY
-
EMPTY_CLASS_ARRAY
-
EMPTY_LONG_ARRAY
public static final long[] EMPTY_LONG_ARRAY -
EMPTY_COLLECTION_ARRAY
-
EMPTY_FILE_ARRAY
-
EMPTY_RUNNABLE_ARRAY
-
STRING_ARRAY_FACTORY
-
OBJECT_ARRAY_FACTORY
-
-
Method Details
-
realloc
-
realloc
-
realloc
-
realloc
-
realloc
-
append
-
append
-
insert
-
insert
-
append
-
append
-
realloc
-
toObjectArray
-
toObjectArray
-
toObjectArray
-
toIntArray
-
mergeArrays
-
mergeCollections
@NotNull @Contract(pure=true) public static <T> T[] mergeCollections(@NotNull Collection<? extends T> c1, @NotNull Collection<? extends T> c2, @NotNull ArrayFactory<T> factory) -
mergeArrays
-
mergeArrays
-
mergeArrays
-
mergeArrays
-
mergeArrayAndCollection
@NotNull @Contract(pure=true) public static <T> T[] mergeArrayAndCollection(@NotNull T[] array, @NotNull Collection<T> collection, @NotNull ArrayFactory<T> factory) Allocates new array of sizearray.length + collection.size()and copies elements ofarrayandcollectionto it.- Parameters:
array- source arraycollection- source collectionfactory- array factory used to create destination array of typeT- Returns:
- destination array
-
append
Appendselementto thesrcarray. As you can imagine the appended element will be the last one in the returned result.- Parameters:
src- array to which theelementshould be appended.element- object to be appended to the end ofsrcarray.- Returns:
- new array
-
prepend
-
prepend
-
prepend
-
prepend
-
append
-
append
-
remove
Removes element with indexidxfrom arraysrc.- Parameters:
src- array.idx- index of element to be removed.- Returns:
- modified array.
-
remove
-
remove
-
remove
-
remove
-
remove
-
find
-
find
-
startsWith
-
startsWith
-
startsWith
-
equals
-
equals
-
reverseArray
-
reverseArray
-
lexicographicCompare
-
lexicographicCompare
-
swap
-
swap
-
swap
-
swap
-
rotateLeft
-
rotateRight
-
indexOf
-
indexOf
-
indexOf
-
indexOf
-
indexOf
-
indexOf
-
indexOf
-
indexOf
-
lastIndexOf
-
lastIndexOf
-
lastIndexOf
-
lastIndexOf
-
contains
-
contains
-
newIntArray
-
newLongArray
-
newStringArray
-
newObjectArray
-
ensureExactSize
-
getFirstElement
-
getLastElement
-
isEmpty
-
toStringArray
-
copy
-
stripTrailingNulls
-
averageAmongMedians
-
averageAmongMedians
-
min
public static int min(int[] values)
-