|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.xmlmind.util.ArrayUtil
public final class ArrayUtil
A collection of utility functions (static methods) operating on arrays. Complements what's found in java.util.Arrays.
| Method Summary | ||
|---|---|---|
static
|
append(T[] list,
T item)
Inserts specified item in specified array at the end of specified array. |
|
static
|
find(T[] list,
T item)
Searches specified array for specified item. |
|
static
|
indexOf(T[] list,
T item)
Searches specified array for specified item. |
|
static
|
insert(T[] list,
int index,
T item)
Equivalent to insert(list,
index, new T[] { item}). |
|
static
|
insert(T[] list,
int index,
T[] items)
Inserts specified items in specified array at specified index. |
|
static
|
prepend(T[] list,
T item)
Inserts specified item in specified array at the beginning of specified array. |
|
static
|
remove(T[] list,
T item)
Remove specified item from specified array. |
|
static
|
removeAt(T[] list,
int index)
Equivalent to remove(list, index,
1). |
|
static
|
removeAt(T[] list,
int index,
int count)
Removes a range of items found at specified index from specified array. |
|
static
|
reverse(T[] list)
Reverses the order of the items in the specified array. |
|
static
|
subArray(T[] list,
int start)
Equivalent to subArray(list, start, list.length). |
|
static
|
subArray(T[] list,
int start,
int end)
Returns a sub-array of specified array. |
|
static
|
trimToSize(T[] list,
int listSize)
Returns specified array if its length is equal to specified size; otherwise returns a copy of specified array having specified size. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static final <T> T[] trimToSize(T[] list,
int listSize)
T - the type of the components of the arraylist - array whose size needs to be adjustedlistSize - the size of the returned array
listSize components
public static final <T> T[] subArray(T[] list,
int start)
subArray(list, start, list.length).
public static final <T> T[] subArray(T[] list,
int start,
int end)
T - the type of the components of the arraylist - the arraystart - the begin index, inclusiveend - the end index, exclusive
java.lang.IndexOutOfBoundsException - if start or end
are negative, if end is greater than list.length
or if start is greater than end
public static final <T> T[] insert(T[] list,
int index,
T item)
insert(list,
index, new T[] { item}).
public static final <T> T[] insert(T[] list,
int index,
T[] items)
T - the type of the components of the arraylist - list to be modifiedindex - items are inserted at this position.
Note that index may be equal to the size of the array. This means: insert at end.
items - items to be inserted
items.length
components
public static final <T> T[] prepend(T[] list,
T item)
T - the type of the components of the arraylist - list to be modifieditem - item to be inserted
public static final <T> T[] append(T[] list,
T item)
T - the type of the components of the arraylist - list to be modifieditem - item to be inserted
public static final <T> T[] remove(T[] list,
T item)
equals() and not == (using indexOf(T[], T)).
T - the type of the components of the arraylist - list to be modifieditem - item to be removed
public static final <T> int indexOf(T[] list,
T item)
find(T[], T),
items are compared using equals() and not ==.
T - the type of the components of the arraylist - a list possibly containing itemitem - searched item
public static final <T> int find(T[] list,
T item)
indexOf(T[], T),
items are compared using == and not equals().
T - the type of the components of the arraylist - a list possibly containing itemitem - searched item
public static final <T> T[] removeAt(T[] list,
int index)
remove(list, index,
1).
public static final <T> T[] removeAt(T[] list,
int index,
int count)
T - the type of the components of the arraylist - list to be modifiedindex - items are removed at this positioncount - number of items to be removed
public static final <T> void reverse(T[] list)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||