public final class ArrayUtil extends ArrayUtilRt
Modifier and Type | Field and Description |
---|---|
static byte[] |
EMPTY_BYTE_ARRAY |
static char[] |
EMPTY_CHAR_ARRAY |
static java.lang.CharSequence |
EMPTY_CHAR_SEQUENCE |
static java.lang.Class[] |
EMPTY_CLASS_ARRAY |
static java.io.File[] |
EMPTY_FILE_ARRAY |
static int[] |
EMPTY_INT_ARRAY |
static long[] |
EMPTY_LONG_ARRAY |
static java.lang.Object[] |
EMPTY_OBJECT_ARRAY |
static java.lang.String[] |
EMPTY_STRING_ARRAY |
static ArrayFactory<java.lang.Object> |
OBJECT_ARRAY_FACTORY |
static ArrayFactory<java.lang.String> |
STRING_ARRAY_FACTORY |
EMPTY_BOOLEAN_ARRAY, EMPTY_COLLECTION_ARRAY, EMPTY_SHORT_ARRAY
Modifier and Type | Method and Description |
---|---|
static 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)
Appends
element to the src array. |
static <T> T [] |
append(T [] src,
T element,
ArrayFactory<? extends T> factory) |
static <T> T [] |
append(T [] src,
T element,
java.lang.Class<T> componentType) |
static long |
averageAmongMedians(int [] time,
int part) |
static long |
averageAmongMedians(long [] time,
int part) |
static boolean |
contains(java.lang.String s,
java.lang.String... strings) |
static <T> boolean |
contains(T o,
T... objects) |
static <T> void |
copy(java.util.Collection<? extends T> src,
T [] dst,
int dstOffset) |
static boolean [] |
copyOf(boolean [] original) |
static int [] |
copyOf(int [] original) |
static <T> T [] |
copyOf(T [] original) |
static <E> E [] |
ensureExactSize(int count,
E [] sample) |
static <T> boolean |
equals(T [] a1,
T [] a2,
<any> comparator) |
static int |
find(int [] src,
int obj) |
static <T> int |
find(T [] src,
T obj) |
static <T> java.lang.Class<T> |
getComponentType(T [] collection) |
static <T> T |
getFirstElement(T [] array) |
static int |
getLastElement(int [] array,
int defaultValue) |
static <T> T |
getLastElement(T [] array) |
static int |
indexOf(byte [] array,
byte [] pattern,
int startIndex) |
static int |
indexOf(int [] ints,
int value) |
static <T> int |
indexOf(java.util.List<? extends T> objects,
T object,
<any> comparator) |
static int |
indexOf(long [] ints,
long value) |
static int |
indexOf(java.lang.Object [] objects,
java.lang.Object object) |
static <T> int |
indexOf(T [] objects,
T object,
<any> comparator) |
static int [] |
insert(int [] array,
int index,
int value) |
static <T> T [] |
insert(T [] array,
int index,
T value) |
static <T> boolean |
isEmpty(T [] array) |
static int |
lastIndexOf(int [] src,
int obj) |
static <T> int |
lastIndexOf(java.util.List<? extends T> src,
T obj,
<any> comparator) |
static <T> int |
lastIndexOf(T [] src,
T obj) |
static <T> int |
lastIndexOf(T [] src,
T obj,
<any> comparator) |
static int |
lastIndexOfNot(int [] src,
int obj) |
static int |
lexicographicCompare(int [] obj1,
int [] obj2) |
static int |
lexicographicCompare(java.lang.String [] obj1,
java.lang.String [] obj2) |
static <T> int |
lexicographicCompare(T [] obj1,
T [] obj2) |
static int |
max(int[] values) |
static <T> T [] |
mergeArrayAndCollection(T [] array,
java.util.Collection<? extends T> collection,
ArrayFactory<? extends T> factory)
Allocates new array of size
array.length + collection.size() and copies elements of array and
collection to it. |
static byte [] |
mergeArrays(byte [] a1,
byte [] a2) |
static int [] |
mergeArrays(int [] a1,
int [] a2) |
static java.lang.String [] |
mergeArrays(java.lang.String [] a1,
java.lang.String... a2) |
static <T> T [] |
mergeArrays(T [] a1,
T [] a2) |
static <T> T [] |
mergeArrays(T [] a1,
T [] a2,
ArrayFactory<? extends T> factory) |
static <T> T [] |
mergeCollections(java.util.Collection<? extends T> c1,
java.util.Collection<? extends T> c2,
ArrayFactory<? extends T> factory) |
static int[] |
mergeSortedArrays(int[] a1,
int[] a2,
boolean mergeEqualItems) |
static int |
min(int[] values) |
static <T> T [] |
newArray(java.lang.Class<T> type,
int length) |
static int [] |
newIntArray(int count) |
static long [] |
newLongArray(int count) |
static java.lang.Object [] |
newObjectArray(int count) |
static java.lang.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<? extends T> factory) |
static <T> T [] |
prepend(T element,
T [] array,
java.lang.Class<T> type) |
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 short [] |
realloc(short [] array,
int newSize) |
static <T> T [] |
realloc(T [] array,
int newSize,
ArrayFactory<? extends 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 index
idx from array src . |
static <T> T [] |
remove(T [] src,
int idx,
ArrayFactory<? extends T> factory) |
static <T> T [] |
remove(T [] src,
T element) |
static <T> T [] |
remove(T [] src,
T element,
ArrayFactory<? extends T> factory) |
static int [] |
reverseArray(int [] array) |
static <T> T [] |
reverseArray(T [] array) |
static <T> void |
rotateLeft(T [] array,
int i1,
int i2) |
static <T> void |
rotateRight(T [] array,
int i1,
int i2) |
static boolean |
startsWith(byte [] array,
byte [] prefix) |
static boolean |
startsWith(byte [] array,
int start,
byte [] subArray) |
static <E> boolean |
startsWith(E [] array,
E [] subArray) |
static <T> T [] |
stripTrailingNulls(T [] array) |
static void |
swap(boolean [] array,
int i1,
int i2) |
static void |
swap(char [] array,
int i1,
int i2) |
static void |
swap(int [] array,
int i1,
int i2) |
static <T> void |
swap(T [] array,
int i1,
int i2) |
static int [] |
toIntArray(java.util.Collection<java.lang.Integer> list) |
static <T> T [] |
toObjectArray(java.lang.Class<T> aClass,
java.lang.Object... source) |
static java.lang.Object [] |
toObjectArray(java.util.Collection<?> collection) |
static <T> T [] |
toObjectArray(java.util.Collection<? extends T> collection,
java.lang.Class<T> aClass) |
static java.lang.String [] |
toStringArray(java.util.Collection<java.lang.String> collection) |
find, indexOf
public static final char[] EMPTY_CHAR_ARRAY
public static final byte[] EMPTY_BYTE_ARRAY
public static final int[] EMPTY_INT_ARRAY
public static final java.lang.Object[] EMPTY_OBJECT_ARRAY
public static final java.lang.String[] EMPTY_STRING_ARRAY
public static final java.lang.Class[] EMPTY_CLASS_ARRAY
public static final long[] EMPTY_LONG_ARRAY
public static final java.io.File[] EMPTY_FILE_ARRAY
public static final java.lang.CharSequence EMPTY_CHAR_SEQUENCE
public static final ArrayFactory<java.lang.String> STRING_ARRAY_FACTORY
public static final ArrayFactory<java.lang.Object> OBJECT_ARRAY_FACTORY
public static byte [] realloc(byte [] array, int newSize)
public static boolean [] realloc(boolean [] array, int newSize)
public static short [] realloc(short [] array, int newSize)
public static long [] realloc(long [] array, int newSize)
public static int [] realloc(int [] array, int newSize)
public static <T> T [] realloc(T [] array, int newSize, ArrayFactory<? extends T> factory)
public static long [] append(long [] array, long value)
public static int [] append(int [] array, int value)
public static <T> T [] insert(T [] array, int index, T value)
public static int [] insert(int [] array, int index, int value)
public static byte [] append(byte [] array, byte value)
public static boolean [] append(boolean [] array, boolean value)
public static char [] realloc(char [] array, int newSize)
public static <T> T [] toObjectArray(java.util.Collection<? extends T> collection, java.lang.Class<T> aClass)
public static <T> T [] toObjectArray(java.lang.Class<T> aClass, java.lang.Object... source)
public static java.lang.Object [] toObjectArray(java.util.Collection<?> collection)
public static int [] toIntArray(java.util.Collection<java.lang.Integer> list)
public static <T> T [] mergeArrays(T [] a1, T [] a2)
public static <T> T [] mergeCollections(java.util.Collection<? extends T> c1, java.util.Collection<? extends T> c2, ArrayFactory<? extends T> factory)
public static <T> T [] mergeArrays(T [] a1, T [] a2, ArrayFactory<? extends T> factory)
public static java.lang.String [] mergeArrays(java.lang.String [] a1, java.lang.String... a2)
public static int [] mergeArrays(int [] a1, int [] a2)
public static byte [] mergeArrays(byte [] a1, byte [] a2)
public static <T> T [] mergeArrayAndCollection(T [] array, java.util.Collection<? extends T> collection, ArrayFactory<? extends T> factory)
array.length + collection.size()
and copies elements of array
and
collection
to it.array
- source arraycollection
- source collectionfactory
- array factory used to create destination array of type T
public static <T> T [] append(T [] src, T element)
element
to the src
array. As you can
imagine the appended element will be the last one in the returned result.src
- array to which the element
should be appended.element
- object to be appended to the end of src
array.public static <T> T [] prepend(T element, T [] array)
public static <T> T [] prepend(T element, T [] array, java.lang.Class<T> type)
public static <T> T [] prepend(T element, T [] src, ArrayFactory<? extends T> factory)
public static byte [] prepend(byte element, byte [] array)
public static <T> T [] append(T [] src, T element, ArrayFactory<? extends T> factory)
public static <T> T [] append(T [] src, T element, java.lang.Class<T> componentType)
public static <T> T [] remove(T [] src, int idx)
idx
from array src
.src
- array.idx
- index of element to be removed.public static <T> T [] newArray(java.lang.Class<T> type, int length)
public static <T> T [] remove(T [] src, int idx, ArrayFactory<? extends T> factory)
public static <T> T [] remove(T [] src, T element)
public static <T> T [] remove(T [] src, T element, ArrayFactory<? extends T> factory)
public static int [] remove(int [] src, int idx)
public static short [] remove(short [] src, int idx)
public static int find(int [] src, int obj)
public static <T> int find(T [] src, T obj)
public static boolean startsWith(byte [] array, byte [] prefix)
public static <E> boolean startsWith(E [] array, E [] subArray)
public static boolean startsWith(byte [] array, int start, byte [] subArray)
public static <T> boolean equals(T [] a1, T [] a2, <any> comparator)
public static <T> T [] reverseArray(T [] array)
public static int [] reverseArray(int [] array)
public static int lexicographicCompare(java.lang.String [] obj1, java.lang.String [] obj2)
public static int lexicographicCompare(int [] obj1, int [] obj2)
public static <T> int lexicographicCompare(T [] obj1, T [] obj2)
public static <T> void swap(T [] array, int i1, int i2)
public static void swap(int [] array, int i1, int i2)
public static void swap(boolean [] array, int i1, int i2)
public static void swap(char [] array, int i1, int i2)
public static <T> void rotateLeft(T [] array, int i1, int i2)
public static <T> void rotateRight(T [] array, int i1, int i2)
public static int indexOf(java.lang.Object [] objects, java.lang.Object object)
public static <T> int indexOf(java.util.List<? extends T> objects, T object, <any> comparator)
public static <T> int indexOf(T [] objects, T object, <any> comparator)
public static int indexOf(long [] ints, long value)
public static int indexOf(int [] ints, int value)
public static int indexOf(byte [] array, byte [] pattern, int startIndex)
public static <T> int lastIndexOf(T [] src, T obj)
public static int lastIndexOf(int [] src, int obj)
public static int lastIndexOfNot(int [] src, int obj)
public static <T> int lastIndexOf(T [] src, T obj, <any> comparator)
public static <T> int lastIndexOf(java.util.List<? extends T> src, T obj, <any> comparator)
@SafeVarargs public static <T> boolean contains(T o, T... objects)
public static boolean contains(java.lang.String s, java.lang.String... strings)
public static int [] newIntArray(int count)
public static long [] newLongArray(int count)
public static java.lang.String [] newStringArray(int count)
public static java.lang.Object [] newObjectArray(int count)
public static <E> E [] ensureExactSize(int count, E [] sample)
public static <T> T getFirstElement(T [] array)
public static <T> T getLastElement(T [] array)
public static int getLastElement(int [] array, int defaultValue)
public static <T> boolean isEmpty(T [] array)
public static java.lang.String [] toStringArray(java.util.Collection<java.lang.String> collection)
public static <T> void copy(java.util.Collection<? extends T> src, T [] dst, int dstOffset)
public static <T> T [] copyOf(T [] original)
public static boolean [] copyOf(boolean [] original)
public static int [] copyOf(int [] original)
public static <T> T [] stripTrailingNulls(T [] array)
public static long averageAmongMedians(long [] time, int part)
public static long averageAmongMedians(int [] time, int part)
public static int min(int[] values)
public static int max(int[] values)
public static int[] mergeSortedArrays(int[] a1, int[] a2, boolean mergeEqualItems)
public static <T> java.lang.Class<T> getComponentType(T [] collection)