net.rim.device.api.util
Class Arrays

java.lang.Object
  |
  +--net.rim.device.api.util.Arrays

public final class Arrays
extends Object

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, IntComparator c, int fromIndex, int toIndex)
          Finds key in section of integer array using binary search with the provided comparator.
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 int binarySearch(short[] a, short key)
          Finds key in short array using binary search.
static boolean contains(Object[] array, Object object)
          Determine if the specified element is present.
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(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(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(long[] array, long element)
          Locates a specified element in provided long integer array.
static int getIndex(Object[] array, Object object)
          Retrieves 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, 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, 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, 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 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, long[] parallel, Comparator comparator)
          Sorts object array and a parallel long 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 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


binarySearch

public static int binarySearch(int[] a,
                               int key)
Finds key in integer array using binary search.

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.

Parameters:
a - Array to search; must be sorted in ascending order (as if with sort).
key - Value to look for.
Returns:
Index of the search key, if contained in the array. If the key is not contained in the list, then this method returns (-(insertPoint + 1); the insert point is the position the key would occupy in the array.

binarySearch

public 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.

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.

Parameters:
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.
Returns:
Index of the search key, if contained in the array. If the key is not contained in the list, then this method returns (-(insertPoint + 1); the insert point is the position the key would occupy in the section to search.
Note: This may not be the appropriate placement within the entire array!
Since:
JDE 4.2.1

binarySearch

public static int binarySearch(int[] a,
                               int key,
                               int fromIndex,
                               int toIndex)
Finds key in section of integer array using binary search.

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.

Parameters:
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.
Returns:
Index of the search key, if contained in the array. If the key is not contained in the list, then this method returns (-(insertPoint + 1); the insert point is the position the key would occupy in the section to search.
Note: This may not be the appropriate placement within the entire array!

binarySearch

public static int binarySearch(long[] a,
                               long key,
                               int fromIndex,
                               int toIndex)
Finds key in section of long integer array using binary search.

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.

Parameters:
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.
Returns:
Index of the search key, if contained in the array. If the key is not contained in the list, then this method returns (-(insertPoint + 1); the insert point is the position the key would occupy in the section to search.
Note: This may not be the appropriate placement within the entire array!

binarySearch

public 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.

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.

Parameters:
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.
Returns:
Index of the search key, if contained in the array. If the key is not contained in the list, then this method returns (-(insertPoint + 1); the insert point is the position the key would occupy in the section to search.
Note: This may not be the appropriate placement within the entire array!

binarySearch

public static int binarySearch(short[] a,
                               short key)
Finds key in short array using binary search.

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.

Parameters:
a - Array to search; must be sorted in ascending order.
key - Value to look for.
Returns:
Index of the search key, if contained in the array. If the key is not contained in the list, then this method returns (-(insertPoint + 1); the insert point is the position the key would occupy in the array.
Since:
JDE 4.1.0

contains

public static boolean contains(Object[] array,
                               Object object)
Determine if the specified element is present.

Locating the element uses Object.equals(Object).

Parameters:
array - Array of objects being managed.
object - Object to locate in the array.
Returns:
True if the specified element is present in the array.
Since:
JDE 4.0.0

copy

public static byte[] copy(byte[] array)
Retrieves a duplicate copy of a byte array.
Parameters:
array - Array to copy.
Returns:
Copy of array.

copy

public static byte[] copy(byte[] array,
                          int offset,
                          int length)
Retrieves a duplicate copy of a section from a byte array.
Parameters:
array - Array from which to copy section.
offset - First element to copy.
length - Number of elements to copy.
Returns:
Copy of array section.
Throws:
IndexOutOfBoundsException - If copying would cause access of data outside the array bounds.

copy

public static char[] copy(char[] array)
Retrieves a duplicate copy of a character array.
Parameters:
array - Array to copy.
Returns:
Copy of array.

copy

public static char[] copy(char[] array,
                          int offset,
                          int length)
Retrieves a duplicate copy of a section from a character array.
Parameters:
array - Array from which to copy section.
offset - First element to copy.
length - Number of elements to copy.
Returns:
Copy of array section.
Throws:
IndexOutOfBoundsException - If copying would cause access of data outside the array bounds.

copy

public static int[] copy(int[] array)
Retrieves a duplicate copy of an integer array.
Parameters:
array - Array to copy.
Returns:
Copy of array.

copy

public static int[] copy(int[] array,
                         int offset,
                         int length)
Retrieves a duplicate copy of a section from an integer array.
Parameters:
array - Array from which to copy section.
offset - First element to copy.
length - Number of elements to copy.
Returns:
Copy of array section.
Throws:
IndexOutOfBoundsException - If copying would cause access of data outside the array bounds.

copy

public static long[] copy(long[] array)
Retrieves a duplicate copy of a long integer array.
Parameters:
array - Array to copy.
Returns:
Copy of array.

copy

public static long[] copy(long[] array,
                          int offset,
                          int length)
Retrieves a duplicate copy of a section from a long integer array.
Parameters:
array - Array from which to copy section.
offset - First element to copy.
length - Number of elements to copy.
Returns:
Copy of array section.
Throws:
IndexOutOfBoundsException - If copying would cause access of data outside the array bounds.

copy

public static short[] copy(short[] array)
Retrieves a duplicate copy of short integer arary.
Parameters:
array - Array to copy.
Returns:
Copy of array.

copy

public static short[] copy(short[] array,
                           int offset,
                           int length)
Retrieves a duplicate copy of a section from a short integer array.
Parameters:
array - Array from which to copy section.
offset - First element to copy.
length - Number of elements to copy.
Returns:
Copy of array section.
Throws:
IndexOutOfBoundsException - If copying would cause access of data outside the array bounds.

equals

public static boolean equals(byte[] a,
                             byte[] a2)
Determines if two byte arrays are equal.

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.

Parameters:
a - First byte array.
a2 - Second byte array.
Returns:
True if the arrays are equal; otherwise, false.

equals

public static boolean equals(byte[] a,
                             int aOffset,
                             byte[] a2,
                             int a2Offset,
                             int length)
Determines if the substrings of two byte arrays are equal.

This method uses the same test for equivalency as equals(byte[],byte[]); simply consider the substrings to be the two arrays to compare.

Parameters:
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.
Returns:
True if the substrings from the arrays are equal; otherwise, false.

equals

public static boolean equals(char[] a,
                             char[] a2)
Determines if two character arrays are equal.

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.

Parameters:
a - First array.
a2 - Second array.
Returns:
True if the arrays are equal; otherwise, false.
Since:
JDE 3.6.0

equals

public static boolean equals(char[] a,
                             int aOffset,
                             char[] a2,
                             int a2Offset,
                             int length)
Determines if the substrings of two character arrays are equal.

Two arrays are considered equal if their substrings are equal. Two null arrays are considered equal.

Parameters:
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.
Returns:
True if the substrings from the arrays are equal; otherwise, false.
Since:
JDE 4.1.0

equals

public static boolean equals(int[] a,
                             int[] a2)
Determines if two integer arrays are equal.

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.

Parameters:
a - First array.
a2 - Second array.
Returns:
True if the arrays are equal; otherwise, false.

equals

public static boolean equals(long[] a,
                             long[] a2)
Determines if two long integer arrays are equal.

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.

Parameters:
a - First array.
a2 - Second array.
Returns:
True if the arrays are equal; otherwise, false.

equals

public static boolean equals(Object[] a,
                             Object[] a2)
Determines if two object arrays are equal.

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.

Parameters:
a - First array.
a2 - Second array.
Returns:
True if the arrays are equal; otherwise, false.

equals

public static boolean equals(short[] a,
                             short[] a2)
Determines if two short arrays are equal.

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.

Parameters:
a - First array.
a2 - Second array.
Returns:
True if the arrays are equal; otherwise, false.
Since:
JDE 3.6.0

fill

public static void fill(byte[] array,
                        byte element)
Fills byte array with provided element.

This method overwrites each element in the array with a copy of your provided element.

Parameters:
array - Array to fill.
element - Element to initialize array with.

fill

public static void fill(byte[] array,
                        byte element,
                        int offset,
                        int length)
Fills a range in byte array with provided element.

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.

Parameters:
array - Array to fill.
element - Element to initialize array with.
offset - The initial position of the data to fill within the array.
length - The length of data to fill within the array.
Since:
JDE 3.6.0

fill

public static void fill(char[] array,
                        char element)
Fills character array with provided element.

This method overwrites each element in the array with a copy of your provided element.

Parameters:
array - Array to fill.
element - Element to initialize array with.

fill

public static void fill(char[] array,
                        char element,
                        int offset,
                        int length)
Fills character array with provided element.

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.

Parameters:
array - Array to fill.
element - Element to initialize array with.
offset - The initial position of the data to fill within the array.
length - The length of the data to fill within the array.
Since:
JDE 3.6.0

fill

public static void fill(int[] array,
                        int element)
Fills integer array with provided element.

This method overwrites each element in the array with a copy of your provided element.

Parameters:
array - Array to fill.
element - Element to initialize array with.

fill

public static void fill(int[] array,
                        int element,
                        int offset,
                        int length)
Fills integer array with provided element.

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.

Parameters:
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.
Since:
JDE 3.6.0

fill

public static void fill(long[] array,
                        long element)
Fills long integer array with provided element.

This method overwrites each element in the array with a copy of your provided element.

Parameters:
array - Array to fill.
element - Element to initialize array with.

fill

public static void fill(long[] array,
                        long element,
                        int offset,
                        int length)
Fills long integer array with provided element.

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.

Parameters:
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.
Since:
JDE 3.6.0

fill

public static void fill(short[] array,
                        short element)
Fills short integer array with provided element.

This method overwrites each element in the array with a copy of your provided element.

Parameters:
array - Array to fill.
element - Element to initialize array with.

fill

public static void fill(short[] array,
                        short element,
                        int offset,
                        int length)
Fills short integer array with provided element.

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.

Parameters:
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.
Since:
JDE 3.6.0

getIndex

public static int getIndex(byte[] array,
                           byte element)
Locates a specified element in provided byte array.
Parameters:
array - Array that could contain element.
element - Element to look for.
Returns:
Index of element in provided array; or -1 if element not in array at all.
Since:
JDE 4.0.0

getIndex

public static int getIndex(char[] array,
                           char element)
Locates a specified element in provided character array.
Parameters:
array - Array that could contain element.
element - Element to look for.
Returns:
Index of element in provided array; or -1 if element not in array at all.
Since:
JDE 4.0.0

getIndex

public static int getIndex(int[] array,
                           int element)
Locates a specified element in provided integer array.
Parameters:
array - Array that could contain element.
element - Element to look for.
Returns:
Index of element in provided array; or -1 if element not in array at all.
Since:
JDE 4.0.0

getIndex

public static int getIndex(long[] array,
                           long element)
Locates a specified element in provided long integer array.
Parameters:
array - Array that could contain element.
element - Element to look for.
Returns:
Index of element in provided array; or -1 if element not in array at all.
Since:
JDE 4.0.0

getIndex

public static int getIndex(Object[] array,
                           Object object)
Retrieves the index of the specified element.

Locating the element uses Object.equals(Object).

Parameters:
array - Array of objects being managed.
object - Object to locate in the array.
Returns:
The index of the element, or -1 if it wasn't found.

remove

public static void remove(Object[] array,
                          Object object)
Remove an element from the array.
Parameters:
array - Array of objects being managed.
object - Object to remove.

sort

public static void sort(int[] a,
                        int fromIndex,
                        int toIndex)
Sorts section of integer array in ascending order.

Note: This method produces a stable sort: equal elements in the sorted section will not be reordered as a result of the sort.

Parameters:
a - Array to sort.
fromIndex - First array element in the sorted section.
toIndex - One past the last array element in the sorted section.
Throws:
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.

sort

public static void sort(int[] a,
                        int fromIndex,
                        int toIndex,
                        byte[] parallel)
Sorts a integer key array and a parallel byte array in ascending order.

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.

Parameters:
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.
Throws:
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.
Since:
JDE 4.0.0

sort

public static void sort(int[] a,
                        int fromIndex,
                        int toIndex,
                        int[] parallel)
Sorts a integer key array and a parallel integer array in ascending order.

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.

Parameters:
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.
Throws:
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.
Since:
JDE 4.2.0

sort

public static void sort(int[] a,
                        int fromIndex,
                        int toIndex,
                        IntComparator c)
Sorts section of integer array in ascending order using a comparator.

Note: This method produces a stable sort: equal elements in the sorted section will not be reordered as a result of the sort.

Parameters:
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.
Throws:
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.
Since:
JDE 3.6.0

sort

public static void sort(int[] a,
                        int fromIndex,
                        int toIndex,
                        Object[] parallel)
Sorts an integer key array and a parallel object array in ascending order.

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.

Parameters:
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.
Throws:
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.

sort

public static void sort(long[] a,
                        int fromIndex,
                        int toIndex)
Sorts section of long integer array in ascending order.

Note: This method produces a stable sort: equal elements in the sorted section will not be reordered as a result of the sort.

Parameters:
a - Array to sort.
fromIndex - First array element in the sorted section.
toIndex - One past the last array element in the sorted section.
Throws:
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.

sort

public 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.

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.

Parameters:
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.
Throws:
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.
Since:
JDE 4.0.0

sort

public 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.

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.

Parameters:
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.
Throws:
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.

sort

public 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.

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.

Parameters:
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.
Throws:
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.

sort

public static void sort(Object[] a,
                        Comparator c)
Sorts object array with provided comparator.

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.

Parameters:
a - Array to sort; all elements in this array must be sortable with the comparator.
c - Comparator used for comparisons during the sort.
Throws:
ClassCastException - If the array contains elements which aren't mutually comparable with the provided comparator.

sort

public static void sort(Object[] a,
                        int fromIndex,
                        int toIndex,
                        Comparator c)
Sorts section of object array with provided comparator.

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.

Parameters:
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.
Throws:
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.

sort

public static void sort(Object[] a,
                        int fromIndex,
                        int toIndex,
                        long[] parallel,
                        Comparator comparator)
Sorts object array and a parallel long array with provided 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.

Parameters:
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.
Throws:
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.
Since:
JDE 4.0.0

sort

public static void sort(Object[] a,
                        int fromIndex,
                        int toIndex,
                        Object[] parallel,
                        Comparator comparator)
Sorts sections of two parallel object arrays with provided 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.

Parameters:
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.
Throws:
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.

sum

public static int sum(byte[] array,
                      int offset,
                      int length,
                      boolean signed)
Sums the elements of an array.
Parameters:
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).
Throws:
ArrayIndexOutOfBoundsException - Thrown if the offset or length are not valid.
NullPointerException - Thrown if the array is null and length is non-zero.
Since:
JDE 4.0.0

zero

public static void zero(byte[] array)
Fills byte array with zeros.
Parameters:
array - Array to zero.

zero

public static void zero(char[] array)
Fills character array with zeros.
Parameters:
array - Array to zero.

zero

public static void zero(int[] array)
Fills integer array with zeros.
Parameters:
array - Array to zero.

zero

public static void zero(long[] array)
Fills long integer array with zeros.
Parameters:
array - Array to zero.

zero

public static void zero(short[] array)
Fills short integer array with zeros.
Parameters:
array - Array to zero.


Copyright 1999-2007 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.