Oracle Application Development Framework Model and Business Components Java API Reference 10g Release 3 (10.1.3)
B16005-01


oracle.jbo.server.java.util
Class Arrays

java.lang.Object
  extended byoracle.jbo.server.java.util.Arrays


public class Arrays
extends java.lang.Object

This class contains various methods for manipulating arrays (such as sorting and searching). It also contains a static factory that allows arrays to be viewed as Lists.

Since:
JDK1.2
See Also:
Comparable, Comparator

Constructor Summary
Arrays()
           

 

Method Summary
static int binarySearch(byte[] a, byte key)
          Searches the specified array of bytes for the specified value using the binary search algorithm.
static int binarySearch(char[] a, char key)
          Searches the specified array of chars for the specified value using the binary search algorithm.
static int binarySearch(double[] a, double key)
          Searches the specified array of doubles for the specified value using the binary search algorithm.
static int binarySearch(float[] a, float key)
          Searches the specified array of floats for the specified value using the binary search algorithm.
static int binarySearch(int[] a, int key)
          Searches the specified array of ints for the specified value using the binary search algorithm.
static int binarySearch(long[] a, long key)
          Searches the specified array of longs for the specified value using the binary search algorithm.
static int binarySearch(java.lang.Object[] a, java.lang.Object key)
          Searches the specified array for the specified Object using the binary search algorithm.
static int binarySearch(java.lang.Object[] a, java.lang.Object key, Comparator c)
          Searches the specified array for the specified Object using the binary search algorithm.
static int binarySearch(short[] a, short key)
          Searches the specified array of shorts for the specified value using the binary search algorithm.
static void sort(byte[] a)
          Sorts the specified array of bytes into ascending numerical order.
static void sort(char[] a)
          Sorts the specified array of chars into ascending numerical order.
static void sort(double[] a)
          Sorts the specified array of doubles into ascending numerical order.
static void sort(float[] a)
          Sorts the specified array of floats into ascending numerical order.
static void sort(int[] a)
          Sorts the specified array of ints into ascending numerical order.
static void sort(long[] a)
          Sorts the specified array of longs into ascending numerical order.
static void sort(java.lang.Object[] a)
          Sorts the specified array of objects into ascending order, according to the natural comparison method of its elements.
static void sort(java.lang.Object[] a, Comparator c)
          Sorts the specified array according to the order induced by the specified Comparator.
static void sort(short[] a)
          Sorts the specified array of shorts into ascending numerical order.
static List toList(java.lang.Object[] a)
          Returns a fixed-size List backed by the specified array.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

Arrays

public Arrays()

Method Detail

sort

public static void sort(long[] a)
Sorts the specified array of longs into ascending numerical order. The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
Since:
JDK1.2

sort

public static void sort(int[] a)
Sorts the specified array of ints into ascending numerical order. The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
Since:
JDK1.2

sort

public static void sort(short[] a)
Sorts the specified array of shorts into ascending numerical order. The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
Since:
JDK1.2

sort

public static void sort(char[] a)
Sorts the specified array of chars into ascending numerical order. The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
Since:
JDK1.2

sort

public static void sort(byte[] a)
Sorts the specified array of bytes into ascending numerical order. The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
Since:
JDK1.2

sort

public static void sort(double[] a)
Sorts the specified array of doubles into ascending numerical order. The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
Since:
JDK1.2

sort

public static void sort(float[] a)
Sorts the specified array of floats into ascending numerical order. The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.
Since:
JDK1.2

sort

public static void sort(java.lang.Object[] a)
Sorts the specified array of objects into ascending order, according to the natural comparison method of its elements. All elements in the array must implement the Comparable interface. Furthermore, all elements in the array must be mutually comparable (that is, e1.compareTo(e2) must not throw a typeMismatchException for any elements e1 and e2 in the array).

The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.

Throws:
java.lang.ClassCastException - array contains elements that are not mutually comparable (for example, Strings and Integers).
Since:
JDK1.2
See Also:
Comparable

sort

public static void sort(java.lang.Object[] a,
                        Comparator c)
Sorts the specified array according to the order induced by the specified Comparator. All elements in the array must be mutually comparable by the specified comparator (that is, comparator.compare(e1, e2) must not throw a typeMismatchException for any elements e1 and e2 in the array).

The sorting algorithm is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.

Throws:
java.lang.ClassCastException - array contains elements that are not mutually comparable with the specified Comparator.
Since:
JDK1.2
See Also:
Comparator

binarySearch

public static int binarySearch(long[] a,
                               long key)
Searches the specified array of longs for the specified value using the binary search algorithm. The array must must be sorted (as by the sort method, above) prior to making this call. If it is not sorted, the results are undefined: in particular, the call may enter an infinite loop. If the array contains multiple elements equal to the specified object, there is no guarantee which instance will be found.
Returns:
index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1). The insertion point is defined as the the point at which the value would be inserted into the array: the index of the first element greater than the value, or a.length, if all elements in the array are less than the specified value. Note that this guarantees that the return value will be >= 0 if and only if the object is found.
Since:
JDK1.2
See Also:
sort(long[])

binarySearch

public static int binarySearch(int[] a,
                               int key)
Searches the specified array of ints for the specified value using the binary search algorithm. The array must must be sorted (as by the sort method, above) prior to making this call. If it is not sorted, the results are undefined: in particular, the call may enter an infinite loop. If the array contains multiple elements equal to the specified object, there is no guarantee which instance will be found.
Returns:
index of the search key, if it is contained in the array; otherwise, (-(the "insertion point") - 1).
Since:
JDK1.2
See Also:
sort(int[])

binarySearch

public static int binarySearch(short[] a,
                               short key)
Searches the specified array of shorts for the specified value using the binary search algorithm. The array must must be sorted (as by the sort method, above) prior to making this call. If it is not sorted, the results are undefined: in particular, the call may enter an infinite loop. If the array contains multiple elements equal to the specified object, there is no guarantee which instance will be found.
Returns:
index of the search key, if it is contained in the array; otherwise, (-(the "insertion point") - 1).
Since:
JDK1.2
See Also:
sort(short[])

binarySearch

public static int binarySearch(char[] a,
                               char key)
Searches the specified array of chars for the specified value using the binary search algorithm. The array must must be sorted (as by the sort method, above) prior to making this call. If it is not sorted, the results are undefined: in particular, the call may enter an infinite loop. If the array contains multiple elements equal to the specified object, there is no guarantee which instance will be found.
Returns:
index of the search key, if it is contained in the array; otherwise, (-(the "insertion point") - 1).
Since:
JDK1.2
See Also:
sort(char[])

binarySearch

public static int binarySearch(byte[] a,
                               byte key)
Searches the specified array of bytes for the specified value using the binary search algorithm. The array must must be sorted (as by the sort method, above) prior to making this call. If it is not sorted, the results are undefined: in particular, the call may enter an infinite loop. If the array contains multiple elements equal to the specified object, there is no guarantee which instance will be found.
Returns:
index of the search key, if it is contained in the array; otherwise, (-(the "insertion point") - 1).
Since:
JDK1.2
See Also:
sort(byte[])

binarySearch

public static int binarySearch(double[] a,
                               double key)
Searches the specified array of doubles for the specified value using the binary search algorithm. The array must must be sorted (as by the sort method, above) prior to making this call. If it is not sorted, the results are undefined: in particular, the call may enter an infinite loop. If the array contains multiple elements equal to the specified object, there is no guarantee which instance will be found.
Returns:
index of the search key, if it is contained in the array; otherwise, (-(the "insertion point") - 1).
Since:
JDK1.2
See Also:
sort(double[])

binarySearch

public static int binarySearch(float[] a,
                               float key)
Searches the specified array of floats for the specified value using the binary search algorithm. The array must must be sorted (as by the sort method, above) prior to making this call. If it is not sorted, the results are undefined: in particular, the call may enter an infinite loop. If the array contains multiple elements equal to the specified object, there is no guarantee which instance will be found.
Returns:
index of the search key, if it is contained in the array; otherwise, (-(the "insertion point") - 1).
Since:
JDK1.2
See Also:
sort(float[])

binarySearch

public static int binarySearch(java.lang.Object[] a,
                               java.lang.Object key)
Searches the specified array for the specified Object using the binary search algorithm. The array must be sorted into ascending order according to the natural comparison method of its elements (as by Sort(Object[]), above) prior to making this call. The array must must be sorted (as by the sort method, above) prior to making this call. If it is not sorted, the results are undefined: in particular, the call may enter an infinite loop. If the array contains multiple elements equal to the specified object, there is no guarantee which instance will be found.
Throws:
java.lang.ClassCastException - array contains elements that are not mutually comparable (for example, Strings and Integers), or the search key in not mutually comparable with the elements of the array.
Since:
JDK1.2
See Also:
Comparable, sort(Object[])

binarySearch

public static int binarySearch(java.lang.Object[] a,
                               java.lang.Object key,
                               Comparator c)
Searches the specified array for the specified Object using the binary search algorithm. The array must be sorted into ascending order according to the specified Comparator (as by Sort(Object[], Comparator), above), prior to making this call. If it is not sorted, the results are undefined: in particular, the call may enter an infinite loop. If the array contains multiple elements equal to the specified object, there is no guarantee which instance will be found.
Throws:
java.lang.ClassCastException - array contains elements that are not mutually comparable with the specified Comparator, or the search key in not mutually comparable with the elements of the array using this Comparator.
Since:
JDK1.2
See Also:
Comparable, sort(Object[], Comparator)

toList

public static List toList(java.lang.Object[] a)
Returns a fixed-size List backed by the specified array. (Changes to the returned List "write through" to the array.) This method acts as bridge between array-based and Collection-based APIs, in combination with Collection.toArray.
Since:
JDK1.2
See Also:
Collection.toArray()

Oracle Application Development Framework Model and Business Components Java API Reference 10g Release 3 (10.1.3)
B16005-01


Copyright © 1997, 2005, Oracle. All rights reserved.