com.intellij.util
Class ArrayUtil

java.lang.Object
  extended by com.intellij.util.ArrayUtil

public class ArrayUtil
extends java.lang.Object

Author: msk


Field Summary
static boolean[] EMPTY_BOOLEAN_ARRAY
           
static byte[] EMPTY_BYTE_ARRAY
           
static java.lang.Class[] EMPTY_CLASS_ARRAY
           
static int[] EMPTY_INT_ARRAY
           
static java.lang.Object[] EMPTY_OBJECT_ARRAY
           
static java.lang.String[] EMPTY_STRING_ARRAY
           
 
Constructor Summary
ArrayUtil()
           
 
Method Summary
static
<T> T[]
append(T[] src, T element)
          Appends element to the src array.
static
<T> T[]
emptyArray()
           
static
<T> boolean
equals(T[] a1, T[] a2, gnu.trove.Equality<? super T> comparator)
           
static
<T> int
find(T[] src, T obj)
           
static
<T> T[]
mergeArrays(T[] a1, T[] a2, java.lang.Class<T> aClass)
           
static byte[] realloc(byte[] array, int newSize)
           
static
<T> T[]
remove(T[] src, int idx)
          Removes element with index idx from array src.
static
<T> T[]
reverseArray(T[] array)
           
static boolean startsWith(byte[] array, byte[] subArray)
           
static java.lang.Object[] toObjectArray(java.util.Collection collection)
           
static
<T> T[]
toObjectArray(java.util.Collection<T> collection, java.lang.Class<T> aClass)
           
static java.lang.String[] toStringArray(java.util.Collection<java.lang.String> collection)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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

public static final java.lang.Object[] EMPTY_OBJECT_ARRAY

EMPTY_STRING_ARRAY

public static final java.lang.String[] EMPTY_STRING_ARRAY

EMPTY_CLASS_ARRAY

public static final java.lang.Class[] EMPTY_CLASS_ARRAY
Constructor Detail

ArrayUtil

public ArrayUtil()
Method Detail

realloc

public static byte[] realloc(byte[] array,
                             int newSize)

toObjectArray

public static <T> T[] toObjectArray(java.util.Collection<T> collection,
                                    java.lang.Class<T> aClass)

toObjectArray

public static java.lang.Object[] toObjectArray(java.util.Collection collection)

toStringArray

public static java.lang.String[] toStringArray(java.util.Collection<java.lang.String> collection)

mergeArrays

public static <T> T[] mergeArrays(T[] a1,
                                  T[] a2,
                                  java.lang.Class<T> aClass)

emptyArray

public static <T> T[] emptyArray()

append

public static <T> T[] append(T[] src,
                             T element)
Appends element to the src array. As you can imagine the appended element will be the last one in the returned result.

Parameters:
src - array to which the element should be appended.
element - object to be appended to the end of src array.

remove

public static <T> T[] remove(T[] src,
                             int idx)
Removes element with index idx from array src.

Parameters:
src - array.
idx - index of element to be removed.
Returns:
modified array.

find

public static <T> int find(T[] src,
                           T obj)
Parameters:
src - source array.
obj - object to be found.
Returns:
index of obj in the src array. Returns -1 if passed object isn't found. This method uses equals of arrays elements to compare obj with these elements.

startsWith

public static boolean startsWith(byte[] array,
                                 byte[] subArray)

equals

public static <T> boolean equals(T[] a1,
                                 T[] a2,
                                 gnu.trove.Equality<? super T> comparator)

reverseArray

public static <T> T[] reverseArray(T[] array)