com.alee.utils
Class ArrayUtils

java.lang.Object
  extended by com.alee.utils.ArrayUtils

public final class ArrayUtils
extends java.lang.Object

This class provides a set of utilities to work with arrays.

Author:
Mikle Garin

Constructor Summary
ArrayUtils()
           
 
Method Summary
static
<T> T[]
createArray(java.lang.Class<T> classType, int length)
          Returns new array with the specified component class type.
static
<T> T[]
createArray(T[] array, int length)
          Returns new array with the component class type from the specified array.
static int indexOf(byte object, byte[] array)
          Returns index of specified byte in array.
static int indexOf(char object, char[] array)
          Returns index of specified character in array.
static int indexOf(double number, double[] array)
          Returns index of specified double in array.
static int indexOf(float number, float[] array)
          Returns index of specified float in array.
static int indexOf(int number, int[] array)
          Returns index of specified int in array.
static int indexOf(java.lang.Object object, java.lang.Object[] array)
          Returns index of specified object in array.
static int indexOf(java.lang.String text, java.lang.String[] array)
          Returns index of specified text in array.
static int indexOf(java.lang.String text, java.lang.String[] array, boolean ignoreCase)
          Returns index of specified text in array.
static boolean[] insert(boolean[] array, int index, boolean object)
          Returns new array with boolean inserted at the specified index.
static byte[] insert(byte[] array, int index, byte object)
          Returns new array with byte inserted at the specified index.
static char[] insert(char[] array, int index, char object)
          Returns new array with char inserted at the specified index.
static double[] insert(double[] array, int index, double object)
          Returns new array with double inserted at the specified index.
static float[] insert(float[] array, int index, float object)
          Returns new array with float inserted at the specified index.
static int[] insert(int[] array, int index, int object)
          Returns new array with int inserted at the specified index.
static
<T> T[]
insert(T[] array, int index, T object)
          Returns new array with object inserted at the specified index.
static boolean[] remove(boolean[] array, int index)
          Returns new array with the boolean under specified index removed.
static byte[] remove(byte[] array, byte index)
          Returns new array with the byte under specified index removed.
static char[] remove(char[] array, char index)
          Returns new array with the char under specified index removed.
static double[] remove(double[] array, double index)
          Returns new array with the double under specified index removed.
static float[] remove(float[] array, float index)
          Returns new array with the float under specified index removed.
static int[] remove(int[] array, int index)
          Returns new array with the int under specified index removed.
static
<T> T[]
remove(T[] array, int index)
          Returns new array with the object under specified index removed.
static
<T> T[]
remove(T[] array, T object)
          Returns new array with the specified object removed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayUtils

public ArrayUtils()
Method Detail

indexOf

public static int indexOf(int number,
                          int[] array)
Returns index of specified int in array.

Parameters:
number - int to find
array - array to process
Returns:
index of specified int in array

indexOf

public static int indexOf(float number,
                          float[] array)
Returns index of specified float in array.

Parameters:
number - float to find
array - array to process
Returns:
index of specified float in array

indexOf

public static int indexOf(double number,
                          double[] array)
Returns index of specified double in array.

Parameters:
number - double to find
array - array to process
Returns:
index of specified double in array

indexOf

public static int indexOf(char object,
                          char[] array)
Returns index of specified character in array.

Parameters:
object - character to find
array - array to process
Returns:
index of specified character in array

indexOf

public static int indexOf(byte object,
                          byte[] array)
Returns index of specified byte in array.

Parameters:
object - byte to find
array - array to process
Returns:
index of specified byte in array

indexOf

public static int indexOf(java.lang.String text,
                          java.lang.String[] array)
Returns index of specified text in array.

Parameters:
text - text to find
array - array to process
Returns:
index of specified text in array

indexOf

public static int indexOf(java.lang.String text,
                          java.lang.String[] array,
                          boolean ignoreCase)
Returns index of specified text in array.

Parameters:
text - text to find
array - array to process
ignoreCase - whether ignore text case or not
Returns:
index of specified text in array

indexOf

public static int indexOf(java.lang.Object object,
                          java.lang.Object[] array)
Returns index of specified object in array.

Parameters:
object - object to find
array - array to process
Returns:
index of specified object in array

remove

public static <T> T[] remove(T[] array,
                             T object)
Returns new array with the specified object removed.

Type Parameters:
T - component type
Parameters:
array - array to process
object - object to remove
Returns:
new array with the specified object removed

remove

public static int[] remove(int[] array,
                           int index)
Returns new array with the int under specified index removed.

Parameters:
array - array to process
index - index of int to remove
Returns:
new array with the int under specified index removed

remove

public static float[] remove(float[] array,
                             float index)
Returns new array with the float under specified index removed.

Parameters:
array - array to process
index - index of float to remove
Returns:
new array with the float under specified index removed

remove

public static double[] remove(double[] array,
                              double index)
Returns new array with the double under specified index removed.

Parameters:
array - array to process
index - index of double to remove
Returns:
new array with the double under specified index removed

remove

public static char[] remove(char[] array,
                            char index)
Returns new array with the char under specified index removed.

Parameters:
array - array to process
index - index of char to remove
Returns:
new array with the char under specified index removed

remove

public static byte[] remove(byte[] array,
                            byte index)
Returns new array with the byte under specified index removed.

Parameters:
array - array to process
index - index of byte to remove
Returns:
new array with the byte under specified index removed

remove

public static boolean[] remove(boolean[] array,
                               int index)
Returns new array with the boolean under specified index removed.

Parameters:
array - array to process
index - index of boolean to remove
Returns:
new array with the boolean under specified index removed

remove

public static <T> T[] remove(T[] array,
                             int index)
Returns new array with the object under specified index removed.

Type Parameters:
T - component type
Parameters:
array - array to process
index - index of object to remove
Returns:
new array with the object under specified index removed

insert

public static int[] insert(int[] array,
                           int index,
                           int object)
Returns new array with int inserted at the specified index.

Parameters:
array - array to process
index - insert index
object - int to insert
Returns:
new array with int inserted at the specified index

insert

public static float[] insert(float[] array,
                             int index,
                             float object)
Returns new array with float inserted at the specified index.

Parameters:
array - array to process
index - insert index
object - float to insert
Returns:
new array with float inserted at the specified index

insert

public static double[] insert(double[] array,
                              int index,
                              double object)
Returns new array with double inserted at the specified index.

Parameters:
array - array to process
index - insert index
object - double to insert
Returns:
new array with double inserted at the specified index

insert

public static char[] insert(char[] array,
                            int index,
                            char object)
Returns new array with char inserted at the specified index.

Parameters:
array - array to process
index - insert index
object - char to insert
Returns:
new array with char inserted at the specified index

insert

public static byte[] insert(byte[] array,
                            int index,
                            byte object)
Returns new array with byte inserted at the specified index.

Parameters:
array - array to process
index - insert index
object - byte to insert
Returns:
new array with byte inserted at the specified index

insert

public static boolean[] insert(boolean[] array,
                               int index,
                               boolean object)
Returns new array with boolean inserted at the specified index.

Parameters:
array - array to process
index - insert index
object - boolean to insert
Returns:
new array with boolean inserted at the specified index

insert

public static <T> T[] insert(T[] array,
                             int index,
                             T object)
Returns new array with object inserted at the specified index.

Type Parameters:
T - component type
Parameters:
array - array to process
index - insert index
object - object to insert
Returns:
new array with object inserted at the specified index

createArray

public static <T> T[] createArray(T[] array,
                                  int length)
Returns new array with the component class type from the specified array.

Type Parameters:
T - component type
Parameters:
array - array to retrieve class type from
length - array length
Returns:
new array with the component class type from the specified array

createArray

public static <T> T[] createArray(java.lang.Class<T> classType,
                                  int length)
Returns new array with the specified component class type.

Type Parameters:
T - component type
Parameters:
classType - component class type
length - array length
Returns:
new array with the specified component class type