|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjlibs.core.lang.ArrayUtil
public class ArrayUtil
| Constructor Summary | |
|---|---|
ArrayUtil()
|
|
| Method Summary | ||
|---|---|---|
static
|
clone(Object[] src,
Class<T> componentType)
returns the clone of src array. |
|
static Object[] |
concat(Object[] array1,
Object[] array2)
Returns new array which has all values from array1 and array2 in order. |
|
static
|
concat(Object[] array1,
Object[] array2,
Class<T> componentType)
|
|
static
|
contains(T[] array,
S item)
tells whether the array contains the given item |
|
static
|
copy(Object[] src,
T[] dest)
Copies all elements from src array to dest array. |
|
static boolean |
endsWith(Object[] array1,
Object[] array2)
Returns true if array1 ends with array2 |
|
static byte[] |
ensureCapacity(byte[] array,
int capacity)
|
|
static char[] |
ensureCapacity(char[] array,
int capacity)
|
|
static boolean |
equals(Object[] array1,
int from1,
Object[] array2,
int from2,
int length)
returns array1[from1, from1+length-1] and array2[from2, from2+length-1] contain same elements in case of index out of range, returns false |
|
static
|
filter(T[] array,
Filter<T> filter)
Returns new array which contains only those elements from given array
which are selected by the filter |
|
static
|
getFirst(T[] array)
Returns first element in given array. |
|
static
|
getLast(T[] array)
Returns last element in given array. |
|
static
|
indexOf(T[] array,
S item)
Returns first index of item in given array |
|
static
|
indexOf(T[] array,
S item,
int fromIndex)
returns first index of item |
|
static boolean |
startsWith(Object[] array1,
Object[] array2)
Returns true if array1 starts with array2 |
|
static Boolean[] |
toObjectArray(boolean[] arr)
|
|
static Byte[] |
toObjectArray(byte[] arr)
|
|
static Character[] |
toObjectArray(char[] arr)
|
|
static Double[] |
toObjectArray(double[] arr)
|
|
static Float[] |
toObjectArray(float[] arr)
|
|
static Integer[] |
toObjectArray(int[] arr)
|
|
static Long[] |
toObjectArray(long[] arr)
|
|
static Short[] |
toObjectArray(short[] arr)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ArrayUtil()
| Method Detail |
|---|
public static <T,S extends T> int indexOf(T[] array,
S item,
int fromIndex)
item in given array starting
from fromIndex(inclusive)
- Parameters:
array - object array, can be nullitem - item to be searched, can be nullfromIndex - index(inclusive) from which search happens.
- Returns:
- -1 if array is null, or the item is not found
otherwize returns first index of item in array
public static <T,S extends T> int indexOf(T[] array,
S item)
item in given array
array - object array, can be nullitem - item to be searched, can be null
indexOf(Object[], Object, int)
public static <T,S extends T> boolean contains(T[] array,
S item)
array contains the given item
array - object array, can be nullitem - item to be searched, can be null
public static <T> T getFirst(T[] array)
array.
if array is null or of length zero, then returns null
public static <T> T getLast(T[] array)
array.
if array is null or of length zero, then returns null
public static boolean equals(Object[] array1,
int from1,
Object[] array2,
int from2,
int length)
public static boolean startsWith(Object[] array1,
Object[] array2)
array1 starts with array2
public static boolean endsWith(Object[] array1,
Object[] array2)
array1 ends with array2
public static <T> T[] copy(Object[] src,
T[] dest)
src array to dest array.
If dest.length<src.length, it copies only the number of elements
that can fit in dest array.
src - source arraydest - destination array
public static <T> T[] clone(Object[] src,
Class<T> componentType)
src array.
src - source arraycomponentType - the componentType used for the new array created
public static <T> T[] filter(T[] array,
Filter<T> filter)
array
which are selected by the filter
array - the array to be filteredfilter - filter to use
public static <T> T[] concat(Object[] array1,
Object[] array2,
Class<T> componentType)
public static Object[] concat(Object[] array1,
Object[] array2)
public static Boolean[] toObjectArray(boolean[] arr)
public static Character[] toObjectArray(char[] arr)
public static Byte[] toObjectArray(byte[] arr)
public static Short[] toObjectArray(short[] arr)
public static Integer[] toObjectArray(int[] arr)
public static Long[] toObjectArray(long[] arr)
public static Float[] toObjectArray(float[] arr)
public static Double[] toObjectArray(double[] arr)
public static byte[] ensureCapacity(byte[] array,
int capacity)
public static char[] ensureCapacity(char[] array,
int capacity)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||