|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.util.Arrays
public final class Arrays
Provides a host of utility functions for manipulating arrays.
Method Summary | ||
---|---|---|
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(int[] a,
int key,
IntComparator c,
int fromIndex,
int toIndex)
Finds key in section of integer array using binary search with the provided comparator. |
|
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 int |
binarySearch(long[] a,
long key,
int fromIndex,
int toIndex)
Finds key in section of long integer array using binary search. |
|
static int |
binarySearch(short[] a,
short key)
Finds key in short array using binary search. |
|
static boolean |
contains(byte[] array,
byte element)
Determine if the specified element is present. |
|
static boolean |
contains(char[] array,
char element)
Determine if the specified element is present. |
|
static boolean |
contains(int[] array,
int element)
Determine if the specified element is present. |
|
static boolean |
contains(Object[] array,
Object object)
Determine if the specified element is present. |
|
static boolean |
contains(long[] array,
long element)
Determine if the specified element is present. |
|
static boolean[] |
copy(boolean[] array)
Retrieves a duplicate copy of a boolean array. |
|
static boolean[] |
copy(boolean[] array,
int offset,
int length)
Retrieves a duplicate copy of a section from a boolean array. |
|
static byte[] |
copy(byte[] array)
Retrieves a duplicate copy of a byte array. |
|
static byte[] |
copy(byte[] array,
int offset,
int length)
Retrieves a duplicate copy of a section from a byte array. |
|
static char[] |
copy(char[] array)
Retrieves a duplicate copy of a character array. |
|
static char[] |
copy(char[] array,
int offset,
int length)
Retrieves a duplicate copy of a section from a character array. |
|
static int[] |
copy(int[] array)
Retrieves a duplicate copy of an integer array. |
|
static int[] |
copy(int[] array,
int offset,
int length)
Retrieves a duplicate copy of a section from an integer array. |
|
static long[] |
copy(long[] array)
Retrieves a duplicate copy of a long integer array. |
|
static long[] |
copy(long[] array,
int offset,
int length)
Retrieves a duplicate copy of a section from a long integer array. |
|
static short[] |
copy(short[] array)
Retrieves a duplicate copy of short integer arary. |
|
static short[] |
copy(short[] array,
int offset,
int length)
Retrieves 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(char[] a,
int aOffset,
char[] a2,
int a2Offset,
int length)
Determines if the substrings of two character arrays are equal. |
|
static boolean |
equals(int[] a,
int[] a2)
Determines if two integer arrays are equal. |
|
static boolean |
equals(Object[] a,
Object[] a2)
Determines if two object arrays are equal. |
|
static boolean |
equals(long[] a,
long[] a2)
Determines if two long integer arrays are equal. |
|
static boolean |
equals(short[] a,
short[] a2)
Determines if two short arrays are equal. |
|
static void |
fill(boolean[] array,
boolean element)
Fills boolean array with provided element. |
|
static void |
fill(boolean[] array,
boolean element,
int offset,
int length)
Fills a range in boolean array with provided element. |
|
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(byte[] array,
byte element)
Locates a specified element in provided byte array. |
|
static int |
getIndex(char[] array,
char element)
Locates a specified element in provided character array. |
|
static int |
getIndex(int[] array,
int element)
Locates a specified element in provided integer array. |
|
static int |
getIndex(Object[] array,
Object object)
Retrieves the index of the specified element. |
|
static int |
getIndex(long[] array,
long element)
Locates a specified element in provided long integer array. |
|
static void |
remove(Object[] array,
Object object)
Remove an element from the array. |
|
static void |
sort(byte[] a,
int fromIndex,
int toIndex,
char[] parallel)
Sorts a byte key array and a parallel char array in ascending order. |
|
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,
byte[] parallel)
Sorts a integer key array and a parallel byte array in ascending order. |
|
static void |
sort(int[] a,
int fromIndex,
int toIndex,
int[] parallel)
Sorts a integer key array and a parallel integer array in ascending order. |
|
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(int[] a,
int fromIndex,
int toIndex,
IntComparator c)
Sorts section of integer array in ascending order using a 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 |
sort(Object[] a,
int fromIndex,
int toIndex,
long[] parallel,
Comparator comparator)
Sorts object array and a parallel long 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,
Comparator c)
Sorts object array with provided comparator. |
|
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,
byte[] parallel)
Sorts a long integer key array and a parallel byte 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 int |
sum(byte[] array,
int offset,
int length,
boolean signed)
Sums the elements of an array. |
|
static void |
zero(byte[] array)
Fills byte array with zeros. |
|
static void |
zero(char[] array)
Fills character array with zeros. |
|
static void |
zero(int[] array)
Fills integer array with zeros. |
|
static void |
zero(long[] array)
Fills long integer array with zeros. |
|
static void |
zero(short[] array)
Fills short integer array with zeros. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean[] copy(boolean[] array)
array
- Array to copy.
public static boolean[] copy(boolean[] 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 specified length is less than zero.
IndexOutOfBoundsException
- If copying would cause access of data
outside the array bounds.public static byte[] copy(byte[] 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 specified length is less than zero.
IndexOutOfBoundsException
- If copying would cause access of data
outside the array bounds.public static char[] copy(char[] array)
array
- Array to copy.
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 specified length is less than zero.
IndexOutOfBoundsException
- If copying would cause access of data
outside the array bounds.public static int[] copy(int[] array)
array
- Array to copy.
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 specified length is less than zero.
IndexOutOfBoundsException
- If copying would cause access of data
outside the array bounds.public static long[] copy(long[] array)
array
- Array to copy.
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 specified length is less than zero.
IndexOutOfBoundsException
- If copying would cause access of data
outside the array bounds.public static short[] copy(short[] array)
array
- Array to copy.
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 specified length is less than zero.
IndexOutOfBoundsException
- If copying would cause access of data
outside the array bounds.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.
IllegalArgumentException
- If specified array is null.public static void fill(byte[] array, byte element, int offset, int length)
This method overwrites the specified elements (the elements specified by the offset and length parameters) in the array with a copy of your provided element.
array
- Array to fill.element
- Element to initialize array with.offset
- The initial position of the data to fill within the array.length
- The amount of data to fill within the array; the array size is used if length is negative.
IllegalArgumentException
- If specified array is null.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.
IllegalArgumentException
- If specified array is null.public static void fill(char[] array, char element, int offset, int length)
This method overwrites the specified elements (the elements specified by the offset and length parameters) in the array with a copy of your provided element.
array
- Array to fill.element
- Element to initialize array with.offset
- The initial position of the data to fill within the array.length
- The amount of data to fill within the array; the array size is used if length is negative.
IllegalArgumentException
- If specified array is null.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.
IllegalArgumentException
- If specified array is null.public static void fill(int[] array, int element, int offset, int length)
This method overwrites the specified elements (the elements specified by the offset and length parameters) in the array with a copy of your provided element.
array
- Array to fill.element
- Element to initialize array with.offset
- The initial position of the data to fill within the array.length
- The amount of data to fill within the array; the array size is used if length is negative.
IllegalArgumentException
- If specified array is null.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.
IllegalArgumentException
- If specified array is null.public static void fill(short[] array, short element, int offset, int length)
This method overwrites the specified elements (the elements specified by the offset and length parameters) in the array with a copy of your provided element.
array
- Array to fill.element
- Element to initialize array with.offset
- The initial position of the data to fill within the array.length
- The amount of data to fill within the array; the array size is used if length is negative.
IllegalArgumentException
- If specified array is null.public static void fill(boolean[] array, boolean 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.
IllegalArgumentException
- If specified array is null.public static void fill(boolean[] array, boolean element, int offset, int length)
This method overwrites the specified elements (the elements specified by the offset and length parameters) in the array with a copy of your provided element.
array
- Array to fill.element
- Element to initialize array with.offset
- The initial position of the data to fill within the array.length
- The amount of data to fill within the array; the array size is used if length is negative.
IllegalArgumentException
- If specified array is null.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.
IllegalArgumentException
- If specified array is null.public static void fill(long[] array, long element, int offset, int length)
This method overwrites the specified elements (the elements specified by the offset and length parameters) in the array with a copy of your provided element.
array
- Array to fill.element
- Element to initialize array with.offset
- The initial position of the data to fill within the array.length
- The amount of data to fill within the array; the array size is used if length is negative.
IllegalArgumentException
- If specified array is null.public static int sum(byte[] array, int offset, int length, boolean signed)
array
- A byte array containing the elements to sum.offset
- The initial position of the data within the array.length
- The number of positions in the array to include in the sum.signed
- A boolean indicating whether or not the data is
signed (true indicates signed, false indicates unsigned).
ArrayIndexOutOfBoundsException
- Thrown if the offset or length are
not valid.
NullPointerException
- Thrown if the array is null and length is
non-zero.public static void zero(byte[] array)
array
- Array to zero.
IllegalArgumentException
- If specified array is null.public static void zero(char[] array)
array
- Array to zero.
IllegalArgumentException
- If specified array is null.public static void zero(int[] array)
array
- Array to zero.
IllegalArgumentException
- If specified array is null.public static void zero(long[] array)
array
- Array to zero.
IllegalArgumentException
- If specified array is null.public static void zero(short[] array)
array
- Array to zero.
IllegalArgumentException
- If specified array is null.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
Arrays.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(char[] a, int aOffset, char[] a2, int a2Offset, int length)
Two arrays are considered equal if their substrings are equal. Two null arrays are considered equal.
a
- First character array.aOffset
- First element of substring from first array.a2
- Second character array.a2Offset
- First element of substring from second array.length
- Length of substrings.
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(Object[] a, int fromIndex, int toIndex, long[] 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 void sort(long[] a, int fromIndex, int toIndex, byte[] 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(int[] a, int fromIndex, int toIndex, byte[] 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(int[] 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 void sort(byte[] a, int fromIndex, int toIndex, char[] 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(short[] a, short 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.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)
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. IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 || toIndex > a.length
public static int binarySearch(int[] a, int key, IntComparator c, int fromIndex, int toIndex)
Note: This method expects to be passed an array where the section to be searched is sorted by the comparator; if this section is not sorted, then this method returns an undefined result. Also, if the key is not unique (according to the supplied comparator) 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;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. NullPointerException
- if a
or c
is null.
IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 || toIndex > a.length
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. IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 || toIndex > a.length
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. IllegalArgumentException
- if fromIndex > toIndex
ArrayIndexOutOfBoundsException
- if fromIndex < 0 || toIndex > a.length
public static int getIndex(Object[] array, Object object)
Locating the element uses Object.equals(Object)
.
array
- Array of objects being managed.object
- Object to locate in the array.
public static boolean contains(Object[] array, Object object)
Locating the element uses Object.equals(Object)
.
array
- Array of objects being managed.object
- Object to locate in the array.
NullPointerException
- if array
is null
.public static boolean contains(int[] array, int element)
array
- Array of integers being managed.element
- Integer to locate in the array.
NullPointerException
- if array
is null
.public static boolean contains(long[] array, long element)
array
- Array of integers being managed.element
- Integer to locate in the array.
NullPointerException
- if array
is null
.public static boolean contains(char[] array, char element)
array
- Array of chars being managed.element
- Char to locate in the array.
NullPointerException
- if array
is null
.public static boolean contains(byte[] array, byte element)
array
- Array of bytes being managed.element
- Byte to locate in the array.
NullPointerException
- if array
is null
.public static void remove(Object[] array, Object object)
array
- Array of objects being managed.object
- Object to remove.public static int getIndex(int[] array, int element)
array
- Array that could contain element.element
- Element to look for.
public static int getIndex(byte[] array, byte element)
array
- Array that could contain element.element
- Element to look for.
public static int getIndex(char[] array, char element)
array
- Array that could contain element.element
- Element to look for.
public static int getIndex(long[] array, long element)
array
- Array that could contain element.element
- Element to look for.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal