|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.util.Arrays
public final class Arrays
Array utilities.
| Method Summary | |
|---|---|
static int |
binarySearch(int[] a,
int key)
Search the given presumed-sorted array for the given key. |
static int |
binarySearch(Object[] a,
Object key)
Search the given presumed-sorted array for the given key, using Comparable.compareTo() with the key as an argument, as
needed to perform a binary search. |
static int |
binarySearch(Object[] a,
Object key,
Comparator comp)
Search the given presumed-sorted array for the given key, using the given Comparator with the key as an argument, as needed
to perform a binary search. |
static void |
sort(int[] a)
Sort the given array. |
static void |
sort(int[] a,
int fromIndex,
int toIndex)
Sort a part of the given array. |
static void |
sort(Object[] a)
Sort the given array using Comparable.compareTo() on
elements as needed. |
static void |
sort(Object[] a,
Comparator comp)
Sort the given array using the given Comparator to
compare elements as needed. |
static void |
sort(Object[] a,
int fromIndex,
int toIndex)
Sort a part of the given array using Comparable.compareTo() on elements as needed. |
static void |
sort(Object[] a,
int fromIndex,
int toIndex,
Comparator comp)
Sort a part of the given array using the given Comparator on elements as needed. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void sort(Object[] a)
Comparable.compareTo() on
elements as needed. This method uses the merge sort algorithm except
on small arrays (for which it uses insertion sort), enhanced to
provide near-O(N) performance on mostly-presorted data. The
algorithm is stable, that is, equal elements will appear in the
result in the same order that they appeared originally.
a - non-null; the array to sort
public static void sort(Object[] a,
int fromIndex,
int toIndex)
Comparable.compareTo() on elements as needed. This
method uses the merge sort algorithm except on small arrays (for
which it uses insertion sort), enhanced to provide near-O(N)
performance on mostly-presorted data. The algorithm is stable, that
is, equal elements will appear in the result in the same order that
they appeared originally.
a - non-null; the array to sortfromIndex - the index of the first element to sorttoIndex - the index just past the last element to sort
public static void sort(Object[] a,
Comparator comp)
Comparator to
compare elements as needed. This method uses the merge sort
algorithm except on small arrays (for which it uses insertion sort),
enhanced to provide near-O(N) performance on mostly-presorted data.
The algorithm is stable, that is, equal elements will appear in the
result in the same order that they appeared originally.
a - non-null; the array to sortcomp - null-ok; the comparator to use, or null to
use Comparable.compareTo() instead of an explicit
comparator
public static void sort(Object[] a,
int fromIndex,
int toIndex,
Comparator comp)
Comparator on elements as needed. This method uses the
merge sort algorithm except on small arrays (for which it uses
insertion sort), enhanced to provide near-O(N) performance on
mostly-presorted data. The algorithm is stable, that is, equal
elements will appear in the result in the same order that they
appeared originally.
a - non-null; the array to sortfromIndex - the index of the first element to sorttoIndex - the index just past the last element to sortcomp - null-ok; the comparator to use, or null to
use Comparable.compareTo() instead of an explicit
comparatorpublic static void sort(int[] a)
a - non-null; the array to sort
public static void sort(int[] a,
int fromIndex,
int toIndex)
a - non-null; the array to sortfromIndex - the index of the first element to sorttoIndex - the index just past the last element to sort
public static int binarySearch(Object[] a,
Object key)
Comparable.compareTo() with the key as an argument, as
needed to perform a binary search. Return the index where the key
was found if it is found, or return ~indexToInsertAt if
it was not found. If there is more than one element equal to the
given key, then any such element may be indicated.
a - non-null; the array to search inkey - null-ok; the key to look for, which is always passed in
as an argument to Comparable.compareTo()
~insertionPoint if it was not found
public static int binarySearch(Object[] a,
Object key,
Comparator comp)
Comparator with the key as an argument, as needed
to perform a binary search. Return the index where the key was found
if it is found, or return ~indexToInsertAt if it was
not found. If there is more than one element equal to the given key,
then any such element may be indicated.
a - non-null; the array to search inkey - null-ok; the key to look for, which is always passed in
as the second argument to Comparator.compare()comp - null-ok; the comparator to use, or null to
use Comparable.compareTo() instead of an explicit
comparator
~insertionPoint if it was not found
public static int binarySearch(int[] a,
int key)
~indexToInsertAt if
it was not found. If there is more than one element equal to the
given key, then any such element may be indicated.
a - non-null; the array in which to searchkey - null-ok; the key to look for
~insertionPoint if it was not found
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||