|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.rim.device.api.util.Arrays
Provides a host of utility functions for manipulating arrays.
| Method Summary | ||
static void |
add(Object[] array,
Object object)
Add an element to the array. |
|
static int |
binarySearch(int[] a,
int key)
Finds key in integer array using binary search. |
|
static int |
binarySearch(int[] a,
int key,
int fromIndex,
int toIndex)
Finds key in section of integer array using binary search. |
|
static int |
binarySearch(long[] a,
long key,
int fromIndex,
int toIndex)
Finds key in section of long integer array using binary search. |
|
static int |
binarySearch(Object[] a,
Object key,
Comparator c,
int fromIndex,
int toIndex)
Finds object key in section of object array using binary search with provided comparator. |
|
static byte[] |
copy(byte[] array)
Returns a duplicate copy of a byte array. |
|
static byte[] |
copy(byte[] array,
int offset,
int length)
Returns a duplicate copy of a section from a byte array. |
|
static char[] |
copy(char[] array)
Returns a duplicate copy of a character array. |
|
static char[] |
copy(char[] array,
int offset,
int length)
Returns a duplicate copy of a section from a character array. |
|
static int[] |
copy(int[] array)
Returns a duplicate copy of an integer array. |
|
static int[] |
copy(int[] array,
int offset,
int length)
Returns a duplicate copy of a section from an integer array. |
|
static long[] |
copy(long[] array)
Returns a duplicate copy of a long integer array. |
|
static long[] |
copy(long[] array,
int offset,
int length)
Returns a duplicate copy of a section from a long integer array. |
|
static short[] |
copy(short[] array)
Returns a duplicate copy of short integer arary. |
|
static short[] |
copy(short[] array,
int offset,
int length)
Returns a duplicate copy of a section from a short integer array. |
|
static boolean |
equals(byte[] a,
byte[] a2)
Determines if two byte arrays are equal. |
|
static boolean |
equals(byte[] a,
int aOffset,
byte[] a2,
int a2Offset,
int length)
Determines if the substrings of two byte arrays are equal. |
|
static boolean |
equals(char[] a,
char[] a2)
Determines if two character arrays are equal. |
|
static boolean |
equals(int[] a,
int[] a2)
Determines if two integer arrays are equal. |
|
static boolean |
equals(long[] a,
long[] a2)
Determines if two long integer arrays are equal. |
|
static boolean |
equals(Object[] a,
Object[] a2)
Determines if two object arrays are equal. |
|
static boolean |
equals(short[] a,
short[] a2)
Determines if two short arrays are equal. |
|
static void |
fill(byte[] array,
byte element)
Fills byte array with provided element. |
|
static void |
fill(byte[] array,
byte element,
int offset,
int length)
Fills a range in byte array with provided element. |
|
static void |
fill(char[] array,
char element)
Fills character array with provided element. |
|
static void |
fill(char[] array,
char element,
int offset,
int length)
Fills character array with provided element. |
|
static void |
fill(int[] array,
int element)
Fills integer array with provided element. |
|
static void |
fill(int[] array,
int element,
int offset,
int length)
Fills integer array with provided element. |
|
static void |
fill(long[] array,
long element)
Fills long integer array with provided element. |
|
static void |
fill(long[] array,
long element,
int offset,
int length)
Fills long integer array with provided element. |
|
static void |
fill(short[] array,
short element)
Fills short integer array with provided element. |
|
static void |
fill(short[] array,
short element,
int offset,
int length)
Fills short integer array with provided element. |
|
static int |
getIndex(Object[] array,
Object object)
Return the index of the specified element. |
|
static void |
remove(Object[] array,
Object object)
Remove an element from the array. |
|
static void |
sort(int[] a,
int fromIndex,
int toIndex)
Sorts section of integer array in ascending order. |
|
static void |
sort(int[] a,
int fromIndex,
int toIndex,
IntComparator c)
Sorts section of integer array in ascending order using a comparator. |
|
static void |
sort(int[] a,
int fromIndex,
int toIndex,
Object[] parallel)
Sorts an integer key array and a parallel object array in ascending order. |
|
static void |
sort(long[] a,
int fromIndex,
int toIndex)
Sorts section of long integer array in ascending order. |
|
static void |
sort(long[] a,
int fromIndex,
int toIndex,
int[] parallel)
Sorts a long integer key array and a parallel int array in ascending order. |
|
static void |
sort(long[] a,
int fromIndex,
int toIndex,
Object[] parallel)
Sorts a long integer key array and a parallel object array in ascending order. |
|
static void |
sort(Object[] a,
Comparator c)
Sorts object array with provided comparator. |
|
static void |
sort(Object[] a,
int fromIndex,
int toIndex,
Comparator c)
Sorts section of object array with provided comparator. |
|
static void |
sort(Object[] a,
int fromIndex,
int toIndex,
Object[] parallel,
Comparator comparator)
Sorts sections of two parallel object arrays with provided comparator. |
|
static void |
zero(byte[] array)
Deprecated. Use fill(array, (byte)0). |
|
static void |
zero(char[] array)
Deprecated. Use fill(array, (char)0). |
|
static void |
zero(int[] array)
Deprecated. Use fill(array, 0). |
|
static void |
zero(long[] array)
Deprecated. Use fill(array, 0L). |
|
static void |
zero(short[] array)
Deprecated. Use fill(array, (short)0). |
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static void add(Object[] array, Object object)
array - The array of objects being managed.object - The object to add.
public static long[] copy(long[] array,
int offset,
int length)
array - Array from which to copy section.offset - First element to copy.length - Number of elements to copy.IllegalArgumentException - If array cannot contain section
(that is, the offset is outside the bounds of the array, or if the offset
plus the length is greater than the size of the array).
public static void fill(byte[] array,
byte element)
This method overwrites each element in the array with a copy of your provided element.
array - Array to fill.element - Element to initialize array with.
public static void fill(byte[] array,
byte element,
int offset,
int length)
This method overwrites each element in the array with a copy of your provided element.
array - Array to fill.element - Element to initialize array with.
public static void fill(char[] array,
char element)
This method overwrites each element in the array with a copy of your provided element.
array - Array to fill.element - Element to initialize array with.
public static void fill(char[] array,
char element,
int offset,
int length)
This method overwrites each element in the array with a copy of your provided element.
array - Array to fill.element - Element to initialize array with.
public static void fill(short[] array,
short element)
This method overwrites each element in the array with a copy of your provided element.
array - Array to fill.element - Element to initialize array with.
public static void fill(short[] array,
short element,
int offset,
int length)
This method overwrites each element in the array with a copy of your provided element.
array - Array to fill.element - Element to initialize array with.
public static void fill(int[] array,
int element)
This method overwrites each element in the array with a copy of your provided element.
array - Array to fill.element - Element to initialize array with.
public static void fill(int[] array,
int element,
int offset,
int length)
This method overwrites each element in the array with a copy of your provided element.
array - Array to fill.element - Element to initialize array with.
public static void fill(long[] array,
long element)
This method overwrites each element in the array with a copy of your provided element.
array - Array to fill.element - Element to initialize array with.
public static void fill(long[] array,
long element,
int offset,
int length)
This method overwrites each element in the array with a copy of your provided element.
array - Array to fill.element - Element to initialize array with.public static void zero(byte[] array)
Equivalent to invoking
fill(byteArray,((byte)0)).
array - Array to zero.public static void zero(char[] array)
Equivalent to invoking
fill(charArray,((char)0)).
array - Array to zero.public static void zero(short[] array)
Equivalent to invoking
fill(shortArray,((short)0)).
array - Array to zero.public static void zero(int[] array)
Equivalent to invoking
fill(intArray,((int)0)).
array - Array to zero.public static void zero(long[] array)
Equivalent to invoking
fill(longArray,((long)0)).
array - Array to zero.
public static boolean equals(byte[] a,
byte[] a2)
Two arrays are considered equal if they are the same length and
a[i]==a2[i] for any value of i. Two null arrays
are considered equal.
a - First byte array.a2 - Second byte array.
public static boolean equals(byte[] a,
int aOffset,
byte[] a2,
int a2Offset,
int length)
This method uses the same test for equivalency as
equals(byte[],byte[]); simply consider the substrings to be the
two arrays to compare.
a - First byte array.aOffset - First element of substring from first array.a2 - Second byte array.a2Offset - First element of substring from second array.length - Length of substrings.
public static boolean equals(char[] a,
char[] a2)
Two arrays are considered equal if they are the same length and
a[i]==a2[i] for any value of i. Two null arrays
are considered equal.
a - First array.a2 - Second array.
public static boolean equals(short[] a,
short[] a2)
Two arrays are considered equal if they are the same length and
a[i]==a2[i] for any value of i. Two null arrays
are considered equal.
a - First array.a2 - Second array.
public static boolean equals(int[] a,
int[] a2)
Two arrays are considered equal if they are the same length and
a[i]==a2[i] for any value of i. Two null arrays
are considered equal.
a - First array.a2 - Second array.
public static boolean equals(long[] a,
long[] a2)
Two arrays are considered equal if they are the same length and
a[i]==a2[i] for any value of i. Two null arrays
are considered equal.
a - First array.a2 - Second array.public static boolean equals(Object[] a, Object[] a2)
The two arrays are considered equal if both these conditions are true:
a.length == a2.length
(a{i]==null) ? (a2[i]==null) : (a[i].equals(a2[i]))
In other words, the two arrays are equal if they both contain the same elements in the same order.
a - First array.a2 - Second array.public static void sort(Object[] a, Comparator c)
Invoke this method to sort the provided array with the provided comparator.
Note: This method produces a stable sort: equal elements will not be reordered as a result of the sort.
a - Array to sort; all elements in this array must be sortable with
the comparator.c - Comparator used for comparisons during the sort.ClassCastException - If the array contains elements which aren't
mutually comparable with the provided comparator.public static void sort(Object[] a, int fromIndex, int toIndex, Comparator c)
Invoke this method to sort a section of the provided array with the provided comparator.
Note: This method produces a stable sort: equal elements in the sorted section will not be reordered as a result of the sort.
a - Array to sort; all elements in this array must be sortable with
the comparator.fromIndex - First array element in the sorted section.toIndex - One past the last array element in the sorted section.c - Comparator used for comparisons during the sort.ArrayIndexOutOfBoundsException - If the fromIndex parameter is less than 0, or
toIndex is greater than the length of the array.ClassCastException - If the array section contains elements which
aren't mutually comparable with the provided comparator.IllegalArgumentException - If the fromIndex parameter is greater
than the toIndex parameter.
public static void sort(int[] a,
int fromIndex,
int toIndex)
Note: This method produces a stable sort: equal elements in the sorted section will not be reordered as a result of the sort.
a - Array to sort.fromIndex - First array element in the sorted section.toIndex - One past the last array element in the sorted section.ArrayIndexOutOfBoundsException - If the fromIndex parameter is less than 0, or
toIndex is greater than the length of the array.IllegalArgumentException - If the fromIndex parameter is greater
than the toIndex parameter.
public static void sort(int[] a,
int fromIndex,
int toIndex,
IntComparator c)
Note: This method produces a stable sort: equal elements in the sorted section will not be reordered as a result of the sort.
a - Array to sort.fromIndex - First array element in the sorted section.toIndex - One past the last array element in the sorted section.c - IntComparator used for comparisons during the sort.ArrayIndexOutOfBoundsException - If the fromIndex parameter is less than 0, or
toIndex is greater than the length of the array.IllegalArgumentException - If the fromIndex parameter is greater
than the toIndex parameter.
public static void sort(long[] a,
int fromIndex,
int toIndex)
Note: This method produces a stable sort: equal elements in the sorted section will not be reordered as a result of the sort.
a - Array to sort.fromIndex - First array element in the sorted section.toIndex - One past the last array element in the sorted section.ArrayIndexOutOfBoundsException - If the fromIndex parameter is less than 0, or
toIndex is greater than the length of the array.IllegalArgumentException - If the fromIndex parameter is greater
than the toIndex parameter.public static void sort(Object[] a, int fromIndex, int toIndex, Object[] parallel, Comparator comparator)
This method sorts two parallel; comparison checking is done on the first, key array; the parallel value array is rearranged symmetrically with the key array, but this method does no comparison checking on it.
Note: This method produces a stable sort: equal elements in the sorted section will not be reordered as a result of the sort.
a - Key array to sort; all elements in this array must be sortable with
the comparator.fromIndex - First array element in the sorted section.toIndex - One past the last array element in the sorted section.parallel - Parallel array of values; this array gets rearranged in
parallel with the sorted array, but no comparisons are done on this
array. This array must have at least as many elements in it as the
toIndex parameter.c - Comparator used for comparisons during the sort.ArrayIndexOutOfBoundsException - If the fromIndex parameter is less than 0, or
toIndex is greater than the length of the array.ClassCastException - If the array section contains elements which
aren't mutually comparable with the provided comparator.IllegalArgumentException - If the fromIndex parameter is greater
than the toIndex parameter.
public static void sort(int[] a,
int fromIndex,
int toIndex,
Object[] parallel)
This method sorts two parallel; comparison checking is done on the first, key array; the parallel value array is rearranged symmetrically with the key array, but this method does no comparison checking on it.
Note: This method produces a stable sort: equal elements in the sorted section will not be reordered as a result of the sort.
a - Key array to sort.fromIndex - First array element in the sorted section.toIndex - One past the last array element in the sorted section.parallel - Parallel array of values; this array gets rearranged in
parallel with the sorted array, but no comparisons are done on this
array. This array must have at least as many elements in it as the
toIndex parameter.ArrayIndexOutOfBoundsException - If the fromIndex parameter is less than 0, or
toIndex is greater than the length of the array.IllegalArgumentException - If the fromIndex parameter is greater
than the toIndex parameter.
public static void sort(long[] a,
int fromIndex,
int toIndex,
Object[] parallel)
This method sorts two parallel; comparison checking is done on the first, key array; the parallel value array is rearranged symmetrically with the key array, but this method does no comparison checking on it.
Note: This method produces a stable sort: equal elements in the sorted section will not be reordered as a result of the sort.
a - Key array to sort.fromIndex - First array element in the sorted section.toIndex - One past the last array element in the sorted section.parallel - Parallel array of values; this array gets rearranged in
parallel with the sorted array, but no comparisons are done on this
array. This array must have at least as many elements in it as the
toIndex parameter.ArrayIndexOutOfBoundsException - If the fromIndex parameter is less than 0, or
toIndex is greater than the length of the array.IllegalArgumentException - If the fromIndex parameter is greater
than the toIndex parameter.
public static void sort(long[] a,
int fromIndex,
int toIndex,
int[] parallel)
This method sorts two parallel; comparison checking is done on the first, key array; the parallel value array is rearranged symmetrically with the key array, but this method does no comparison checking on it.
Note: This method produces a stable sort: equal elements in the sorted section will not be reordered as a result of the sort.
a - Key array to sort.fromIndex - First array element in the sorted section.toIndex - One past the last array element in the sorted section.parallel - Parallel array of values; this array gets rearranged in
parallel with the sorted array, but no comparisons are done on this
array. This array must have at least as many elements in it as the
toIndex parameter.ArrayIndexOutOfBoundsException - If the fromIndex parameter is less than 0, or
toIndex is greater than the length of the array.IllegalArgumentException - If the fromIndex parameter is greater
than the toIndex parameter.
public static int binarySearch(int[] a,
int key)
Note: This method expects to be passed a sorted array; if the array is not sorted, then this method returns an undefined result. Also, if the key is not unique within the array, then this method may return the index of any one of the matching elements; there is no guarantee which one it will return.
a - Array to search; must be sorted in ascending order (as if with
sort).key - Value to look for.(-(insertPoint + 1); the insert point is the
position the key would occupy in the array.
public static int binarySearch(int[] a,
int key,
int fromIndex,
int toIndex)
Note: This method expects to be passed an array where the section to be searched is sorted; if this section is not sorted, then this method returns an undefined result. Also, if the key is not unique within the section to search, then this method may return the index of any one of the matching elements; there is no guarantee which one it will return.
a - Array to search; section to search must be sorted in ascending
order (as if with sort).key - Value to look for.fromIndex - First element in section to search.toIndex - One past the last element to search.(-(insertPoint + 1); the insert point is the
position the key would occupy in the section to search.
public static int binarySearch(long[] a,
long key,
int fromIndex,
int toIndex)
Note: This method expects to be passed an array where the section to be searched is sorted; if this section is not sorted, then this method returns an undefined result. Also, if the key is not unique within the section to search, then this method may return the index of any one of the matching elements; there is no guarantee which one it will return.
a - Array to search; section to search must be sorted in ascending
order (as if with sort).key - Value to look for.fromIndex - First element in section to search.toIndex - One past the last element to search.(-(insertPoint + 1); the insert point is the
position the key would occupy in the section to search. public static int binarySearch(Object[] a, Object key, Comparator c, int fromIndex, int toIndex)
Note: This method expects to be passed an array where the section to be searched is sorted; if this section is not sorted, then this method returns an undefined result. Also, if the key is not unique within the section to search, then this method may return the index of any one of the matching elements; there is no guarantee which one it will return.
a - Array to search; section to search must be sorted in ascending
order (as if with sort).key - Value to look for.comparator - Comparator used for comparisons during the sort; note
that both the key and the elements of the array section to search must be
comparable with this comparator.fromIndex - First element in section to search.toIndex - One past the last element to search.(-(insertPoint + 1); the insert point is the
position the key would occupy in the section to search. public static byte[] copy(byte[] array)
array - Array to copy.public static char[] copy(char[] array)
array - Array to copy.public static short[] copy(short[] array)
array - Array to copy.public static int[] copy(int[] array)
array - Array to copy.public static long[] copy(long[] array)
array - Array to copy.
public static byte[] copy(byte[] array,
int offset,
int length)
array - Array from which to copy section.offset - First element to copy.length - Number of elements to copy.IllegalArgumentException - If array cannot contain section
(that is, the offset is outside the bounds of the array, or if the offset
plus the length is greater than the size of the array).
public static char[] copy(char[] array,
int offset,
int length)
array - Array from which to copy section.offset - First element to copy.length - Number of elements to copy.IllegalArgumentException - If array cannot contain section
(that is, the offset is outside the bounds of the array, or if the offset
plus the length is greater than the size of the array).
public static short[] copy(short[] array,
int offset,
int length)
array - Array from which to copy section.offset - First element to copy.length - Number of elements to copy.IllegalArgumentException - If array cannot contain section
(that is, the offset is outside the bounds of the array, or if the offset
plus the length is greater than the size of the array).
public static int[] copy(int[] array,
int offset,
int length)
array - Array from which to copy section.offset - First element to copy.length - Number of elements to copy.IllegalArgumentException - If array cannot contain section
(that is, the offset is outside the bounds of the array, or if the offset
plus the length is greater than the size of the array).public static int getIndex(Object[] array, Object object)
.equals().array - The array of objects being managed.object - The object to locate in the array.public static void remove(Object[] array, Object object)
array - The array of objects being managed.object - The object to remove.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2002 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.