This class contains various methods for manipulating arrays (such as
sorting and searching). This class also contains a static factory
that allows arrays to be viewed as lists.
The methods in this class all throw a NullPointerException if
the specified array reference is null, except where noted.
The documentation for the methods contained in this class includes
briefs description of the implementations. Such descriptions should
be regarded as implementation notes, rather than parts of the
specification. Implementors should feel free to substitute other
algorithms, so long as the specification itself is adhered to. (For
example, the algorithm used by sort(Object[]) does not have to be
a mergesort, but it does have to be stable.)
This class is a member of the
Java Collections Framework.
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. The returned list is
serializable and implements
RandomAccess
.
This method also provides a convenient way to create a fixed-size
list initialized to contain several elements:
List stooges = Arrays.asList("Larry", "Moe", "Curly");
Searches the specified array of bytes for the specified value using the
binary search algorithm. The array must be sorted (as
by the sort method, above) prior to making this call. If it
is not sorted, the results are undefined. If the array contains
multiple elements with the specified value, there is no guarantee which
one will be found.
Searches the specified array of chars for the specified value using the
binary search algorithm. The array must be sorted (as
by the sort method, above) prior to making this call. If it
is not sorted, the results are undefined. If the array contains
multiple elements with the specified value, there is no guarantee which
one will be found.
Searches the specified array of doubles for the specified value using
the binary search algorithm. The array must be sorted
(as by the sort method, above) prior to making this call. If
it is not sorted, the results are undefined. If the array contains
multiple elements with the specified value, there is no guarantee which
one will be found. This method considers all NaN values to be
equivalent and equal.
Searches the specified array of floats for the specified value using
the binary search algorithm. The array must be sorted
(as by the sort method, above) prior to making this call. If
it is not sorted, the results are undefined. If the array contains
multiple elements with the specified value, there is no guarantee which
one will be found. This method considers all NaN values to be
equivalent and equal.
Searches the specified array of ints for the specified value using the
binary search algorithm. The array must be sorted (as
by the sort method, above) prior to making this call. If it
is not sorted, the results are undefined. If the array contains
multiple elements with the specified value, there is no guarantee which
one will be found.
Searches the specified array of longs for the specified value using the
binary search algorithm. The array must be sorted (as
by the sort method, above) prior to making this call. If it
is not sorted, the results are undefined. If the array contains
multiple elements with the specified value, there is no guarantee which
one will be found.
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 ordering of its elements (as by
Sort(Object[]), above) prior to making this call. If it is
not sorted, the results are undefined.
(If the array contains elements that are not mutually comparable (for
example,strings and integers), it cannot be sorted according
to the natural order of its elements, hence results are undefined.)
If the array contains multiple
elements equal to the specified object, there is no guarantee which
one will be found.
Searches the specified array of shorts for the specified value using
the binary search algorithm. The array must be sorted
(as by the sort method, above) prior to making this call. If
it is not sorted, the results are undefined. If the array contains
multiple elements with the specified value, there is no guarantee which
one will be found.
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 the Sort(Object[],
Comparator) method, above), prior to making this call. If it is
not sorted, the results are undefined.
If the array contains multiple
elements equal to the specified object, there is no guarantee which one
will be found.
Returns
true if the two specified arrays are
deeply
equal to one another. Unlike the @link{#equals{Object[],Object[])
method, this method is appropriate for use with nested arrays of
arbitrary depth.
Two array references are considered deeply equal if both
are null, or if they refer to arrays that contain the same
number of elements and all corresponding pairs of elements in the two
arrays are deeply equal.
Two possibly null elements e1 and e2 are
deeply equal if any of the following conditions hold:
- e1 and e2 are both arrays of object reference
types, and Arrays.deepEquals(e1, e2) would return true
- e1 and e2 are arrays of the same primitive
type, and the appropriate overloading of
Arrays.equals(e1, e2) would return true.
- e1 == e2
- e1.equals(e2) would return true.
Note that this definition permits
null elements at any depth.
If either of the specified arrays contain themselves as elements
either directly or indirectly through one or more levels of arrays,
the behavior of this method is undefined.
Returns a hash code based on the "deep contents" of the specified
array. If the array contains other arrays as elements, the
hash code is based on their contents and so on, ad infinitum.
It is therefore unacceptable to invoke this method on an array that
contains itself as an element, either directly or indirectly through
one or more levels of arrays. The behavior of such an invocation is
undefined.
For any two arrays a and b such that
Arrays.deepEquals(a, b), it is also the case that
Arrays.deepHashCode(a) == Arrays.deepHashCode(b).
The computation of the value returned by this method is similar to
that of the value returned by
on a list
containing the same elements as a in the same order, with one
difference: If an element e of a is itself an array,
its hash code is computed not by calling e.hashCode(), but as
by calling the appropriate overloading of Arrays.hashCode(e)
if e is an array of a primitive type, or as by calling
Arrays.deepHashCode(e) recursively if e is an array
of a reference type. If a is null, this method
returns 0.
Returns a string representation of the "deep contents" of the specified
array. If the array contains other arrays as elements, the string
representation contains their contents and so on. This method is
designed for converting multidimensional arrays to strings.
The string representation consists of a list of the array's
elements, enclosed in square brackets ("[]"). Adjacent
elements are separated by the characters ", " (a comma
followed by a space). Elements are converted to strings as by
String.valueOf(Object), unless they are themselves
arrays.
If an element e is an array of a primitive type, it is
converted to a string as by invoking the appropriate overloading of
Arrays.toString(e). If an element e is an array of a
reference type, it is converted to a string as by invoking
this method recursively.
To avoid infinite recursion, if the specified array contains itself
as an element, or contains an indirect reference to itself through one
or more levels of arrays, the self-reference is converted to the string
"[...]". For example, an array containing only a reference
to itself would be rendered as "[[...]]".
This method returns "null" if the specified array
is null.
Returns
true if the two specified arrays of booleans are
equal to one another. Two arrays are considered equal if both
arrays contain the same number of elements, and all corresponding pairs
of elements in the two arrays are equal. In other words, two arrays
are equal if they contain the same elements in the same order. Also,
two array references are considered equal if both are
null.
Returns
true if the two specified arrays of bytes are
equal to one another. Two arrays are considered equal if both
arrays contain the same number of elements, and all corresponding pairs
of elements in the two arrays are equal. In other words, two arrays
are equal if they contain the same elements in the same order. Also,
two array references are considered equal if both are
null.
Returns
true if the two specified arrays of chars are
equal to one another. Two arrays are considered equal if both
arrays contain the same number of elements, and all corresponding pairs
of elements in the two arrays are equal. In other words, two arrays
are equal if they contain the same elements in the same order. Also,
two array references are considered equal if both are
null.
Returns
true if the two specified arrays of doubles are
equal to one another. Two arrays are considered equal if both
arrays contain the same number of elements, and all corresponding pairs
of elements in the two arrays are equal. In other words, two arrays
are equal if they contain the same elements in the same order. Also,
two array references are considered equal if both are
null.
Two doubles d1 and d2 are considered equal if:
new Double(d1).equals(new Double(d2))
(Unlike the
== operator, this method considers
NaN equals to itself, and 0.0d unequal to -0.0d.)
Returns
true if the two specified arrays of floats are
equal to one another. Two arrays are considered equal if both
arrays contain the same number of elements, and all corresponding pairs
of elements in the two arrays are equal. In other words, two arrays
are equal if they contain the same elements in the same order. Also,
two array references are considered equal if both are
null.
Two floats f1 and f2 are considered equal if:
new Float(f1).equals(new Float(f2))
(Unlike the
== operator, this method considers
NaN equals to itself, and 0.0f unequal to -0.0f.)
Returns
true if the two specified arrays of ints are
equal to one another. Two arrays are considered equal if both
arrays contain the same number of elements, and all corresponding pairs
of elements in the two arrays are equal. In other words, two arrays
are equal if they contain the same elements in the same order. Also,
two array references are considered equal if both are
null.
Returns
true if the two specified arrays of longs are
equal to one another. Two arrays are considered equal if both
arrays contain the same number of elements, and all corresponding pairs
of elements in the two arrays are equal. In other words, two arrays
are equal if they contain the same elements in the same order. Also,
two array references are considered equal if both are
null.
Indicates whether some other object is "equal to" this one.
The equals
method implements an equivalence relation
on non-null object references:
- It is reflexive: for any non-null reference value
x
, x.equals(x)
should return
true
.
- It is symmetric: for any non-null reference values
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
- It is transitive: for any non-null reference values
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
- It is consistent: for any non-null reference values
x
and y
, multiple invocations of
x.equals(y) consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
- For any non-null reference value
x
,
x.equals(null)
should return false
.
The equals method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode method, which states
that equal objects must have equal hash codes.
Returns
true if the two specified arrays of Objects are
equal to one another. The two arrays are considered equal if
both arrays contain the same number of elements, and all corresponding
pairs of elements in the two arrays are equal. Two objects
e1
and
e2 are considered
equal if
(e1==null ? e2==null
: e1.equals(e2)). In other words, the two arrays are equal if
they contain the same elements in the same order. Also, two array
references are considered equal if both are
null.
Returns
true if the two specified arrays of shorts are
equal to one another. Two arrays are considered equal if both
arrays contain the same number of elements, and all corresponding pairs
of elements in the two arrays are equal. In other words, two arrays
are equal if they contain the same elements in the same order. Also,
two array references are considered equal if both are
null.
Assigns the specified boolean value to each element of the specified
array of booleans.
Assigns the specified boolean value to each element of the specified
range of the specified array of booleans. The range to be filled
extends from index fromIndex, inclusive, to index
toIndex, exclusive. (If fromIndex==toIndex, the
range to be filled is empty.)
Assigns the specified byte value to each element of the specified array
of bytes.
Assigns the specified byte value to each element of the specified
range of the specified array of bytes. The range to be filled
extends from index fromIndex, inclusive, to index
toIndex, exclusive. (If fromIndex==toIndex, the
range to be filled is empty.)
Assigns the specified char value to each element of the specified array
of chars.
Assigns the specified char value to each element of the specified
range of the specified array of chars. The range to be filled
extends from index fromIndex, inclusive, to index
toIndex, exclusive. (If fromIndex==toIndex, the
range to be filled is empty.)
Assigns the specified double value to each element of the specified
array of doubles.
Assigns the specified double value to each element of the specified
range of the specified array of doubles. The range to be filled
extends from index fromIndex, inclusive, to index
toIndex, exclusive. (If fromIndex==toIndex, the
range to be filled is empty.)
Assigns the specified float value to each element of the specified array
of floats.
Assigns the specified float value to each element of the specified
range of the specified array of floats. The range to be filled
extends from index fromIndex, inclusive, to index
toIndex, exclusive. (If fromIndex==toIndex, the
range to be filled is empty.)
Assigns the specified int value to each element of the specified array
of ints.
Assigns the specified int value to each element of the specified
range of the specified array of ints. The range to be filled
extends from index fromIndex, inclusive, to index
toIndex, exclusive. (If fromIndex==toIndex, the
range to be filled is empty.)
Assigns the specified long value to each element of the specified
range of the specified array of longs. The range to be filled
extends from index fromIndex, inclusive, to index
toIndex, exclusive. (If fromIndex==toIndex, the
range to be filled is empty.)
Assigns the specified long value to each element of the specified array
of longs.
Assigns the specified Object reference to each element of the specified
range of the specified array of Objects. The range to be filled
extends from index fromIndex, inclusive, to index
toIndex, exclusive. (If fromIndex==toIndex, the
range to be filled is empty.)
Assigns the specified Object reference to each element of the specified
array of Objects.
Assigns the specified short value to each element of the specified
range of the specified array of shorts. The range to be filled
extends from index fromIndex, inclusive, to index
toIndex, exclusive. (If fromIndex==toIndex, the
range to be filled is empty.)
Assigns the specified short value to each element of the specified array
of shorts.
Returns the runtime class of an object. That Class
object is the object that is locked by static synchronized
methods of the represented class.
Returns a hash code value for the object. This method is
supported for the benefit of hashtables such as those provided by
java.util.Hashtable
.
The general contract of hashCode
is:
- Whenever it is invoked on the same object more than once during
an execution of a Java application, the hashCode method
must consistently return the same integer, provided no information
used in equals comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
- If two objects are equal according to the equals(Object)
method, then calling the
hashCode
method on each of
the two objects must produce the same integer result.
- It is not required that if two objects are unequal
according to the
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hashtables.
As much as is reasonably practical, the hashCode method defined by
class Object does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
JavaTM programming language.)
Returns a hash code based on the contents of the specified array.
For any two
boolean arrays
a and
b
such that
Arrays.equals(a, b), it is also the case that
Arrays.hashCode(a) == Arrays.hashCode(b).
The value returned by this method is the same value that would be
obtained by invoking the hashCode
method on a List
containing a sequence of Boolean
instances representing the elements of a in the same order.
If a is null, this method returns 0.
Returns a hash code based on the contents of the specified array.
For any two
byte arrays
a and
b
such that
Arrays.equals(a, b), it is also the case that
Arrays.hashCode(a) == Arrays.hashCode(b).
The value returned by this method is the same value that would be
obtained by invoking the hashCode
method on a List
containing a sequence of Byte
instances representing the elements of a in the same order.
If a is null, this method returns 0.
Returns a hash code based on the contents of the specified array.
For any two
char arrays
a and
b
such that
Arrays.equals(a, b), it is also the case that
Arrays.hashCode(a) == Arrays.hashCode(b).
The value returned by this method is the same value that would be
obtained by invoking the hashCode
method on a List
containing a sequence of Character
instances representing the elements of a in the same order.
If a is null, this method returns 0.
Returns a hash code based on the contents of the specified array.
For any two
double arrays
a and
b
such that
Arrays.equals(a, b), it is also the case that
Arrays.hashCode(a) == Arrays.hashCode(b).
The value returned by this method is the same value that would be
obtained by invoking the hashCode
method on a List
containing a sequence of Double
instances representing the elements of a in the same order.
If a is null, this method returns 0.
Returns a hash code based on the contents of the specified array.
For any two
float arrays
a and
b
such that
Arrays.equals(a, b), it is also the case that
Arrays.hashCode(a) == Arrays.hashCode(b).
The value returned by this method is the same value that would be
obtained by invoking the hashCode
method on a List
containing a sequence of Float
instances representing the elements of a in the same order.
If a is null, this method returns 0.
Returns a hash code based on the contents of the specified array.
For any two non-null
int arrays
a and
b
such that
Arrays.equals(a, b), it is also the case that
Arrays.hashCode(a) == Arrays.hashCode(b).
The value returned by this method is the same value that would be
obtained by invoking the hashCode
method on a List
containing a sequence of Integer
instances representing the elements of a in the same order.
If a is null, this method returns 0.
Returns a hash code based on the contents of the specified array.
For any two
long arrays
a and
b
such that
Arrays.equals(a, b), it is also the case that
Arrays.hashCode(a) == Arrays.hashCode(b).
The value returned by this method is the same value that would be
obtained by invoking the hashCode
method on a List
containing a sequence of Long
instances representing the elements of a in the same order.
If a is null, this method returns 0.
Returns a hash code based on the contents of the specified array. If
the array contains other arrays as elements, the hash code is based on
their identities rather than their contents. It is therefore
acceptable to invoke this method on an array that contains itself as an
element, either directly or indirectly through one or more levels of
arrays.
For any two arrays a and b such that
Arrays.equals(a, b), it is also the case that
Arrays.hashCode(a) == Arrays.hashCode(b).
The value returned by this method is equal to the value that would
be returned by Arrays.asList(a).hashCode(), unless a
is null, in which case 0 is returned.
Returns a hash code based on the contents of the specified array.
For any two
short arrays
a and
b
such that
Arrays.equals(a, b), it is also the case that
Arrays.hashCode(a) == Arrays.hashCode(b).
The value returned by this method is the same value that would be
obtained by invoking the hashCode
method on a List
containing a sequence of Short
instances representing the elements of a in the same order.
If a is null, this method returns 0.
Wakes up a single thread that is waiting on this object's
monitor. If any threads are waiting on this object, one of them
is chosen to be awakened. The choice is arbitrary and occurs at
the discretion of the implementation. A thread waits on an object's
monitor by calling one of the
wait
methods.
The awakened thread will not be able to proceed until the current
thread relinquishes the lock on this object. The awakened thread will
compete in the usual manner with any other threads that might be
actively competing to synchronize on this object; for example, the
awakened thread enjoys no reliable privilege or disadvantage in being
the next thread to lock this object.
This method should only be called by a thread that is the owner
of this object's monitor. A thread becomes the owner of the
object's monitor in one of three ways:
- By executing a synchronized instance method of that object.
- By executing the body of a
synchronized
statement
that synchronizes on the object.
- For objects of type
Class,
by executing a
synchronized static method of that class.
Only one thread at a time can own an object's monitor.
Wakes up all threads that are waiting on this object's monitor. A
thread waits on an object's monitor by calling one of the
wait
methods.
The awakened threads will not be able to proceed until the current
thread relinquishes the lock on this object. The awakened threads
will compete in the usual manner with any other threads that might
be actively competing to synchronize on this object; for example,
the awakened threads enjoy no reliable privilege or disadvantage in
being the next thread to lock this object.
This method should only be called by a thread that is the owner
of this object's monitor. See the notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
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.
Sorts the specified range of the specified array of bytes into
ascending numerical order. The range to be sorted extends from index
fromIndex, inclusive, to index
toIndex, exclusive.
(If
fromIndex==toIndex, the range to be sorted is empty.)
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.
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.
Sorts the specified range of the specified array of chars into
ascending numerical order. The range to be sorted extends from index
fromIndex, inclusive, to index
toIndex, exclusive.
(If
fromIndex==toIndex, the range to be sorted is empty.)
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.
Sorts the specified array of doubles into ascending numerical order.
The <
relation does not provide a total order on
all floating-point values; although they are distinct numbers
-0.0 == 0.0
is true
and a NaN value
compares neither less than, greater than, nor equal to any
floating-point value, even itself. To allow the sort to
proceed, instead of using the <
relation to
determine ascending numerical order, this method uses the total
order imposed by Double#compareTo
. This ordering
differs from the <
relation in that
-0.0
is treated as less than 0.0
and
NaN is considered greater than any other floating-point value.
For the purposes of sorting, all NaN values are considered
equivalent and equal.
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.
Sorts the specified range of the specified array of doubles into
ascending numerical order. The range to be sorted extends from index
fromIndex, inclusive, to index
toIndex, exclusive.
(If
fromIndex==toIndex, the range to be sorted is empty.)
The <
relation does not provide a total order on
all floating-point values; although they are distinct numbers
-0.0 == 0.0
is true
and a NaN value
compares neither less than, greater than, nor equal to any
floating-point value, even itself. To allow the sort to
proceed, instead of using the <
relation to
determine ascending numerical order, this method uses the total
order imposed by Double#compareTo
. This ordering
differs from the <
relation in that
-0.0
is treated as less than 0.0
and
NaN is considered greater than any other floating-point value.
For the purposes of sorting, all NaN values are considered
equivalent and equal.
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.
Sorts the specified array of floats into ascending numerical order.
The <
relation does not provide a total order on
all floating-point values; although they are distinct numbers
-0.0f == 0.0f
is true
and a NaN value
compares neither less than, greater than, nor equal to any
floating-point value, even itself. To allow the sort to
proceed, instead of using the <
relation to
determine ascending numerical order, this method uses the total
order imposed by Float#compareTo
. This ordering
differs from the <
relation in that
-0.0f
is treated as less than 0.0f
and
NaN is considered greater than any other floating-point value.
For the purposes of sorting, all NaN values are considered
equivalent and equal.
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.
Sorts the specified range of the specified array of floats into
ascending numerical order. The range to be sorted extends from index
fromIndex, inclusive, to index
toIndex, exclusive.
(If
fromIndex==toIndex, the range to be sorted is empty.)
The <
relation does not provide a total order on
all floating-point values; although they are distinct numbers
-0.0f == 0.0f
is true
and a NaN value
compares neither less than, greater than, nor equal to any
floating-point value, even itself. To allow the sort to
proceed, instead of using the <
relation to
determine ascending numerical order, this method uses the total
order imposed by Float#compareTo
. This ordering
differs from the <
relation in that
-0.0f
is treated as less than 0.0f
and
NaN is considered greater than any other floating-point value.
For the purposes of sorting, all NaN values are considered
equivalent and equal.
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.
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.
Sorts the specified range of the specified array of ints into
ascending numerical order. The range to be sorted extends from index
fromIndex, inclusive, to index
toIndex, exclusive.
(If
fromIndex==toIndex, the range to be sorted is empty.)
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.
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.
Sorts the specified range of the specified array of longs into
ascending numerical order. The range to be sorted extends from index
fromIndex, inclusive, to index
toIndex, exclusive.
(If
fromIndex==toIndex, the range to be sorted is empty.)
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.
Sorts the specified array of objects into ascending order, according to
the
natural ordering 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
ClassCastException
for any elements
e1 and
e2 in the array).
This sort is guaranteed to be stable: equal elements will
not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is
omitted if the highest element in the low sublist is less than the
lowest element in the high sublist). This algorithm offers guaranteed
n*log(n) performance.
Sorts the specified range of the specified array of objects into
ascending order, according to the
natural ordering of its
elements. The range to be sorted extends from index
fromIndex, inclusive, to index
toIndex, exclusive.
(If
fromIndex==toIndex, the range to be sorted is empty.) All
elements in this range must implement the
Comparable
interface. Furthermore, all elements in this range must be
mutually
comparable (that is,
e1.compareTo(e2) must not throw a
ClassCastException for any elements
e1 and
e2 in the array).
This sort is guaranteed to be stable: equal elements will
not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is
omitted if the highest element in the low sublist is less than the
lowest element in the high sublist). This algorithm offers guaranteed
n*log(n) performance.
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.
Sorts the specified range of the specified array of shorts into
ascending numerical order. The range to be sorted extends from index
fromIndex, inclusive, to index
toIndex, exclusive.
(If
fromIndex==toIndex, the range to be sorted is empty.)
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.
Sorts the specified array of objects according to the order induced by
the specified comparator. All elements in the array must be
mutually comparable by the specified comparator (that is,
c.compare(e1, e2) must not throw a
ClassCastException
for any elements
e1 and
e2 in the array).
This sort is guaranteed to be stable: equal elements will
not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is
omitted if the highest element in the low sublist is less than the
lowest element in the high sublist). This algorithm offers guaranteed
n*log(n) performance.
Sorts the specified range of the specified array of objects according
to the order induced by the specified comparator. The range to be
sorted extends from index
fromIndex, inclusive, to index
toIndex, exclusive. (If
fromIndex==toIndex, the
range to be sorted is empty.) All elements in the range must be
mutually comparable by the specified comparator (that is,
c.compare(e1, e2) must not throw a
ClassCastException
for any elements
e1 and
e2 in the range).
This sort is guaranteed to be stable: equal elements will
not be reordered as a result of the sort.
The sorting algorithm is a modified mergesort (in which the merge is
omitted if the highest element in the low sublist is less than the
lowest element in the high sublist). This algorithm offers guaranteed
n*log(n) performance.
Returns a string representation of the object. In general, the
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Returns a string representation of the contents of the specified array.
The string representation consists of a list of the array's elements,
enclosed in square brackets ("[]"). Adjacent elements are
separated by the characters ", " (a comma followed by a
space). Elements are converted to strings as by
String.valueOf(boolean). Returns "null" if
a is null.
Returns a string representation of the contents of the specified array.
The string representation consists of a list of the array's elements,
enclosed in square brackets ("[]"). Adjacent elements
are separated by the characters ", " (a comma followed
by a space). Elements are converted to strings as by
String.valueOf(byte). Returns "null" if
a is null.
Returns a string representation of the contents of the specified array.
The string representation consists of a list of the array's elements,
enclosed in square brackets ("[]"). Adjacent elements are
separated by the characters ", " (a comma followed by a
space). Elements are converted to strings as by
String.valueOf(char). Returns "null" if a
is null.
Returns a string representation of the contents of the specified array.
The string representation consists of a list of the array's elements,
enclosed in square brackets ("[]"). Adjacent elements are
separated by the characters ", " (a comma followed by a
space). Elements are converted to strings as by
String.valueOf(double). Returns "null" if a
is null.
Returns a string representation of the contents of the specified array.
The string representation consists of a list of the array's elements,
enclosed in square brackets ("[]"). Adjacent elements are
separated by the characters ", " (a comma followed by a
space). Elements are converted to strings as by
String.valueOf(float). Returns "null" if a
is null.
Returns a string representation of the contents of the specified array.
The string representation consists of a list of the array's elements,
enclosed in square brackets ("[]"). Adjacent elements are
separated by the characters ", " (a comma followed by a
space). Elements are converted to strings as by
String.valueOf(int). Returns "null" if a is
null.
Returns a string representation of the contents of the specified array.
The string representation consists of a list of the array's elements,
enclosed in square brackets ("[]"). Adjacent elements are
separated by the characters ", " (a comma followed by a
space). Elements are converted to strings as by
String.valueOf(long). Returns "null" if a
is null.
Returns a string representation of the contents of the specified array.
If the array contains other arrays as elements, they are converted to
strings by the
Object#toString
method inherited from
Object, which describes their
identities rather than
their contents.
The value returned by this method is equal to the value that would
be returned by Arrays.asList(a).toString(), unless a
is null, in which case "null" is returned.
Returns a string representation of the contents of the specified array.
The string representation consists of a list of the array's elements,
enclosed in square brackets ("[]"). Adjacent elements are
separated by the characters ", " (a comma followed by a
space). Elements are converted to strings as by
String.valueOf(short). Returns "null" if a
is null.
Causes current thread to wait until another thread invokes the
method or the
method for this object.
In other words, this method behaves exactly as if it simply
performs the call
wait(0).
The current thread must own this object's monitor. The thread
releases ownership of this monitor and waits until another thread
notifies threads waiting on this object's monitor to wake up
either through a call to the notify
method or the
notifyAll
method. The thread then waits until it can
re-obtain ownership of the monitor and resumes execution.
As in the one argument version, interrupts and spurious wakeups are
possible, and this method should always be used in a loop:
synchronized (obj) {
while (<condition does not hold>)
obj.wait();
... // Perform action appropriate to condition
}
This method should only be called by a thread that is the owner
of this object's monitor. See the
notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
Causes current thread to wait until either another thread invokes the
method or the
method for this object, or a
specified amount of time has elapsed.
The current thread must own this object's monitor.
This method causes the current thread (call it T) to
place itself in the wait set for this object and then to relinquish
any and all synchronization claims on this object. Thread T
becomes disabled for thread scheduling purposes and lies dormant
until one of four things happens:
- Some other thread invokes the notify method for this
object and thread T happens to be arbitrarily chosen as
the thread to be awakened.
- Some other thread invokes the notifyAll method for this
object.
- Some other thread interrupts
thread T.
- The specified amount of real time has elapsed, more or less. If
timeout is zero, however, then real time is not taken into
consideration and the thread simply waits until notified.
The thread
T is then removed from the wait set for this
object and re-enabled for thread scheduling. It then competes in the
usual manner with other threads for the right to synchronize on the
object; once it has gained control of the object, all its
synchronization claims on the object are restored to the status quo
ante - that is, to the situation as of the time that the
wait
method was invoked. Thread
T then returns from the
invocation of the
wait method. Thus, on return from the
wait method, the synchronization state of the object and of
thread
T is exactly as it was when the
wait method
was invoked.
A thread can also wake up without being notified, interrupted, or
timing out, a so-called spurious wakeup. While this will rarely
occur in practice, applications must guard against it by testing for
the condition that should have caused the thread to be awakened, and
continuing to wait if the condition is not satisfied. In other words,
waits should always occur in loops, like this one:
synchronized (obj) {
while (<condition does not hold>)
obj.wait(timeout);
... // Perform action appropriate to condition
}
(For more information on this topic, see Section 3.2.3 in Doug Lea's
"Concurrent Programming in Java (Second Edition)" (Addison-Wesley,
2000), or Item 50 in Joshua Bloch's "Effective Java Programming
Language Guide" (Addison-Wesley, 2001).
If the current thread is
interrupted
by another thread
while it is waiting, then an InterruptedException is thrown.
This exception is not thrown until the lock status of this object has
been restored as described above.
Note that the wait method, as it places the current thread
into the wait set for this object, unlocks only this object; any
other objects on which the current thread may be synchronized remain
locked while the thread waits.
This method should only be called by a thread that is the owner
of this object's monitor. See the notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
Causes current thread to wait until another thread invokes the
method or the
method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
This method is similar to the wait
method of one
argument, but it allows finer control over the amount of time to
wait for a notification before giving up. The amount of real time,
measured in nanoseconds, is given by:
1000000*timeout+nanos
In all other respects, this method does the same thing as the
method
of one argument. In particular,
wait(0, 0) means the same thing as wait(0).
The current thread must own this object's monitor. The thread
releases ownership of this monitor and waits until either of the
following two conditions has occurred:
- Another thread notifies threads waiting on this object's monitor
to wake up either through a call to the
notify
method
or the notifyAll
method.
- The timeout period, specified by
timeout
milliseconds plus nanos
nanoseconds arguments, has
elapsed.
The thread then waits until it can re-obtain ownership of the
monitor and resumes execution.
As in the one argument version, interrupts and spurious wakeups are
possible, and this method should always be used in a loop:
synchronized (obj) {
while (<condition does not hold>)
obj.wait(timeout, nanos);
... // Perform action appropriate to condition
}
This method should only be called by a thread that is the owner
of this object's monitor. See the
notify
method for a
description of the ways in which a thread can become the owner of
a monitor.