Arrays
class Arrays
kotlin.Any | |
↳ | java.util.Arrays |
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 brief descriptions 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.
Summary
Public methods | |
---|---|
static MutableList<T> |
asList(vararg a: T) Returns a fixed-size list backed by the specified array. |
static Int |
binarySearch(a: ByteArray, key: Byte) Searches the specified array of bytes for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: ByteArray, fromIndex: Int, toIndex: Int, key: Byte) Searches a range of the specified array of bytes for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: CharArray, key: Char) Searches the specified array of chars for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: CharArray, fromIndex: Int, toIndex: Int, key: Char) Searches a range of the specified array of chars for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: DoubleArray, key: Double) Searches the specified array of doubles for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: DoubleArray, fromIndex: Int, toIndex: Int, key: Double) Searches a range of the specified array of doubles for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: FloatArray, key: Float) Searches the specified array of floats for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: FloatArray, fromIndex: Int, toIndex: Int, key: Float) Searches a range of the specified array of floats for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: IntArray, key: Int) Searches the specified array of ints for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: IntArray, fromIndex: Int, toIndex: Int, key: Int) Searches a range of the specified array of ints for the specified value using the binary search algorithm. |
static Int |
Searches a range of the specified array for the specified object using the binary search algorithm. |
static Int |
binarySearch(a: Array<Any!>, key: Any) Searches the specified array for the specified object using the binary search algorithm. |
static Int |
binarySearch(a: LongArray, fromIndex: Int, toIndex: Int, key: Long) Searches a range of the specified array of longs for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: LongArray, key: Long) Searches the specified array of longs for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: ShortArray, fromIndex: Int, toIndex: Int, key: Short) Searches a range of the specified array of shorts for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: ShortArray, key: Short) Searches the specified array of shorts for the specified value using the binary search algorithm. |
static Int |
binarySearch(a: Array<T>, fromIndex: Int, toIndex: Int, key: T, c: Comparator<in T>?) Searches a range of the specified array for the specified object using the binary search algorithm. |
static Int |
binarySearch(a: Array<T>, key: T, c: Comparator<in T>?) Searches the specified array for the specified object using the binary search algorithm. |
static Int |
compare(a: BooleanArray?, b: BooleanArray?) Compares two |
static Int |
compare(a: BooleanArray, aFromIndex: Int, aToIndex: Int, b: BooleanArray, bFromIndex: Int, bToIndex: Int) Compares two |
static Int |
Compares two |
static Int |
Compares two |
static Int |
Compares two |
static Int |
Compares two |
static Int |
compare(a: DoubleArray?, b: DoubleArray?) Compares two |
static Int |
compare(a: DoubleArray, aFromIndex: Int, aToIndex: Int, b: DoubleArray, bFromIndex: Int, bToIndex: Int) Compares two |
static Int |
compare(a: FloatArray?, b: FloatArray?) Compares two |
static Int |
compare(a: FloatArray, aFromIndex: Int, aToIndex: Int, b: FloatArray, bFromIndex: Int, bToIndex: Int) Compares two |
static Int |
Compares two |
static Int |
Compares two |
static Int |
Compares two |
static Int |
Compares two |
static Int |
compare(a: ShortArray, aFromIndex: Int, aToIndex: Int, b: ShortArray, bFromIndex: Int, bToIndex: Int) Compares two |
static Int |
compare(a: ShortArray?, b: ShortArray?) Compares two |
static Int |
Compares two |
static Int |
compare(a: Array<T>, aFromIndex: Int, aToIndex: Int, b: Array<T>, bFromIndex: Int, bToIndex: Int, cmp: Comparator<in T>) Compares two |
static Int |
Compares two |
static Int |
compare(a: Array<T>?, b: Array<T>?, cmp: Comparator<in T>) Compares two |
static Int |
compareUnsigned(a: ByteArray?, b: ByteArray?) Compares two |
static Int |
compareUnsigned(a: ByteArray, aFromIndex: Int, aToIndex: Int, b: ByteArray, bFromIndex: Int, bToIndex: Int) Compares two |
static Int |
compareUnsigned(a: IntArray, aFromIndex: Int, aToIndex: Int, b: IntArray, bFromIndex: Int, bToIndex: Int) Compares two |
static Int |
compareUnsigned(a: IntArray?, b: IntArray?) Compares two |
static Int |
compareUnsigned(a: LongArray, aFromIndex: Int, aToIndex: Int, b: LongArray, bFromIndex: Int, bToIndex: Int) Compares two |
static Int |
compareUnsigned(a: LongArray?, b: LongArray?) Compares two |
static Int |
compareUnsigned(a: ShortArray, aFromIndex: Int, aToIndex: Int, b: ShortArray, bFromIndex: Int, bToIndex: Int) Compares two |
static Int |
compareUnsigned(a: ShortArray?, b: ShortArray?) Compares two |
static BooleanArray |
copyOf(original: BooleanArray, newLength: Int) Copies the specified array, truncating or padding with |
static ByteArray |
Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. |
static CharArray |
Copies the specified array, truncating or padding with null characters (if necessary) so the copy has the specified length. |
static DoubleArray |
copyOf(original: DoubleArray, newLength: Int) Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. |
static FloatArray |
copyOf(original: FloatArray, newLength: Int) Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. |
static IntArray |
Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. |
static LongArray |
Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. |
static ShortArray |
copyOf(original: ShortArray, newLength: Int) Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. |
static Array<T> |
Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. |
static Array<T> |
Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. |
static BooleanArray |
copyOfRange(original: BooleanArray, from: Int, to: Int) Copies the specified range of the specified array into a new array. |
static ByteArray |
copyOfRange(original: ByteArray, from: Int, to: Int) Copies the specified range of the specified array into a new array. |
static CharArray |
copyOfRange(original: CharArray, from: Int, to: Int) Copies the specified range of the specified array into a new array. |
static DoubleArray |
copyOfRange(original: DoubleArray, from: Int, to: Int) Copies the specified range of the specified array into a new array. |
static FloatArray |
copyOfRange(original: FloatArray, from: Int, to: Int) Copies the specified range of the specified array into a new array. |
static IntArray |
copyOfRange(original: IntArray, from: Int, to: Int) Copies the specified range of the specified array into a new array. |
static LongArray |
copyOfRange(original: LongArray, from: Int, to: Int) Copies the specified range of the specified array into a new array. |
static ShortArray |
copyOfRange(original: ShortArray, from: Int, to: Int) Copies the specified range of the specified array into a new array. |
static Array<T> |
copyOfRange(original: Array<T>, from: Int, to: Int) Copies the specified range of the specified array into a new array. |
static Array<T> |
Copies the specified range of the specified array into a new array. |
static Boolean |
deepEquals(a1: Array<Any!>?, a2: Array<Any!>?) Returns |
static Int |
deepHashCode(a: Array<Any!>?) Returns a hash code based on the "deep contents" of the specified array. |
static String |
deepToString(a: Array<Any!>?) Returns a string representation of the "deep contents" of the specified array. |
static Boolean |
equals(a: BooleanArray?, a2: BooleanArray?) Returns |
static Boolean |
equals(a: BooleanArray, aFromIndex: Int, aToIndex: Int, b: BooleanArray, bFromIndex: Int, bToIndex: Int) Returns true if the two specified arrays of booleans, over the specified ranges, are equal to one another. |
static Boolean |
Returns |
static Boolean |
Returns true if the two specified arrays of bytes, over the specified ranges, are equal to one another. |
static Boolean |
Returns |
static Boolean |
Returns true if the two specified arrays of chars, over the specified ranges, are equal to one another. |
static Boolean |
equals(a: DoubleArray?, a2: DoubleArray?) Returns |
static Boolean |
equals(a: DoubleArray, aFromIndex: Int, aToIndex: Int, b: DoubleArray, bFromIndex: Int, bToIndex: Int) Returns true if the two specified arrays of doubles, over the specified ranges, are equal to one another. |
static Boolean |
equals(a: FloatArray?, a2: FloatArray?) Returns |
static Boolean |
equals(a: FloatArray, aFromIndex: Int, aToIndex: Int, b: FloatArray, bFromIndex: Int, bToIndex: Int) Returns true if the two specified arrays of floats, over the specified ranges, are equal to one another. |
static Boolean |
Returns true if the two specified arrays of ints, over the specified ranges, are equal to one another. |
static Boolean |
Returns |
static Boolean |
equals(a: Array<Any!>, aFromIndex: Int, aToIndex: Int, b: Array<Any!>, bFromIndex: Int, bToIndex: Int) Returns true if the two specified arrays of Objects, over the specified ranges, are equal to one another. |
static Boolean |
Returns |
static Boolean |
Returns true if the two specified arrays of longs, over the specified ranges, are equal to one another. |
static Boolean |
Returns |
static Boolean |
equals(a: ShortArray, aFromIndex: Int, aToIndex: Int, b: ShortArray, bFromIndex: Int, bToIndex: Int) Returns true if the two specified arrays of shorts, over the specified ranges, are equal to one another. |
static Boolean |
equals(a: ShortArray?, a2: ShortArray?) Returns |
static Boolean |
equals(a: Array<T>, aFromIndex: Int, aToIndex: Int, b: Array<T>, bFromIndex: Int, bToIndex: Int, cmp: Comparator<in T>) Returns true if the two specified arrays of Objects, over the specified ranges, are equal to one another. |
static Boolean |
equals(a: Array<T>?, a2: Array<T>?, cmp: Comparator<in T>) Returns |
static Unit |
fill(a: BooleanArray, val: Boolean) Assigns the specified boolean value to each element of the specified array of booleans. |
static Unit |
fill(a: BooleanArray, fromIndex: Int, toIndex: Int, val: Boolean) Assigns the specified boolean value to each element of the specified range of the specified array of booleans. |
static Unit |
Assigns the specified byte value to each element of the specified array of bytes. |
static Unit |
Assigns the specified byte value to each element of the specified range of the specified array of bytes. |
static Unit |
Assigns the specified char value to each element of the specified array of chars. |
static Unit |
Assigns the specified char value to each element of the specified range of the specified array of chars. |
static Unit |
fill(a: DoubleArray, val: Double) Assigns the specified double value to each element of the specified array of doubles. |
static Unit |
fill(a: DoubleArray, fromIndex: Int, toIndex: Int, val: Double) Assigns the specified double value to each element of the specified range of the specified array of doubles. |
static Unit |
fill(a: FloatArray, val: Float) Assigns the specified float value to each element of the specified array of floats. |
static Unit |
fill(a: FloatArray, fromIndex: Int, toIndex: Int, val: Float) Assigns the specified float value to each element of the specified range of the specified array of floats. |
static Unit |
Assigns the specified int value to each element of the specified array of ints. |
static Unit |
Assigns the specified int value to each element of the specified range of the specified array of ints. |
static Unit |
Assigns the specified Object reference to each element of the specified range of the specified array of Objects. |
static Unit |
Assigns the specified Object reference to each element of the specified array of Objects. |
static Unit |
Assigns the specified long value to each element of the specified range of the specified array of longs. |
static Unit |
Assigns the specified long value to each element of the specified array of longs. |
static Unit |
fill(a: ShortArray, fromIndex: Int, toIndex: Int, val: Short) Assigns the specified short value to each element of the specified range of the specified array of shorts. |
static Unit |
fill(a: ShortArray, val: Short) Assigns the specified short value to each element of the specified array of shorts. |
static Int |
hashCode(a: BooleanArray?) Returns a hash code based on the contents of the specified array. |
static Int |
Returns a hash code based on the contents of the specified array. |
static Int |
Returns a hash code based on the contents of the specified array. |
static Int |
hashCode(a: DoubleArray?) Returns a hash code based on the contents of the specified array. |
static Int |
hashCode(a: FloatArray?) Returns a hash code based on the contents of the specified array. |
static Int |
Returns a hash code based on the contents of the specified array. |
static Int |
Returns a hash code based on the contents of the specified array. |
static Int |
Returns a hash code based on the contents of the specified array. |
static Int |
hashCode(a: ShortArray?) Returns a hash code based on the contents of the specified array. |
static Int |
mismatch(a: BooleanArray, b: BooleanArray) Finds and returns the index of the first mismatch between two |
static Int |
mismatch(a: BooleanArray, aFromIndex: Int, aToIndex: Int, b: BooleanArray, bFromIndex: Int, bToIndex: Int) Finds and returns the relative index of the first mismatch between two |
static Int |
Finds and returns the index of the first mismatch between two |
static Int |
mismatch(a: ByteArray!, aFromIndex: Int, aToIndex: Int, b: ByteArray!, bFromIndex: Int, bToIndex: Int) Finds and returns the relative index of the first mismatch between two |
static Int |
Finds and returns the index of the first mismatch between two |
static Int |
mismatch(a: CharArray, aFromIndex: Int, aToIndex: Int, b: CharArray, bFromIndex: Int, bToIndex: Int) Finds and returns the relative index of the first mismatch between two |
static Int |
mismatch(a: DoubleArray, b: DoubleArray) Finds and returns the index of the first mismatch between two |
static Int |
mismatch(a: DoubleArray, aFromIndex: Int, aToIndex: Int, b: DoubleArray, bFromIndex: Int, bToIndex: Int) Finds and returns the relative index of the first mismatch between two |
static Int |
mismatch(a: FloatArray, b: FloatArray) Finds and returns the index of the first mismatch between two |
static Int |
mismatch(a: FloatArray, aFromIndex: Int, aToIndex: Int, b: FloatArray, bFromIndex: Int, bToIndex: Int) Finds and returns the relative index of the first mismatch between two |
static Int |
Finds and returns the relative index of the first mismatch between two |
static Int |
Finds and returns the index of the first mismatch between two |
static Int |
mismatch(a: Array<Any!>, aFromIndex: Int, aToIndex: Int, b: Array<Any!>, bFromIndex: Int, bToIndex: Int) Finds and returns the relative index of the first mismatch between two |
static Int |
Finds and returns the index of the first mismatch between two |
static Int |
mismatch(a: LongArray, aFromIndex: Int, aToIndex: Int, b: LongArray, bFromIndex: Int, bToIndex: Int) Finds and returns the relative index of the first mismatch between two |
static Int |
Finds and returns the index of the first mismatch between two |
static Int |
mismatch(a: ShortArray, aFromIndex: Int, aToIndex: Int, b: ShortArray, bFromIndex: Int, bToIndex: Int) Finds and returns the relative index of the first mismatch between two |
static Int |
mismatch(a: ShortArray, b: ShortArray) Finds and returns the index of the first mismatch between two |
static Int |
mismatch(a: Array<T>, aFromIndex: Int, aToIndex: Int, b: Array<T>, bFromIndex: Int, bToIndex: Int, cmp: Comparator<in T>) Finds and returns the relative index of the first mismatch between two |
static Int |
mismatch(a: Array<T>, b: Array<T>, cmp: Comparator<in T>) Finds and returns the index of the first mismatch between two |
static Unit |
parallelPrefix(array: DoubleArray, fromIndex: Int, toIndex: Int, op: DoubleBinaryOperator) Performs |
static Unit |
parallelPrefix(array: DoubleArray, op: DoubleBinaryOperator) Cumulates, in parallel, each element of the given array in place, using the supplied function. |
static Unit |
parallelPrefix(array: IntArray, fromIndex: Int, toIndex: Int, op: IntBinaryOperator) Performs |
static Unit |
parallelPrefix(array: IntArray, op: IntBinaryOperator) Cumulates, in parallel, each element of the given array in place, using the supplied function. |
static Unit |
parallelPrefix(array: LongArray, fromIndex: Int, toIndex: Int, op: LongBinaryOperator) Performs |
static Unit |
parallelPrefix(array: LongArray, op: LongBinaryOperator) Cumulates, in parallel, each element of the given array in place, using the supplied function. |
static Unit |
parallelPrefix(array: Array<T>, fromIndex: Int, toIndex: Int, op: BinaryOperator<T>) Performs |
static Unit |
parallelPrefix(array: Array<T>, op: BinaryOperator<T>) Cumulates, in parallel, each element of the given array in place, using the supplied function. |
static Unit |
parallelSetAll(array: DoubleArray, generator: IntToDoubleFunction) Set all elements of the specified array, in parallel, using the provided generator function to compute each element. |
static Unit |
parallelSetAll(array: IntArray, generator: IntUnaryOperator) Set all elements of the specified array, in parallel, using the provided generator function to compute each element. |
static Unit |
parallelSetAll(array: LongArray, generator: IntToLongFunction) Set all elements of the specified array, in parallel, using the provided generator function to compute each element. |
static Unit |
parallelSetAll(array: Array<T>, generator: IntFunction<out T>) Set all elements of the specified array, in parallel, using the provided generator function to compute each element. |
static Unit |
Sorts the specified array into ascending numerical order. |
static Unit |
parallelSort(a: ByteArray, fromIndex: Int, toIndex: Int) Sorts the specified range of the array into ascending numerical order. |
static Unit |
Sorts the specified array into ascending numerical order. |
static Unit |
parallelSort(a: CharArray, fromIndex: Int, toIndex: Int) Sorts the specified range of the array into ascending numerical order. |
static Unit |
Sorts the specified array into ascending numerical order. |
static Unit |
parallelSort(a: DoubleArray, fromIndex: Int, toIndex: Int) Sorts the specified range of the array into ascending numerical order. |
static Unit |
Sorts the specified array into ascending numerical order. |
static Unit |
parallelSort(a: FloatArray, fromIndex: Int, toIndex: Int) Sorts the specified range of the array into ascending numerical order. |
static Unit |
parallelSort(a: IntArray) Sorts the specified array into ascending numerical order. |
static Unit |
parallelSort(a: IntArray, fromIndex: Int, toIndex: Int) Sorts the specified range of the array into ascending numerical order. |
static Unit |
Sorts the specified array into ascending numerical order. |
static Unit |
parallelSort(a: LongArray, fromIndex: Int, toIndex: Int) Sorts the specified range of the array into ascending numerical order. |
static Unit |
Sorts the specified array into ascending numerical order. |
static Unit |
parallelSort(a: ShortArray, fromIndex: Int, toIndex: Int) Sorts the specified range of the array into ascending numerical order. |
static Unit |
parallelSort(a: Array<T>) Sorts the specified array of objects into ascending order, according to the natural ordering of its elements. |
static Unit |
parallelSort(a: Array<T>, fromIndex: Int, toIndex: Int) Sorts the specified range of the specified array of objects into ascending order, according to the natural ordering of its elements. |
static Unit |
parallelSort(a: Array<T>, fromIndex: Int, toIndex: Int, cmp: Comparator<in T>?) Sorts the specified range of the specified array of objects according to the order induced by the specified comparator. |
static Unit |
parallelSort(a: Array<T>, cmp: Comparator<in T>?) Sorts the specified array of objects according to the order induced by the specified comparator. |
static Unit |
setAll(array: DoubleArray, generator: IntToDoubleFunction) Set all elements of the specified array, using the provided generator function to compute each element. |
static Unit |
setAll(array: IntArray, generator: IntUnaryOperator) Set all elements of the specified array, using the provided generator function to compute each element. |
static Unit |
setAll(array: LongArray, generator: IntToLongFunction) Set all elements of the specified array, using the provided generator function to compute each element. |
static Unit |
setAll(array: Array<T>, generator: IntFunction<out T>) Set all elements of the specified array, using the provided generator function to compute each element. |
static Unit |
Sorts the specified array into ascending numerical order. |
static Unit |
Sorts the specified range of the array into ascending order. |
static Unit |
Sorts the specified array into ascending numerical order. |
static Unit |
Sorts the specified range of the array into ascending order. |
static Unit |
sort(a: DoubleArray) Sorts the specified array into ascending numerical order. |
static Unit |
sort(a: DoubleArray, fromIndex: Int, toIndex: Int) Sorts the specified range of the array into ascending order. |
static Unit |
sort(a: FloatArray) Sorts the specified array into ascending numerical order. |
static Unit |
sort(a: FloatArray, fromIndex: Int, toIndex: Int) Sorts the specified range of the array into ascending order. |
static Unit |
Sorts the specified array into ascending numerical order. |
static Unit |
Sorts the specified range of the array into ascending order. |
static Unit |
Sorts the specified array of objects into ascending order, according to the natural ordering of its elements. |
static Unit |
Sorts the specified range of the specified array of objects into ascending order, according to the natural ordering of its elements. |
static Unit |
Sorts the specified array into ascending numerical order. |
static Unit |
Sorts the specified range of the array into ascending order. |
static Unit |
sort(a: ShortArray) Sorts the specified array into ascending numerical order. |
static Unit |
sort(a: ShortArray, fromIndex: Int, toIndex: Int) Sorts the specified range of the array into ascending order. |
static Unit |
sort(a: Array<T>, fromIndex: Int, toIndex: Int, c: Comparator<in T>?) Sorts the specified range of the specified array of objects according to the order induced by the specified comparator. |
static Unit |
sort(a: Array<T>, c: Comparator<in T>?) Sorts the specified array of objects according to the order induced by the specified comparator. |
static Spliterator.OfDouble |
spliterator(array: DoubleArray) Returns a |
static Spliterator.OfDouble |
spliterator(array: DoubleArray, startInclusive: Int, endExclusive: Int) Returns a |
static Spliterator.OfInt |
spliterator(array: IntArray) Returns a |
static Spliterator.OfInt |
spliterator(array: IntArray, startInclusive: Int, endExclusive: Int) Returns a |
static Spliterator.OfLong |
spliterator(array: LongArray) Returns a |
static Spliterator.OfLong |
spliterator(array: LongArray, startInclusive: Int, endExclusive: Int) Returns a |
static Spliterator<T> |
spliterator(array: Array<T>) Returns a |
static Spliterator<T> |
spliterator(array: Array<T>, startInclusive: Int, endExclusive: Int) Returns a |
static DoubleStream |
stream(array: DoubleArray) Returns a sequential |
static DoubleStream |
stream(array: DoubleArray, startInclusive: Int, endExclusive: Int) Returns a sequential |
static IntStream |
Returns a sequential |
static IntStream |
Returns a sequential |
static LongStream |
Returns a sequential |
static LongStream |
Returns a sequential |
static Stream<T> |
Returns a sequential |
static Stream<T> |
Returns a sequential |
static String |
toString(a: BooleanArray?) Returns a string representation of the contents of the specified array. |
static String |
Returns a string representation of the contents of the specified array. |
static String |
Returns a string representation of the contents of the specified array. |
static String |
toString(a: DoubleArray?) Returns a string representation of the contents of the specified array. |
static String |
toString(a: FloatArray?) Returns a string representation of the contents of the specified array. |
static String |
Returns a string representation of the contents of the specified array. |
static String |
Returns a string representation of the contents of the specified array. |
static String |
Returns a string representation of the contents of the specified array. |
static String |
toString(a: ShortArray?) Returns a string representation of the contents of the specified array. |
Public methods
asList
@SafeVarargs static fun <T : Any!> asList(vararg a: T): MutableList<T>
Returns a fixed-size list backed by the specified array. Changes made to the array will be visible in the returned list, and changes made to the list will be visible in the array. The returned list is Serializable
and implements RandomAccess
.
The returned list implements the optional Collection
methods, except those that would change the size of the returned list. Those methods leave the list unchanged and throw UnsupportedOperationException
.
If the specified array's actual component type differs from the type parameter T, this can result in operations on the returned list throwing an ArrayStoreException
.
Parameters | |
---|---|
<T> |
the class of the objects in the array |
a |
T: the array by which the list will be backed |
Return | |
---|---|
MutableList<T> |
a list view of the specified array |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the specified array is null |
binarySearch
static fun binarySearch(
a: ByteArray,
key: Byte
): Int
Searches the specified array of bytes for the specified value using the binary search algorithm. The array must be sorted (as by the sort(byte[])
method) 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.
Parameters | |
---|---|
a |
ByteArray: the array to be searched |
key |
Byte: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
binarySearch
static fun binarySearch(
a: ByteArray,
fromIndex: Int,
toIndex: Int,
key: Byte
): Int
Searches a range of the specified array of bytes for the specified value using the binary search algorithm. The range must be sorted (as by the sort(byte[],int,int)
method) prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.
Parameters | |
---|---|
a |
ByteArray: the array to be searched |
fromIndex |
Int: the index of the first element (inclusive) to be searched |
toIndex |
Int: the index of the last element (exclusive) to be searched |
key |
Byte: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array within the specified range; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element in the range greater than the key, or toIndex if all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
binarySearch
static fun binarySearch(
a: CharArray,
key: Char
): Int
Searches the specified array of chars for the specified value using the binary search algorithm. The array must be sorted (as by the sort(char[])
method) 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.
Parameters | |
---|---|
a |
CharArray: the array to be searched |
key |
Char: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
binarySearch
static fun binarySearch(
a: CharArray,
fromIndex: Int,
toIndex: Int,
key: Char
): Int
Searches a range of the specified array of chars for the specified value using the binary search algorithm. The range must be sorted (as by the sort(char[],int,int)
method) prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.
Parameters | |
---|---|
a |
CharArray: the array to be searched |
fromIndex |
Int: the index of the first element (inclusive) to be searched |
toIndex |
Int: the index of the last element (exclusive) to be searched |
key |
Char: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array within the specified range; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element in the range greater than the key, or toIndex if all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
binarySearch
static fun binarySearch(
a: DoubleArray,
key: Double
): Int
Searches the specified array of doubles for the specified value using the binary search algorithm. The array must be sorted (as by the sort(double[])
method) 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.
Parameters | |
---|---|
a |
DoubleArray: the array to be searched |
key |
Double: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
binarySearch
static fun binarySearch(
a: DoubleArray,
fromIndex: Int,
toIndex: Int,
key: Double
): Int
Searches a range of the specified array of doubles for the specified value using the binary search algorithm. The range must be sorted (as by the sort(double[],int,int)
method) prior to making this call. If it is not sorted, the results are undefined. If the range 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.
Parameters | |
---|---|
a |
DoubleArray: the array to be searched |
fromIndex |
Int: the index of the first element (inclusive) to be searched |
toIndex |
Int: the index of the last element (exclusive) to be searched |
key |
Double: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array within the specified range; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element in the range greater than the key, or toIndex if all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
binarySearch
static fun binarySearch(
a: FloatArray,
key: Float
): Int
Searches the specified array of floats for the specified value using the binary search algorithm. The array must be sorted (as by the sort(float[])
method) 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.
Parameters | |
---|---|
a |
FloatArray: the array to be searched |
key |
Float: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
binarySearch
static fun binarySearch(
a: FloatArray,
fromIndex: Int,
toIndex: Int,
key: Float
): Int
Searches a range of the specified array of floats for the specified value using the binary search algorithm. The range must be sorted (as by the sort(float[],int,int)
method) prior to making this call. If it is not sorted, the results are undefined. If the range 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.
Parameters | |
---|---|
a |
FloatArray: the array to be searched |
fromIndex |
Int: the index of the first element (inclusive) to be searched |
toIndex |
Int: the index of the last element (exclusive) to be searched |
key |
Float: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array within the specified range; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element in the range greater than the key, or toIndex if all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
binarySearch
static fun binarySearch(
a: IntArray,
key: Int
): Int
Searches the specified array of ints for the specified value using the binary search algorithm. The array must be sorted (as by the sort(int[])
method) 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.
Parameters | |
---|---|
a |
IntArray: the array to be searched |
key |
Int: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
binarySearch
static fun binarySearch(
a: IntArray,
fromIndex: Int,
toIndex: Int,
key: Int
): Int
Searches a range of the specified array of ints for the specified value using the binary search algorithm. The range must be sorted (as by the sort(int[],int,int)
method) prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.
Parameters | |
---|---|
a |
IntArray: the array to be searched |
fromIndex |
Int: the index of the first element (inclusive) to be searched |
toIndex |
Int: the index of the last element (exclusive) to be searched |
key |
Int: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array within the specified range; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element in the range greater than the key, or toIndex if all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
binarySearch
static fun binarySearch(
a: Array<Any!>,
fromIndex: Int,
toIndex: Int,
key: Any
): Int
Searches a range of the specified array for the specified object using the binary search algorithm. The range must be sorted into ascending order according to the natural ordering of its elements (as by the sort(java.lang.Object[],int,int)
method) prior to making this call. If it is not sorted, the results are undefined. (If the range contains elements that are not mutually comparable (for example, strings and integers), it cannot be sorted according to the natural ordering of its elements, hence results are undefined.) If the range contains multiple elements equal to the specified object, there is no guarantee which one will be found.
Parameters | |
---|---|
a |
Array<Any!>: the array to be searched |
fromIndex |
Int: the index of the first element (inclusive) to be searched |
toIndex |
Int: the index of the last element (exclusive) to be searched |
key |
Any: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array within the specified range; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element in the range greater than the key, or toIndex if all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the search key is not comparable to the elements of the array within the specified range. |
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
binarySearch
static fun binarySearch(
a: Array<Any!>,
key: Any
): Int
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 the sort(java.lang.Object[])
method) 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 ordering 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.
Parameters | |
---|---|
a |
Array<Any!>: the array to be searched |
key |
Any: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the search key is not comparable to the elements of the array. |
binarySearch
static fun binarySearch(
a: LongArray,
fromIndex: Int,
toIndex: Int,
key: Long
): Int
Searches a range of the specified array of longs for the specified value using the binary search algorithm. The range must be sorted (as by the sort(long[],int,int)
method) prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.
Parameters | |
---|---|
a |
LongArray: the array to be searched |
fromIndex |
Int: the index of the first element (inclusive) to be searched |
toIndex |
Int: the index of the last element (exclusive) to be searched |
key |
Long: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array within the specified range; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element in the range greater than the key, or toIndex if all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
binarySearch
static fun binarySearch(
a: LongArray,
key: Long
): Int
Searches the specified array of longs for the specified value using the binary search algorithm. The array must be sorted (as by the sort(long[])
method) 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.
Parameters | |
---|---|
a |
LongArray: the array to be searched |
key |
Long: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
binarySearch
static fun binarySearch(
a: ShortArray,
fromIndex: Int,
toIndex: Int,
key: Short
): Int
Searches a range of the specified array of shorts for the specified value using the binary search algorithm. The range must be sorted (as by the sort(short[],int,int)
method) prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements with the specified value, there is no guarantee which one will be found.
Parameters | |
---|---|
a |
ShortArray: the array to be searched |
fromIndex |
Int: the index of the first element (inclusive) to be searched |
toIndex |
Int: the index of the last element (exclusive) to be searched |
key |
Short: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array within the specified range; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element in the range greater than the key, or toIndex if all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
binarySearch
static fun binarySearch(
a: ShortArray,
key: Short
): Int
Searches the specified array of shorts for the specified value using the binary search algorithm. The array must be sorted (as by the sort(short[])
method) 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.
Parameters | |
---|---|
a |
ShortArray: the array to be searched |
key |
Short: the value to be searched for |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
binarySearch
static fun <T : Any!> binarySearch(
a: Array<T>,
fromIndex: Int,
toIndex: Int,
key: T,
c: Comparator<in T>?
): Int
Searches a range of the specified array for the specified object using the binary search algorithm. The range must be sorted into ascending order according to the specified comparator (as by the sort(T[], int, int, Comparator)
method) prior to making this call. If it is not sorted, the results are undefined. If the range contains multiple elements equal to the specified object, there is no guarantee which one will be found.
Parameters | |
---|---|
<T> |
the class of the objects in the array |
a |
Array<T>: the array to be searched |
fromIndex |
Int: the index of the first element (inclusive) to be searched |
toIndex |
Int: the index of the last element (exclusive) to be searched |
key |
T: the value to be searched for |
c |
Comparator<in T>?: the comparator by which the array is ordered. A null value indicates that the elements' natural ordering should be used. |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array within the specified range; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element in the range greater than the key, or toIndex if all elements in the range are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the range contains elements that are not mutually comparable using the specified comparator, or the search key is not comparable to the elements in the range using this comparator. |
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
binarySearch
static fun <T : Any!> binarySearch(
a: Array<T>,
key: T,
c: Comparator<in T>?
): Int
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(T[], Comparator)
method) 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.
Parameters | |
---|---|
<T> |
the class of the objects in the array |
a |
Array<T>: the array to be searched |
key |
T: the value to be searched for |
c |
Comparator<in T>?: the comparator by which the array is ordered. A null value indicates that the elements' natural ordering should be used. |
Return | |
---|---|
Int |
index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1) . The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found. |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the array contains elements that are not mutually comparable using the specified comparator, or the search key is not comparable to the elements of the array using this comparator. |
compare
static fun compare(
a: BooleanArray?,
b: BooleanArray?
): Int
Compares two boolean
arrays lexicographically.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Boolean.compare(boolean, boolean)
, at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(boolean[],boolean[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
:
<code>Arrays.equals(a, b) == (Arrays.compare(a, b) == 0) </code>
Parameters | |
---|---|
a |
BooleanArray?: the first array to compare |
b |
BooleanArray?: the second array to compare |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
compare
static fun compare(
a: BooleanArray,
aFromIndex: Int,
aToIndex: Int,
b: BooleanArray,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two boolean
arrays lexicographically over the specified ranges.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Boolean.compare(boolean, boolean)
, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(boolean[],int,int,boolean[],int,int)
for the definition of a common and proper prefix.)
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively:
<code>Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0) </code>
Parameters | |
---|---|
a |
BooleanArray: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
BooleanArray: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compare
static fun compare(
a: ByteArray?,
b: ByteArray?
): Int
Compares two byte
arrays lexicographically.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Byte.compare(byte, byte)
, at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(byte[],byte[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
:
<code>Arrays.equals(a, b) == (Arrays.compare(a, b) == 0) </code>
Parameters | |
---|---|
a |
ByteArray?: the first array to compare |
b |
ByteArray?: the second array to compare |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
compare
static fun compare(
a: ByteArray,
aFromIndex: Int,
aToIndex: Int,
b: ByteArray,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two byte
arrays lexicographically over the specified ranges.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Byte.compare(byte, byte)
, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(byte[],int,int,byte[],int,int)
for the definition of a common and proper prefix.)
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively:
<code>Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0) </code>
Parameters | |
---|---|
a |
ByteArray: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
ByteArray: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compare
static fun compare(
a: CharArray?,
b: CharArray?
): Int
Compares two char
arrays lexicographically.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Character.compare(char, char)
, at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(char[],char[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
:
<code>Arrays.equals(a, b) == (Arrays.compare(a, b) == 0) </code>
Parameters | |
---|---|
a |
CharArray?: the first array to compare |
b |
CharArray?: the second array to compare |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
compare
static fun compare(
a: CharArray,
aFromIndex: Int,
aToIndex: Int,
b: CharArray,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two char
arrays lexicographically over the specified ranges.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Character.compare(char, char)
, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(char[],int,int,char[],int,int)
for the definition of a common and proper prefix.)
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively:
<code>Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0) </code>
Parameters | |
---|---|
a |
CharArray: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
CharArray: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compare
static fun compare(
a: DoubleArray?,
b: DoubleArray?
): Int
Compares two double
arrays lexicographically.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Double.compare(double, double)
, at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(double[],double[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
:
<code>Arrays.equals(a, b) == (Arrays.compare(a, b) == 0) </code>
Parameters | |
---|---|
a |
DoubleArray?: the first array to compare |
b |
DoubleArray?: the second array to compare |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
compare
static fun compare(
a: DoubleArray,
aFromIndex: Int,
aToIndex: Int,
b: DoubleArray,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two double
arrays lexicographically over the specified ranges.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Double.compare(double, double)
, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(double[],int,int,double[],int,int)
for the definition of a common and proper prefix.)
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively:
<code>Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0) </code>
Parameters | |
---|---|
a |
DoubleArray: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
DoubleArray: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compare
static fun compare(
a: FloatArray?,
b: FloatArray?
): Int
Compares two float
arrays lexicographically.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Float.compare(float, float)
, at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(float[],float[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
:
<code>Arrays.equals(a, b) == (Arrays.compare(a, b) == 0) </code>
Parameters | |
---|---|
a |
FloatArray?: the first array to compare |
b |
FloatArray?: the second array to compare |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
compare
static fun compare(
a: FloatArray,
aFromIndex: Int,
aToIndex: Int,
b: FloatArray,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two float
arrays lexicographically over the specified ranges.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Float.compare(float, float)
, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(float[],int,int,float[],int,int)
for the definition of a common and proper prefix.)
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively:
<code>Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0) </code>
Parameters | |
---|---|
a |
FloatArray: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
FloatArray: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compare
static fun compare(
a: IntArray,
aFromIndex: Int,
aToIndex: Int,
b: IntArray,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two int
arrays lexicographically over the specified ranges.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Integer.compare(int, int)
, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(int[],int,int,int[],int,int)
for the definition of a common and proper prefix.)
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively:
<code>Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0) </code>
Parameters | |
---|---|
a |
IntArray: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
IntArray: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compare
static fun compare(
a: IntArray?,
b: IntArray?
): Int
Compares two int
arrays lexicographically.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Integer.compare(int, int)
, at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(int[],int[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
:
<code>Arrays.equals(a, b) == (Arrays.compare(a, b) == 0) </code>
Parameters | |
---|---|
a |
IntArray?: the first array to compare |
b |
IntArray?: the second array to compare |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
compare
static fun compare(
a: LongArray,
aFromIndex: Int,
aToIndex: Int,
b: LongArray,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two long
arrays lexicographically over the specified ranges.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Long.compare(long, long)
, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(long[],int,int,long[],int,int)
for the definition of a common and proper prefix.)
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively:
<code>Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0) </code>
Parameters | |
---|---|
a |
LongArray: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
LongArray: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compare
static fun compare(
a: LongArray?,
b: LongArray?
): Int
Compares two long
arrays lexicographically.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Long.compare(long, long)
, at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(long[],long[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
:
<code>Arrays.equals(a, b) == (Arrays.compare(a, b) == 0) </code>
Parameters | |
---|---|
a |
LongArray?: the first array to compare |
b |
LongArray?: the second array to compare |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
compare
static fun compare(
a: ShortArray,
aFromIndex: Int,
aToIndex: Int,
b: ShortArray,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two short
arrays lexicographically over the specified ranges.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Short.compare(short, short)
, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(short[],int,int,short[],int,int)
for the definition of a common and proper prefix.)
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively:
<code>Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0) </code>
Parameters | |
---|---|
a |
ShortArray: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
ShortArray: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compare
static fun compare(
a: ShortArray?,
b: ShortArray?
): Int
Compares two short
arrays lexicographically.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Short.compare(short, short)
, at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(short[],short[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
:
<code>Arrays.equals(a, b) == (Arrays.compare(a, b) == 0) </code>
Parameters | |
---|---|
a |
ShortArray?: the first array to compare |
b |
ShortArray?: the second array to compare |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
compare
static fun <T : Comparable<T>!> compare(
a: Array<T>,
aFromIndex: Int,
aToIndex: Int,
b: Array<T>,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two Object
arrays lexicographically over the specified ranges.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements of type T
at a relative index i
within the respective arrays that is the prefix length, as if by:
<code>Comparator.nullsFirst(Comparator.<T>naturalOrder()). compare(a[aFromIndex + i, b[bFromIndex + i]) </code>
mismatch(java.lang.Object[],int,int,java.lang.Object[],int,int)
for the definition of a common and proper prefix.)
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively:
<code>Arrays.equals(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == (Arrays.compare(a, aFromIndex, aToIndex, b, bFromIndex, bToIndex) == 0) </code>
Parameters | |
---|---|
a |
Array<T>: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
Array<T>: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
<T> |
the type of comparable array elements |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compare
static fun <T : Any!> compare(
a: Array<T>,
aFromIndex: Int,
aToIndex: Int,
b: Array<T>,
bFromIndex: Int,
bToIndex: Int,
cmp: Comparator<in T>
): Int
Compares two Object
arrays lexicographically over the specified ranges.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing with the specified comparator two elements at a relative index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(java.lang.Object[],int,int,java.lang.Object[],int,int)
for the definition of a common and proper prefix.)
Parameters | |
---|---|
a |
Array<T>: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
Array<T>: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
cmp |
Comparator<in T>: the comparator to compare array elements |
<T> |
the type of array elements |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array or the comparator is null |
compare
static fun <T : Comparable<T>!> compare(
a: Array<T>?,
b: Array<T>?
): Int
Compares two Object
arrays, within comparable elements, lexicographically.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements of type T
at an index i
within the respective arrays that is the prefix length, as if by:
<code>Comparator.nullsFirst(Comparator.<T>naturalOrder()). compare(a[i], b[i]) </code>
mismatch(java.lang.Object[],java.lang.Object[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal. A null
array element is considered lexicographically less than a non-null
array element. Two null
array elements are considered equal.
The comparison is consistent with equals
, more specifically the following holds for arrays a
and b
:
<code>Arrays.equals(a, b) == (Arrays.compare(a, b) == 0) </code>
Parameters | |
---|---|
a |
Array<T>?: the first array to compare |
b |
Array<T>?: the second array to compare |
<T> |
the type of comparable array elements |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
compare
static fun <T : Any!> compare(
a: Array<T>?,
b: Array<T>?,
cmp: Comparator<in T>
): Int
Compares two Object
arrays lexicographically using a specified comparator.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing with the specified comparator two elements at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(java.lang.Object[],java.lang.Object[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
Parameters | |
---|---|
a |
Array<T>?: the first array to compare |
b |
Array<T>?: the second array to compare |
cmp |
Comparator<in T>: the comparator to compare array elements |
<T> |
the type of array elements |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the comparator is null |
compareUnsigned
static fun compareUnsigned(
a: ByteArray?,
b: ByteArray?
): Int
Compares two byte
arrays lexicographically, numerically treating elements as unsigned.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Byte.compareUnsigned(byte, byte)
, at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(byte[],byte[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
Parameters | |
---|---|
a |
ByteArray?: the first array to compare |
b |
ByteArray?: the second array to compare |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
compareUnsigned
static fun compareUnsigned(
a: ByteArray,
aFromIndex: Int,
aToIndex: Int,
b: ByteArray,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two byte
arrays lexicographically over the specified ranges, numerically treating elements as unsigned.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Byte.compareUnsigned(byte, byte)
, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(byte[],int,int,byte[],int,int)
for the definition of a common and proper prefix.)
Parameters | |
---|---|
a |
ByteArray: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
ByteArray: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compareUnsigned
static fun compareUnsigned(
a: IntArray,
aFromIndex: Int,
aToIndex: Int,
b: IntArray,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two int
arrays lexicographically over the specified ranges, numerically treating elements as unsigned.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Integer.compareUnsigned(int, int)
, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(int[],int,int,int[],int,int)
for the definition of a common and proper prefix.)
Parameters | |
---|---|
a |
IntArray: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
IntArray: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compareUnsigned
static fun compareUnsigned(
a: IntArray?,
b: IntArray?
): Int
Compares two int
arrays lexicographically, numerically treating elements as unsigned.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Integer.compareUnsigned(int, int)
, at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(int[],int[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
Parameters | |
---|---|
a |
IntArray?: the first array to compare |
b |
IntArray?: the second array to compare |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
compareUnsigned
static fun compareUnsigned(
a: LongArray,
aFromIndex: Int,
aToIndex: Int,
b: LongArray,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two long
arrays lexicographically over the specified ranges, numerically treating elements as unsigned.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Long.compareUnsigned(long, long)
, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(long[],int,int,long[],int,int)
for the definition of a common and proper prefix.)
Parameters | |
---|---|
a |
LongArray: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
LongArray: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compareUnsigned
static fun compareUnsigned(
a: LongArray?,
b: LongArray?
): Int
Compares two long
arrays lexicographically, numerically treating elements as unsigned.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Long.compareUnsigned(long, long)
, at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(long[],long[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
Parameters | |
---|---|
a |
LongArray?: the first array to compare |
b |
LongArray?: the second array to compare |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
compareUnsigned
static fun compareUnsigned(
a: ShortArray,
aFromIndex: Int,
aToIndex: Int,
b: ShortArray,
bFromIndex: Int,
bToIndex: Int
): Int
Compares two short
arrays lexicographically over the specified ranges, numerically treating elements as unsigned.
If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Short.compareUnsigned(short, short)
, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See mismatch(short[],int,int,short[],int,int)
for the definition of a common and proper prefix.)
Parameters | |
---|---|
a |
ShortArray: the first array to compare |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be compared |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be compared |
b |
ShortArray: the second array to compare |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be compared |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be compared |
Return | |
---|---|
Int |
the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
compareUnsigned
static fun compareUnsigned(
a: ShortArray?,
b: ShortArray?
): Int
Compares two short
arrays lexicographically, numerically treating elements as unsigned.
If the two arrays share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Short.compareUnsigned(short, short)
, at an index within the respective arrays that is the prefix length. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two array lengths. (See mismatch(short[],short[])
for the definition of a common and proper prefix.)
A null
array reference is considered lexicographically less than a non-null
array reference. Two null
array references are considered equal.
Parameters | |
---|---|
a |
ShortArray?: the first array to compare |
b |
ShortArray?: the second array to compare |
Return | |
---|---|
Int |
the value 0 if the first and second array are equal and contain the same elements in the same order; a value less than 0 if the first array is lexicographically less than the second array; and a value greater than 0 if the first array is lexicographically greater than the second array |
copyOf
static fun copyOf(
original: BooleanArray,
newLength: Int
): BooleanArray
Copies the specified array, truncating or padding with false
(if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain false
. Such indices will exist if and only if the specified length is greater than that of the original array.
Parameters | |
---|---|
original |
BooleanArray: the array to be copied |
newLength |
Int: the length of the copy to be returned |
Return | |
---|---|
BooleanArray |
a copy of the original array, truncated or padded with false elements to obtain the specified length |
Exceptions | |
---|---|
java.lang.NegativeArraySizeException |
if newLength is negative |
java.lang.NullPointerException |
if original is null |
copyOf
static fun copyOf(
original: ByteArray,
newLength: Int
): ByteArray
Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain (byte)0
. Such indices will exist if and only if the specified length is greater than that of the original array.
Parameters | |
---|---|
original |
ByteArray: the array to be copied |
newLength |
Int: the length of the copy to be returned |
Return | |
---|---|
ByteArray |
a copy of the original array, truncated or padded with zeros to obtain the specified length |
Exceptions | |
---|---|
java.lang.NegativeArraySizeException |
if newLength is negative |
java.lang.NullPointerException |
if original is null |
copyOf
static fun copyOf(
original: CharArray,
newLength: Int
): CharArray
Copies the specified array, truncating or padding with null characters (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain '\u005cu0000'
. Such indices will exist if and only if the specified length is greater than that of the original array.
Parameters | |
---|---|
original |
CharArray: the array to be copied |
newLength |
Int: the length of the copy to be returned |
Return | |
---|---|
CharArray |
a copy of the original array, truncated or padded with null characters to obtain the specified length |
Exceptions | |
---|---|
java.lang.NegativeArraySizeException |
if newLength is negative |
java.lang.NullPointerException |
if original is null |
copyOf
static fun copyOf(
original: DoubleArray,
newLength: Int
): DoubleArray
Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain 0d
. Such indices will exist if and only if the specified length is greater than that of the original array.
Parameters | |
---|---|
original |
DoubleArray: the array to be copied |
newLength |
Int: the length of the copy to be returned |
Return | |
---|---|
DoubleArray |
a copy of the original array, truncated or padded with zeros to obtain the specified length |
Exceptions | |
---|---|
java.lang.NegativeArraySizeException |
if newLength is negative |
java.lang.NullPointerException |
if original is null |
copyOf
static fun copyOf(
original: FloatArray,
newLength: Int
): FloatArray
Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain 0f
. Such indices will exist if and only if the specified length is greater than that of the original array.
Parameters | |
---|---|
original |
FloatArray: the array to be copied |
newLength |
Int: the length of the copy to be returned |
Return | |
---|---|
FloatArray |
a copy of the original array, truncated or padded with zeros to obtain the specified length |
Exceptions | |
---|---|
java.lang.NegativeArraySizeException |
if newLength is negative |
java.lang.NullPointerException |
if original is null |
copyOf
static fun copyOf(
original: IntArray,
newLength: Int
): IntArray
Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain 0
. Such indices will exist if and only if the specified length is greater than that of the original array.
Parameters | |
---|---|
original |
IntArray: the array to be copied |
newLength |
Int: the length of the copy to be returned |
Return | |
---|---|
IntArray |
a copy of the original array, truncated or padded with zeros to obtain the specified length |
Exceptions | |
---|---|
java.lang.NegativeArraySizeException |
if newLength is negative |
java.lang.NullPointerException |
if original is null |
copyOf
static fun copyOf(
original: LongArray,
newLength: Int
): LongArray
Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain 0L
. Such indices will exist if and only if the specified length is greater than that of the original array.
Parameters | |
---|---|
original |
LongArray: the array to be copied |
newLength |
Int: the length of the copy to be returned |
Return | |
---|---|
LongArray |
a copy of the original array, truncated or padded with zeros to obtain the specified length |
Exceptions | |
---|---|
java.lang.NegativeArraySizeException |
if newLength is negative |
java.lang.NullPointerException |
if original is null |
copyOf
static fun copyOf(
original: ShortArray,
newLength: Int
): ShortArray
Copies the specified array, truncating or padding with zeros (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain (short)0
. Such indices will exist if and only if the specified length is greater than that of the original array.
Parameters | |
---|---|
original |
ShortArray: the array to be copied |
newLength |
Int: the length of the copy to be returned |
Return | |
---|---|
ShortArray |
a copy of the original array, truncated or padded with zeros to obtain the specified length |
Exceptions | |
---|---|
java.lang.NegativeArraySizeException |
if newLength is negative |
java.lang.NullPointerException |
if original is null |
copyOf
static fun <T : Any!> copyOf(
original: Array<T>,
newLength: Int
): Array<T>
Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain null
. Such indices will exist if and only if the specified length is greater than that of the original array. The resulting array is of exactly the same class as the original array.
Parameters | |
---|---|
<T> |
the class of the objects in the array |
original |
Array<T>: the array to be copied |
newLength |
Int: the length of the copy to be returned |
Return | |
---|---|
Array<T> |
a copy of the original array, truncated or padded with nulls to obtain the specified length |
Exceptions | |
---|---|
java.lang.NegativeArraySizeException |
if newLength is negative |
java.lang.NullPointerException |
if original is null |
copyOf
static fun <T : Any!, U : Any!> copyOf(
original: Array<U>,
newLength: Int,
newType: Class<out Array<T>!>
): Array<T>
Copies the specified array, truncating or padding with nulls (if necessary) so the copy has the specified length. For all indices that are valid in both the original array and the copy, the two arrays will contain identical values. For any indices that are valid in the copy but not the original, the copy will contain null
. Such indices will exist if and only if the specified length is greater than that of the original array. The resulting array is of the class newType
.
Parameters | |
---|---|
<U> |
the class of the objects in the original array |
<T> |
the class of the objects in the returned array |
original |
Array<U>: the array to be copied |
newLength |
Int: the length of the copy to be returned |
newType |
Class<out Array<T>!>: the class of the copy to be returned |
Return | |
---|---|
Array<T> |
a copy of the original array, truncated or padded with nulls to obtain the specified length |
Exceptions | |
---|---|
java.lang.NegativeArraySizeException |
if newLength is negative |
java.lang.NullPointerException |
if original is null |
java.lang.ArrayStoreException |
if an element copied from original is not of a runtime type that can be stored in an array of class newType |
copyOfRange
static fun copyOfRange(
original: BooleanArray,
from: Int,
to: Int
): BooleanArray
Copies the specified range of the specified array into a new array. The initial index of the range (from
) must lie between zero and original.length
, inclusive. The value at original[from]
is placed into the initial element of the copy (unless from == original.length
or from == to
). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to
), which must be greater than or equal to from
, may be greater than original.length
, in which case false
is placed in all elements of the copy whose index is greater than or equal to original.length - from
. The length of the returned array will be to - from
.
Parameters | |
---|---|
original |
BooleanArray: the array from which a range is to be copied |
from |
Int: the initial index of the range to be copied, inclusive |
to |
Int: the final index of the range to be copied, exclusive. (This index may lie outside the array.) |
Return | |
---|---|
BooleanArray |
a new array containing the specified range from the original array, truncated or padded with false elements to obtain the required length |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if from < 0 or from > original.length |
java.lang.IllegalArgumentException |
if from > to |
java.lang.NullPointerException |
if original is null |
copyOfRange
static fun copyOfRange(
original: ByteArray,
from: Int,
to: Int
): ByteArray
Copies the specified range of the specified array into a new array. The initial index of the range (from
) must lie between zero and original.length
, inclusive. The value at original[from]
is placed into the initial element of the copy (unless from == original.length
or from == to
). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to
), which must be greater than or equal to from
, may be greater than original.length
, in which case (byte)0
is placed in all elements of the copy whose index is greater than or equal to original.length - from
. The length of the returned array will be to - from
.
Parameters | |
---|---|
original |
ByteArray: the array from which a range is to be copied |
from |
Int: the initial index of the range to be copied, inclusive |
to |
Int: the final index of the range to be copied, exclusive. (This index may lie outside the array.) |
Return | |
---|---|
ByteArray |
a new array containing the specified range from the original array, truncated or padded with zeros to obtain the required length |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if from < 0 or from > original.length |
java.lang.IllegalArgumentException |
if from > to |
java.lang.NullPointerException |
if original is null |
copyOfRange
static fun copyOfRange(
original: CharArray,
from: Int,
to: Int
): CharArray
Copies the specified range of the specified array into a new array. The initial index of the range (from
) must lie between zero and original.length
, inclusive. The value at original[from]
is placed into the initial element of the copy (unless from == original.length
or from == to
). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to
), which must be greater than or equal to from
, may be greater than original.length
, in which case '\u005cu0000'
is placed in all elements of the copy whose index is greater than or equal to original.length - from
. The length of the returned array will be to - from
.
Parameters | |
---|---|
original |
CharArray: the array from which a range is to be copied |
from |
Int: the initial index of the range to be copied, inclusive |
to |
Int: the final index of the range to be copied, exclusive. (This index may lie outside the array.) |
Return | |
---|---|
CharArray |
a new array containing the specified range from the original array, truncated or padded with null characters to obtain the required length |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if from < 0 or from > original.length |
java.lang.IllegalArgumentException |
if from > to |
java.lang.NullPointerException |
if original is null |
copyOfRange
static fun copyOfRange(
original: DoubleArray,
from: Int,
to: Int
): DoubleArray
Copies the specified range of the specified array into a new array. The initial index of the range (from
) must lie between zero and original.length
, inclusive. The value at original[from]
is placed into the initial element of the copy (unless from == original.length
or from == to
). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to
), which must be greater than or equal to from
, may be greater than original.length
, in which case 0d
is placed in all elements of the copy whose index is greater than or equal to original.length - from
. The length of the returned array will be to - from
.
Parameters | |
---|---|
original |
DoubleArray: the array from which a range is to be copied |
from |
Int: the initial index of the range to be copied, inclusive |
to |
Int: the final index of the range to be copied, exclusive. (This index may lie outside the array.) |
Return | |
---|---|
DoubleArray |
a new array containing the specified range from the original array, truncated or padded with zeros to obtain the required length |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if from < 0 or from > original.length |
java.lang.IllegalArgumentException |
if from > to |
java.lang.NullPointerException |
if original is null |
copyOfRange
static fun copyOfRange(
original: FloatArray,
from: Int,
to: Int
): FloatArray
Copies the specified range of the specified array into a new array. The initial index of the range (from
) must lie between zero and original.length
, inclusive. The value at original[from]
is placed into the initial element of the copy (unless from == original.length
or from == to
). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to
), which must be greater than or equal to from
, may be greater than original.length
, in which case 0f
is placed in all elements of the copy whose index is greater than or equal to original.length - from
. The length of the returned array will be to - from
.
Parameters | |
---|---|
original |
FloatArray: the array from which a range is to be copied |
from |
Int: the initial index of the range to be copied, inclusive |
to |
Int: the final index of the range to be copied, exclusive. (This index may lie outside the array.) |
Return | |
---|---|
FloatArray |
a new array containing the specified range from the original array, truncated or padded with zeros to obtain the required length |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if from < 0 or from > original.length |
java.lang.IllegalArgumentException |
if from > to |
java.lang.NullPointerException |
if original is null |
copyOfRange
static fun copyOfRange(
original: IntArray,
from: Int,
to: Int
): IntArray
Copies the specified range of the specified array into a new array. The initial index of the range (from
) must lie between zero and original.length
, inclusive. The value at original[from]
is placed into the initial element of the copy (unless from == original.length
or from == to
). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to
), which must be greater than or equal to from
, may be greater than original.length
, in which case 0
is placed in all elements of the copy whose index is greater than or equal to original.length - from
. The length of the returned array will be to - from
.
Parameters | |
---|---|
original |
IntArray: the array from which a range is to be copied |
from |
Int: the initial index of the range to be copied, inclusive |
to |
Int: the final index of the range to be copied, exclusive. (This index may lie outside the array.) |
Return | |
---|---|
IntArray |
a new array containing the specified range from the original array, truncated or padded with zeros to obtain the required length |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if from < 0 or from > original.length |
java.lang.IllegalArgumentException |
if from > to |
java.lang.NullPointerException |
if original is null |
copyOfRange
static fun copyOfRange(
original: LongArray,
from: Int,
to: Int
): LongArray
Copies the specified range of the specified array into a new array. The initial index of the range (from
) must lie between zero and original.length
, inclusive. The value at original[from]
is placed into the initial element of the copy (unless from == original.length
or from == to
). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to
), which must be greater than or equal to from
, may be greater than original.length
, in which case 0L
is placed in all elements of the copy whose index is greater than or equal to original.length - from
. The length of the returned array will be to - from
.
Parameters | |
---|---|
original |
LongArray: the array from which a range is to be copied |
from |
Int: the initial index of the range to be copied, inclusive |
to |
Int: the final index of the range to be copied, exclusive. (This index may lie outside the array.) |
Return | |
---|---|
LongArray |
a new array containing the specified range from the original array, truncated or padded with zeros to obtain the required length |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if from < 0 or from > original.length |
java.lang.IllegalArgumentException |
if from > to |
java.lang.NullPointerException |
if original is null |
copyOfRange
static fun copyOfRange(
original: ShortArray,
from: Int,
to: Int
): ShortArray
Copies the specified range of the specified array into a new array. The initial index of the range (from
) must lie between zero and original.length
, inclusive. The value at original[from]
is placed into the initial element of the copy (unless from == original.length
or from == to
). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to
), which must be greater than or equal to from
, may be greater than original.length
, in which case (short)0
is placed in all elements of the copy whose index is greater than or equal to original.length - from
. The length of the returned array will be to - from
.
Parameters | |
---|---|
original |
ShortArray: the array from which a range is to be copied |
from |
Int: the initial index of the range to be copied, inclusive |
to |
Int: the final index of the range to be copied, exclusive. (This index may lie outside the array.) |
Return | |
---|---|
ShortArray |
a new array containing the specified range from the original array, truncated or padded with zeros to obtain the required length |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if from < 0 or from > original.length |
java.lang.IllegalArgumentException |
if from > to |
java.lang.NullPointerException |
if original is null |
copyOfRange
static fun <T : Any!> copyOfRange(
original: Array<T>,
from: Int,
to: Int
): Array<T>
Copies the specified range of the specified array into a new array. The initial index of the range (from
) must lie between zero and original.length
, inclusive. The value at original[from]
is placed into the initial element of the copy (unless from == original.length
or from == to
). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to
), which must be greater than or equal to from
, may be greater than original.length
, in which case null
is placed in all elements of the copy whose index is greater than or equal to original.length - from
. The length of the returned array will be to - from
.
The resulting array is of exactly the same class as the original array.
Parameters | |
---|---|
<T> |
the class of the objects in the array |
original |
Array<T>: the array from which a range is to be copied |
from |
Int: the initial index of the range to be copied, inclusive |
to |
Int: the final index of the range to be copied, exclusive. (This index may lie outside the array.) |
Return | |
---|---|
Array<T> |
a new array containing the specified range from the original array, truncated or padded with nulls to obtain the required length |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if from < 0 or from > original.length |
java.lang.IllegalArgumentException |
if from > to |
java.lang.NullPointerException |
if original is null |
copyOfRange
static fun <T : Any!, U : Any!> copyOfRange(
original: Array<U>,
from: Int,
to: Int,
newType: Class<out Array<T>!>
): Array<T>
Copies the specified range of the specified array into a new array. The initial index of the range (from
) must lie between zero and original.length
, inclusive. The value at original[from]
is placed into the initial element of the copy (unless from == original.length
or from == to
). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to
), which must be greater than or equal to from
, may be greater than original.length
, in which case null
is placed in all elements of the copy whose index is greater than or equal to original.length - from
. The length of the returned array will be to - from
. The resulting array is of the class newType
.
Parameters | |
---|---|
<U> |
the class of the objects in the original array |
<T> |
the class of the objects in the returned array |
original |
Array<U>: the array from which a range is to be copied |
from |
Int: the initial index of the range to be copied, inclusive |
to |
Int: the final index of the range to be copied, exclusive. (This index may lie outside the array.) |
newType |
Class<out Array<T>!>: the class of the copy to be returned |
Return | |
---|---|
Array<T> |
a new array containing the specified range from the original array, truncated or padded with nulls to obtain the required length |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if from < 0 or from > original.length |
java.lang.IllegalArgumentException |
if from > to |
java.lang.NullPointerException |
if original is null |
java.lang.ArrayStoreException |
if an element copied from original is not of a runtime type that can be stored in an array of class newType . |
deepEquals
static fun deepEquals(
a1: Array<Any!>?,
a2: Array<Any!>?
): Boolean
Returns true
if the two specified arrays are deeply equal to one another. Unlike the equals(java.lang.Object[],java.lang.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
ande2
are both arrays of object reference types, andArrays.deepEquals(e1, e2) would return true
-
e1
ande2
are arrays of the same primitive type, and the appropriate overloading ofArrays.equals(e1, e2)
would return true. -
e1 == e2
-
e1.equals(e2)
would return true.
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.
Parameters | |
---|---|
a1 |
Array<Any!>?: one array to be tested for equality |
a2 |
Array<Any!>?: the other array to be tested for equality |
Return | |
---|---|
Boolean |
true if the two arrays are equal |
deepHashCode
static fun deepHashCode(a: Array<Any!>?): Int
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 java.util.List#hashCode() 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.
Parameters | |
---|---|
a |
Array<Any!>?: the array whose deep-content-based hash code to compute |
Return | |
---|---|
Int |
a deep-content-based hash code for a |
See Also
deepToString
static fun deepToString(a: Array<Any!>?): String
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
.
Parameters | |
---|---|
a |
Array<Any!>?: the array whose string representation to return |
Return | |
---|---|
String |
a string representation of a |
See Also
equals
static fun equals(
a: BooleanArray?,
a2: BooleanArray?
): Boolean
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
.
Parameters | |
---|---|
a |
BooleanArray?: one array to be tested for equality |
a2 |
BooleanArray?: the other array to be tested for equality |
Return | |
---|---|
Boolean |
true if the two arrays are equal |
equals
static fun equals(
a: BooleanArray,
aFromIndex: Int,
aToIndex: Int,
b: BooleanArray,
bFromIndex: Int,
bToIndex: Int
): Boolean
Returns true if the two specified arrays of booleans, over the specified ranges, are equal to one another.
Two arrays are considered equal if the number of elements covered by each range is the same, and all corresponding pairs of elements over the specified ranges in the two arrays are equal. In other words, two arrays are equal if they contain, over the specified ranges, the same elements in the same order.
Parameters | |
---|---|
a |
BooleanArray: the first array to be tested for equality |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
BooleanArray: the second array to be tested for equality |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Boolean |
true if the two arrays, over the specified ranges, are equal |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
equals
static fun equals(
a: ByteArray?,
a2: ByteArray?
): Boolean
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
.
Parameters | |
---|---|
a |
ByteArray?: one array to be tested for equality |
a2 |
ByteArray?: the other array to be tested for equality |
Return | |
---|---|
Boolean |
true if the two arrays are equal |
equals
static fun equals(
a: ByteArray,
aFromIndex: Int,
aToIndex: Int,
b: ByteArray,
bFromIndex: Int,
bToIndex: Int
): Boolean
Returns true if the two specified arrays of bytes, over the specified ranges, are equal to one another.
Two arrays are considered equal if the number of elements covered by each range is the same, and all corresponding pairs of elements over the specified ranges in the two arrays are equal. In other words, two arrays are equal if they contain, over the specified ranges, the same elements in the same order.
Parameters | |
---|---|
a |
ByteArray: the first array to be tested for equality |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
ByteArray: the second array to be tested for equality |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Boolean |
true if the two arrays, over the specified ranges, are equal |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
equals
static fun equals(
a: CharArray?,
a2: CharArray?
): Boolean
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
.
Parameters | |
---|---|
a |
CharArray?: one array to be tested for equality |
a2 |
CharArray?: the other array to be tested for equality |
Return | |
---|---|
Boolean |
true if the two arrays are equal |
equals
static fun equals(
a: CharArray,
aFromIndex: Int,
aToIndex: Int,
b: CharArray,
bFromIndex: Int,
bToIndex: Int
): Boolean
Returns true if the two specified arrays of chars, over the specified ranges, are equal to one another.
Two arrays are considered equal if the number of elements covered by each range is the same, and all corresponding pairs of elements over the specified ranges in the two arrays are equal. In other words, two arrays are equal if they contain, over the specified ranges, the same elements in the same order.
Parameters | |
---|---|
a |
CharArray: the first array to be tested for equality |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
CharArray: the second array to be tested for equality |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Boolean |
true if the two arrays, over the specified ranges, are equal |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
equals
static fun equals(
a: DoubleArray?,
a2: DoubleArray?
): Boolean
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:
<code>Double.valueOf(d1).equals(Double.valueOf(d2))</code>
==
operator, this method considers NaN
equal to itself, and 0.0d unequal to -0.0d.)
Parameters | |
---|---|
a |
DoubleArray?: one array to be tested for equality |
a2 |
DoubleArray?: the other array to be tested for equality |
Return | |
---|---|
Boolean |
true if the two arrays are equal |
See Also
equals
static fun equals(
a: DoubleArray,
aFromIndex: Int,
aToIndex: Int,
b: DoubleArray,
bFromIndex: Int,
bToIndex: Int
): Boolean
Returns true if the two specified arrays of doubles, over the specified ranges, are equal to one another.
Two arrays are considered equal if the number of elements covered by each range is the same, and all corresponding pairs of elements over the specified ranges in the two arrays are equal. In other words, two arrays are equal if they contain, over the specified ranges, the same elements in the same order.
Two doubles d1
and d2
are considered equal if:
<code>Double.valueOf(d1).equals(Double.valueOf(d2))</code>
==
operator, this method considers NaN
equal to itself, and 0.0d unequal to -0.0d.)
Parameters | |
---|---|
a |
DoubleArray: the first array to be tested for equality |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
DoubleArray: the second array to be tested for equality |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Boolean |
true if the two arrays, over the specified ranges, are equal |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
See Also
equals
static fun equals(
a: FloatArray?,
a2: FloatArray?
): Boolean
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:
<code>Float.valueOf(f1).equals(Float.valueOf(f2))</code>
==
operator, this method considers NaN
equal to itself, and 0.0f unequal to -0.0f.)
Parameters | |
---|---|
a |
FloatArray?: one array to be tested for equality |
a2 |
FloatArray?: the other array to be tested for equality |
Return | |
---|---|
Boolean |
true if the two arrays are equal |
See Also
equals
static fun equals(
a: FloatArray,
aFromIndex: Int,
aToIndex: Int,
b: FloatArray,
bFromIndex: Int,
bToIndex: Int
): Boolean
Returns true if the two specified arrays of floats, over the specified ranges, are equal to one another.
Two arrays are considered equal if the number of elements covered by each range is the same, and all corresponding pairs of elements over the specified ranges in the two arrays are equal. In other words, two arrays are equal if they contain, over the specified ranges, the same elements in the same order.
Two floats f1
and f2
are considered equal if:
<code>Float.valueOf(f1).equals(Float.valueOf(f2))</code>
==
operator, this method considers NaN
equal to itself, and 0.0f unequal to -0.0f.)
Parameters | |
---|---|
a |
FloatArray: the first array to be tested for equality |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
FloatArray: the second array to be tested for equality |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Boolean |
true if the two arrays, over the specified ranges, are equal |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
See Also
equals
static fun equals(
a: IntArray,
aFromIndex: Int,
aToIndex: Int,
b: IntArray,
bFromIndex: Int,
bToIndex: Int
): Boolean
Returns true if the two specified arrays of ints, over the specified ranges, are equal to one another.
Two arrays are considered equal if the number of elements covered by each range is the same, and all corresponding pairs of elements over the specified ranges in the two arrays are equal. In other words, two arrays are equal if they contain, over the specified ranges, the same elements in the same order.
Parameters | |
---|---|
a |
IntArray: the first array to be tested for equality |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
IntArray: the second array to be tested for equality |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Boolean |
true if the two arrays, over the specified ranges, are equal |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
equals
static fun equals(
a: IntArray?,
a2: IntArray?
): Boolean
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
.
Parameters | |
---|---|
a |
IntArray?: one array to be tested for equality |
a2 |
IntArray?: the other array to be tested for equality |
Return | |
---|---|
Boolean |
true if the two arrays are equal |
equals
static fun equals(
a: Array<Any!>,
aFromIndex: Int,
aToIndex: Int,
b: Array<Any!>,
bFromIndex: Int,
bToIndex: Int
): Boolean
Returns true if the two specified arrays of Objects, over the specified ranges, are equal to one another.
Two arrays are considered equal if the number of elements covered by each range is the same, and all corresponding pairs of elements over the specified ranges in the two arrays are equal. In other words, two arrays are equal if they contain, over the specified ranges, the same elements in the same order.
Two objects e1
and e2
are considered equal if Objects.equals(e1, e2)
.
Parameters | |
---|---|
a |
Array<Any!>: the first array to be tested for equality |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
Array<Any!>: the second array to be tested for equality |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Boolean |
true if the two arrays, over the specified ranges, are equal |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
equals
static fun equals(
a: Array<Any!>?,
a2: Array<Any!>?
): Boolean
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 Objects.equals(e1, 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
.
Parameters | |
---|---|
a |
Array<Any!>?: one array to be tested for equality |
a2 |
Array<Any!>?: the other array to be tested for equality |
Return | |
---|---|
Boolean |
true if the two arrays are equal |
equals
static fun equals(
a: LongArray,
aFromIndex: Int,
aToIndex: Int,
b: LongArray,
bFromIndex: Int,
bToIndex: Int
): Boolean
Returns true if the two specified arrays of longs, over the specified ranges, are equal to one another.
Two arrays are considered equal if the number of elements covered by each range is the same, and all corresponding pairs of elements over the specified ranges in the two arrays are equal. In other words, two arrays are equal if they contain, over the specified ranges, the same elements in the same order.
Parameters | |
---|---|
a |
LongArray: the first array to be tested for equality |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
LongArray: the second array to be tested for equality |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Boolean |
true if the two arrays, over the specified ranges, are equal |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
equals
static fun equals(
a: LongArray?,
a2: LongArray?
): Boolean
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
.
Parameters | |
---|---|
a |
LongArray?: one array to be tested for equality |
a2 |
LongArray?: the other array to be tested for equality |
Return | |
---|---|
Boolean |
true if the two arrays are equal |
equals
static fun equals(
a: ShortArray,
aFromIndex: Int,
aToIndex: Int,
b: ShortArray,
bFromIndex: Int,
bToIndex: Int
): Boolean
Returns true if the two specified arrays of shorts, over the specified ranges, are equal to one another.
Two arrays are considered equal if the number of elements covered by each range is the same, and all corresponding pairs of elements over the specified ranges in the two arrays are equal. In other words, two arrays are equal if they contain, over the specified ranges, the same elements in the same order.
Parameters | |
---|---|
a |
ShortArray: the first array to be tested for equality |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
ShortArray: the second array to be tested for equality |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Boolean |
true if the two arrays, over the specified ranges, are equal |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
equals
static fun equals(
a: ShortArray?,
a2: ShortArray?
): Boolean
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
.
Parameters | |
---|---|
a |
ShortArray?: one array to be tested for equality |
a2 |
ShortArray?: the other array to be tested for equality |
Return | |
---|---|
Boolean |
true if the two arrays are equal |
equals
static fun <T : Any!> equals(
a: Array<T>,
aFromIndex: Int,
aToIndex: Int,
b: Array<T>,
bFromIndex: Int,
bToIndex: Int,
cmp: Comparator<in T>
): Boolean
Returns true if the two specified arrays of Objects, over the specified ranges, are equal to one another.
Two arrays are considered equal if the number of elements covered by each range is the same, and all corresponding pairs of elements over the specified ranges in the two arrays are equal. In other words, two arrays are equal if they contain, over the specified ranges, the same elements in the same order.
Two objects e1
and e2
are considered equal if, given the specified comparator, cmp.compare(e1, e2) == 0
.
Parameters | |
---|---|
a |
Array<T>: the first array to be tested for equality |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
Array<T>: the second array to be tested for equality |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
cmp |
Comparator<in T>: the comparator to compare array elements |
<T> |
the type of array elements |
Return | |
---|---|
Boolean |
true if the two arrays, over the specified ranges, are equal |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array or the comparator is null |
equals
static fun <T : Any!> equals(
a: Array<T>?,
a2: Array<T>?,
cmp: Comparator<in T>
): Boolean
Returns true
if the two specified arrays of Objects 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, 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
.
Two objects e1
and e2
are considered equal if, given the specified comparator, cmp.compare(e1, e2) == 0
.
Parameters | |
---|---|
a |
Array<T>?: one array to be tested for equality |
a2 |
Array<T>?: the other array to be tested for equality |
cmp |
Comparator<in T>: the comparator to compare array elements |
<T> |
the type of array elements |
Return | |
---|---|
Boolean |
true if the two arrays are equal |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the comparator is null |
fill
static fun fill(
a: BooleanArray,
val: Boolean
): Unit
Assigns the specified boolean value to each element of the specified array of booleans.
Parameters | |
---|---|
a |
BooleanArray: the array to be filled |
val |
Boolean: the value to be stored in all elements of the array |
fill
static fun fill(
a: BooleanArray,
fromIndex: Int,
toIndex: Int,
val: Boolean
): Unit
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.)
Parameters | |
---|---|
a |
BooleanArray: the array to be filled |
fromIndex |
Int: the index of the first element (inclusive) to be filled with the specified value |
toIndex |
Int: the index of the last element (exclusive) to be filled with the specified value |
val |
Boolean: the value to be stored in all elements of the array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
fill
static fun fill(
a: ByteArray,
val: Byte
): Unit
Assigns the specified byte value to each element of the specified array of bytes.
Parameters | |
---|---|
a |
ByteArray: the array to be filled |
val |
Byte: the value to be stored in all elements of the array |
fill
static fun fill(
a: ByteArray,
fromIndex: Int,
toIndex: Int,
val: Byte
): Unit
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.)
Parameters | |
---|---|
a |
ByteArray: the array to be filled |
fromIndex |
Int: the index of the first element (inclusive) to be filled with the specified value |
toIndex |
Int: the index of the last element (exclusive) to be filled with the specified value |
val |
Byte: the value to be stored in all elements of the array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
fill
static fun fill(
a: CharArray,
val: Char
): Unit
Assigns the specified char value to each element of the specified array of chars.
Parameters | |
---|---|
a |
CharArray: the array to be filled |
val |
Char: the value to be stored in all elements of the array |
fill
static fun fill(
a: CharArray,
fromIndex: Int,
toIndex: Int,
val: Char
): Unit
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.)
Parameters | |
---|---|
a |
CharArray: the array to be filled |
fromIndex |
Int: the index of the first element (inclusive) to be filled with the specified value |
toIndex |
Int: the index of the last element (exclusive) to be filled with the specified value |
val |
Char: the value to be stored in all elements of the array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
fill
static fun fill(
a: DoubleArray,
val: Double
): Unit
Assigns the specified double value to each element of the specified array of doubles.
Parameters | |
---|---|
a |
DoubleArray: the array to be filled |
val |
Double: the value to be stored in all elements of the array |
fill
static fun fill(
a: DoubleArray,
fromIndex: Int,
toIndex: Int,
val: Double
): Unit
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.)
Parameters | |
---|---|
a |
DoubleArray: the array to be filled |
fromIndex |
Int: the index of the first element (inclusive) to be filled with the specified value |
toIndex |
Int: the index of the last element (exclusive) to be filled with the specified value |
val |
Double: the value to be stored in all elements of the array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
fill
static fun fill(
a: FloatArray,
val: Float
): Unit
Assigns the specified float value to each element of the specified array of floats.
Parameters | |
---|---|
a |
FloatArray: the array to be filled |
val |
Float: the value to be stored in all elements of the array |
fill
static fun fill(
a: FloatArray,
fromIndex: Int,
toIndex: Int,
val: Float
): Unit
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.)
Parameters | |
---|---|
a |
FloatArray: the array to be filled |
fromIndex |
Int: the index of the first element (inclusive) to be filled with the specified value |
toIndex |
Int: the index of the last element (exclusive) to be filled with the specified value |
val |
Float: the value to be stored in all elements of the array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
fill
static fun fill(
a: IntArray,
val: Int
): Unit
Assigns the specified int value to each element of the specified array of ints.
Parameters | |
---|---|
a |
IntArray: the array to be filled |
val |
Int: the value to be stored in all elements of the array |
fill
static fun fill(
a: IntArray,
fromIndex: Int,
toIndex: Int,
val: Int
): Unit
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.)
Parameters | |
---|---|
a |
IntArray: the array to be filled |
fromIndex |
Int: the index of the first element (inclusive) to be filled with the specified value |
toIndex |
Int: the index of the last element (exclusive) to be filled with the specified value |
val |
Int: the value to be stored in all elements of the array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
fill
static fun fill(
a: Array<Any!>,
fromIndex: Int,
toIndex: Int,
val: Any?
): Unit
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.)
Parameters | |
---|---|
a |
Array<Any!>: the array to be filled |
fromIndex |
Int: the index of the first element (inclusive) to be filled with the specified value |
toIndex |
Int: the index of the last element (exclusive) to be filled with the specified value |
val |
Any?: the value to be stored in all elements of the array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
java.lang.ArrayStoreException |
if the specified value is not of a runtime type that can be stored in the specified array |
fill
static fun fill(
a: Array<Any!>,
val: Any?
): Unit
Assigns the specified Object reference to each element of the specified array of Objects.
Parameters | |
---|---|
a |
Array<Any!>: the array to be filled |
val |
Any?: the value to be stored in all elements of the array |
Exceptions | |
---|---|
java.lang.ArrayStoreException |
if the specified value is not of a runtime type that can be stored in the specified array |
fill
static fun fill(
a: LongArray,
fromIndex: Int,
toIndex: Int,
val: Long
): Unit
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.)
Parameters | |
---|---|
a |
LongArray: the array to be filled |
fromIndex |
Int: the index of the first element (inclusive) to be filled with the specified value |
toIndex |
Int: the index of the last element (exclusive) to be filled with the specified value |
val |
Long: the value to be stored in all elements of the array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
fill
static fun fill(
a: LongArray,
val: Long
): Unit
Assigns the specified long value to each element of the specified array of longs.
Parameters | |
---|---|
a |
LongArray: the array to be filled |
val |
Long: the value to be stored in all elements of the array |
fill
static fun fill(
a: ShortArray,
fromIndex: Int,
toIndex: Int,
val: Short
): Unit
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.)
Parameters | |
---|---|
a |
ShortArray: the array to be filled |
fromIndex |
Int: the index of the first element (inclusive) to be filled with the specified value |
toIndex |
Int: the index of the last element (exclusive) to be filled with the specified value |
val |
Short: the value to be stored in all elements of the array |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
fill
static fun fill(
a: ShortArray,
val: Short
): Unit
Assigns the specified short value to each element of the specified array of shorts.
Parameters | |
---|---|
a |
ShortArray: the array to be filled |
val |
Short: the value to be stored in all elements of the array |
hashCode
static fun hashCode(a: BooleanArray?): Int
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 java.util.List#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.
Parameters | |
---|---|
a |
BooleanArray?: the array whose hash value to compute |
Return | |
---|---|
Int |
a content-based hash code for a |
hashCode
static fun hashCode(a: ByteArray?): Int
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 java.util.List#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.
Parameters | |
---|---|
a |
ByteArray?: the array whose hash value to compute |
Return | |
---|---|
Int |
a content-based hash code for a |
hashCode
static fun hashCode(a: CharArray?): Int
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 java.util.List#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.
Parameters | |
---|---|
a |
CharArray?: the array whose hash value to compute |
Return | |
---|---|
Int |
a content-based hash code for a |
hashCode
static fun hashCode(a: DoubleArray?): Int
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 java.util.List#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.
Parameters | |
---|---|
a |
DoubleArray?: the array whose hash value to compute |
Return | |
---|---|
Int |
a content-based hash code for a |
hashCode
static fun hashCode(a: FloatArray?): Int
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 java.util.List#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.
Parameters | |
---|---|
a |
FloatArray?: the array whose hash value to compute |
Return | |
---|---|
Int |
a content-based hash code for a |
hashCode
static fun hashCode(a: IntArray?): Int
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 java.util.List#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.
Parameters | |
---|---|
a |
IntArray?: the array whose hash value to compute |
Return | |
---|---|
Int |
a content-based hash code for a |
hashCode
static fun hashCode(a: Array<Any!>?): Int
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.
Parameters | |
---|---|
a |
Array<Any!>?: the array whose content-based hash code to compute |
Return | |
---|---|
Int |
a content-based hash code for a |
See Also
hashCode
static fun hashCode(a: LongArray?): Int
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 java.util.List#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.
Parameters | |
---|---|
a |
LongArray?: the array whose hash value to compute |
Return | |
---|---|
Int |
a content-based hash code for a |
hashCode
static fun hashCode(a: ShortArray?): Int
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 java.util.List#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.
Parameters | |
---|---|
a |
ShortArray?: the array whose hash value to compute |
Return | |
---|---|
Int |
a content-based hash code for a |
mismatch
static fun mismatch(
a: BooleanArray,
b: BooleanArray
): Int
Finds and returns the index of the first mismatch between two boolean
arrays, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller array.
If the two arrays share a common prefix then the returned index is the length of the common prefix and it follows that there is a mismatch between the two elements at that index within the respective arrays. If one array is a proper prefix of the other then the returned index is the length of the smaller array and it follows that the index is only valid for the larger array. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(a.length, b.length) && Arrays.equals(a, 0, pl, b, 0, pl) && a[pl] != b[pl] </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
, share a proper prefix if the following expression is true:
<code>a.length != b.length && Arrays.equals(a, 0, Math.min(a.length, b.length), b, 0, Math.min(a.length, b.length)) </code>
Parameters | |
---|---|
a |
BooleanArray: the first array to be tested for a mismatch |
b |
BooleanArray: the second array to be tested for a mismatch |
Return | |
---|---|
Int |
the index of the first mismatch between the two arrays, otherwise -1 . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: BooleanArray,
aFromIndex: Int,
aToIndex: Int,
b: BooleanArray,
bFromIndex: Int,
bToIndex: Int
): Int
Finds and returns the relative index of the first mismatch between two boolean
arrays over the specified ranges, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller range.
If the two arrays, over the specified ranges, share a common prefix then the returned relative index is the length of the common prefix and it follows that there is a mismatch between the two elements at that relative index within the respective arrays. If one array is a proper prefix of the other, over the specified ranges, then the returned relative index is the length of the smaller range and it follows that the relative index is only valid for the array with the larger range. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex) && Arrays.equals(a, aFromIndex, aFromIndex + pl, b, bFromIndex, bFromIndex + pl) && a[aFromIndex + pl] != b[bFromIndex + pl] </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a proper prefix if the following expression is true:
<code>(aToIndex - aFromIndex) != (bToIndex - bFromIndex) && Arrays.equals(a, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex), b, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex)) </code>
Parameters | |
---|---|
a |
BooleanArray: the first array to be tested for a mismatch |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
BooleanArray: the second array to be tested for a mismatch |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Int |
the relative index of the first mismatch between the two arrays over the specified ranges, otherwise -1 . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: ByteArray,
b: ByteArray
): Int
Finds and returns the index of the first mismatch between two byte
arrays, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller array.
If the two arrays share a common prefix then the returned index is the length of the common prefix and it follows that there is a mismatch between the two elements at that index within the respective arrays. If one array is a proper prefix of the other then the returned index is the length of the smaller array and it follows that the index is only valid for the larger array. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(a.length, b.length) && Arrays.equals(a, 0, pl, b, 0, pl) && a[pl] != b[pl] </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
, share a proper prefix if the following expression is true:
<code>a.length != b.length && Arrays.equals(a, 0, Math.min(a.length, b.length), b, 0, Math.min(a.length, b.length)) </code>
Parameters | |
---|---|
a |
ByteArray: the first array to be tested for a mismatch |
b |
ByteArray: the second array to be tested for a mismatch |
Return | |
---|---|
Int |
the index of the first mismatch between the two arrays, otherwise -1 . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: ByteArray!,
aFromIndex: Int,
aToIndex: Int,
b: ByteArray!,
bFromIndex: Int,
bToIndex: Int
): Int
Finds and returns the relative index of the first mismatch between two byte
arrays over the specified ranges, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller range.
If the two arrays, over the specified ranges, share a common prefix then the returned relative index is the length of the common prefix and it follows that there is a mismatch between the two elements at that relative index within the respective arrays. If one array is a proper prefix of the other, over the specified ranges, then the returned relative index is the length of the smaller range and it follows that the relative index is only valid for the array with the larger range. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex) && Arrays.equals(a, aFromIndex, aFromIndex + pl, b, bFromIndex, bFromIndex + pl) && a[aFromIndex + pl] != b[bFromIndex + pl] </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a proper prefix if the following expression is true:
<code>(aToIndex - aFromIndex) != (bToIndex - bFromIndex) && Arrays.equals(a, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex), b, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex)) </code>
Parameters | |
---|---|
a |
ByteArray!: the first array to be tested for a mismatch |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
ByteArray!: the second array to be tested for a mismatch |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Int |
the relative index of the first mismatch between the two arrays over the specified ranges, otherwise -1 . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: CharArray,
b: CharArray
): Int
Finds and returns the index of the first mismatch between two char
arrays, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller array.
If the two arrays share a common prefix then the returned index is the length of the common prefix and it follows that there is a mismatch between the two elements at that index within the respective arrays. If one array is a proper prefix of the other then the returned index is the length of the smaller array and it follows that the index is only valid for the larger array. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(a.length, b.length) && Arrays.equals(a, 0, pl, b, 0, pl) && a[pl] != b[pl] </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
, share a proper prefix if the following expression is true:
<code>a.length != b.length && Arrays.equals(a, 0, Math.min(a.length, b.length), b, 0, Math.min(a.length, b.length)) </code>
Parameters | |
---|---|
a |
CharArray: the first array to be tested for a mismatch |
b |
CharArray: the second array to be tested for a mismatch |
Return | |
---|---|
Int |
the index of the first mismatch between the two arrays, otherwise -1 . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: CharArray,
aFromIndex: Int,
aToIndex: Int,
b: CharArray,
bFromIndex: Int,
bToIndex: Int
): Int
Finds and returns the relative index of the first mismatch between two char
arrays over the specified ranges, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller range.
If the two arrays, over the specified ranges, share a common prefix then the returned relative index is the length of the common prefix and it follows that there is a mismatch between the two elements at that relative index within the respective arrays. If one array is a proper prefix of the other, over the specified ranges, then the returned relative index is the length of the smaller range and it follows that the relative index is only valid for the array with the larger range. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex) && Arrays.equals(a, aFromIndex, aFromIndex + pl, b, bFromIndex, bFromIndex + pl) && a[aFromIndex + pl] != b[bFromIndex + pl] </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a proper prefix if the following expression is true:
<code>(aToIndex - aFromIndex) != (bToIndex - bFromIndex) && Arrays.equals(a, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex), b, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex)) </code>
Parameters | |
---|---|
a |
CharArray: the first array to be tested for a mismatch |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
CharArray: the second array to be tested for a mismatch |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Int |
the relative index of the first mismatch between the two arrays over the specified ranges, otherwise -1 . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: DoubleArray,
b: DoubleArray
): Int
Finds and returns the index of the first mismatch between two double
arrays, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller array.
If the two arrays share a common prefix then the returned index is the length of the common prefix and it follows that there is a mismatch between the two elements at that index within the respective arrays. If one array is a proper prefix of the other then the returned index is the length of the smaller array and it follows that the index is only valid for the larger array. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(a.length, b.length) && Arrays.equals(a, 0, pl, b, 0, pl) && Double.compare(a[pl], b[pl]) != 0 </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
, share a proper prefix if the following expression is true:
<code>a.length != b.length && Arrays.equals(a, 0, Math.min(a.length, b.length), b, 0, Math.min(a.length, b.length)) </code>
Parameters | |
---|---|
a |
DoubleArray: the first array to be tested for a mismatch |
b |
DoubleArray: the second array to be tested for a mismatch |
Return | |
---|---|
Int |
the index of the first mismatch between the two arrays, otherwise -1 . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: DoubleArray,
aFromIndex: Int,
aToIndex: Int,
b: DoubleArray,
bFromIndex: Int,
bToIndex: Int
): Int
Finds and returns the relative index of the first mismatch between two double
arrays over the specified ranges, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller range.
If the two arrays, over the specified ranges, share a common prefix then the returned relative index is the length of the common prefix and it follows that there is a mismatch between the two elements at that relative index within the respective arrays. If one array is a proper prefix of the other, over the specified ranges, then the returned relative index is the length of the smaller range and it follows that the relative index is only valid for the array with the larger range. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex) && Arrays.equals(a, aFromIndex, aFromIndex + pl, b, bFromIndex, bFromIndex + pl) && Double.compare(a[aFromIndex + pl], b[bFromIndex + pl]) != 0 </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a proper prefix if the following expression is true:
<code>(aToIndex - aFromIndex) != (bToIndex - bFromIndex) && Arrays.equals(a, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex), b, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex)) </code>
Parameters | |
---|---|
a |
DoubleArray: the first array to be tested for a mismatch |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
DoubleArray: the second array to be tested for a mismatch |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Int |
the relative index of the first mismatch between the two arrays over the specified ranges, otherwise -1 . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: FloatArray,
b: FloatArray
): Int
Finds and returns the index of the first mismatch between two float
arrays, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller array.
If the two arrays share a common prefix then the returned index is the length of the common prefix and it follows that there is a mismatch between the two elements at that index within the respective arrays. If one array is a proper prefix of the other then the returned index is the length of the smaller array and it follows that the index is only valid for the larger array. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(a.length, b.length) && Arrays.equals(a, 0, pl, b, 0, pl) && Float.compare(a[pl], b[pl]) != 0 </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
, share a proper prefix if the following expression is true:
<code>a.length != b.length && Arrays.equals(a, 0, Math.min(a.length, b.length), b, 0, Math.min(a.length, b.length)) </code>
Parameters | |
---|---|
a |
FloatArray: the first array to be tested for a mismatch |
b |
FloatArray: the second array to be tested for a mismatch |
Return | |
---|---|
Int |
the index of the first mismatch between the two arrays, otherwise -1 . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: FloatArray,
aFromIndex: Int,
aToIndex: Int,
b: FloatArray,
bFromIndex: Int,
bToIndex: Int
): Int
Finds and returns the relative index of the first mismatch between two float
arrays over the specified ranges, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller range.
If the two arrays, over the specified ranges, share a common prefix then the returned relative index is the length of the common prefix and it follows that there is a mismatch between the two elements at that relative index within the respective arrays. If one array is a proper prefix of the other, over the specified ranges, then the returned relative index is the length of the smaller range and it follows that the relative index is only valid for the array with the larger range. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex) && Arrays.equals(a, aFromIndex, aFromIndex + pl, b, bFromIndex, bFromIndex + pl) && Float.compare(a[aFromIndex + pl], b[bFromIndex + pl]) != 0 </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a proper prefix if the following expression is true:
<code>(aToIndex - aFromIndex) != (bToIndex - bFromIndex) && Arrays.equals(a, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex), b, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex)) </code>
Parameters | |
---|---|
a |
FloatArray: the first array to be tested for a mismatch |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
FloatArray: the second array to be tested for a mismatch |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Int |
the relative index of the first mismatch between the two arrays over the specified ranges, otherwise -1 . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: IntArray,
aFromIndex: Int,
aToIndex: Int,
b: IntArray,
bFromIndex: Int,
bToIndex: Int
): Int
Finds and returns the relative index of the first mismatch between two int
arrays over the specified ranges, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller range.
If the two arrays, over the specified ranges, share a common prefix then the returned relative index is the length of the common prefix and it follows that there is a mismatch between the two elements at that relative index within the respective arrays. If one array is a proper prefix of the other, over the specified ranges, then the returned relative index is the length of the smaller range and it follows that the relative index is only valid for the array with the larger range. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex) && Arrays.equals(a, aFromIndex, aFromIndex + pl, b, bFromIndex, bFromIndex + pl) && a[aFromIndex + pl] != b[bFromIndex + pl] </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a proper prefix if the following expression is true:
<code>(aToIndex - aFromIndex) != (bToIndex - bFromIndex) && Arrays.equals(a, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex), b, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex)) </code>
Parameters | |
---|---|
a |
IntArray: the first array to be tested for a mismatch |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
IntArray: the second array to be tested for a mismatch |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Int |
the relative index of the first mismatch between the two arrays over the specified ranges, otherwise -1 . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: IntArray,
b: IntArray
): Int
Finds and returns the index of the first mismatch between two int
arrays, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller array.
If the two arrays share a common prefix then the returned index is the length of the common prefix and it follows that there is a mismatch between the two elements at that index within the respective arrays. If one array is a proper prefix of the other then the returned index is the length of the smaller array and it follows that the index is only valid for the larger array. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(a.length, b.length) && Arrays.equals(a, 0, pl, b, 0, pl) && a[pl] != b[pl] </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
, share a proper prefix if the following expression is true:
<code>a.length != b.length && Arrays.equals(a, 0, Math.min(a.length, b.length), b, 0, Math.min(a.length, b.length)) </code>
Parameters | |
---|---|
a |
IntArray: the first array to be tested for a mismatch |
b |
IntArray: the second array to be tested for a mismatch |
Return | |
---|---|
Int |
the index of the first mismatch between the two arrays, otherwise -1 . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: Array<Any!>,
aFromIndex: Int,
aToIndex: Int,
b: Array<Any!>,
bFromIndex: Int,
bToIndex: Int
): Int
Finds and returns the relative index of the first mismatch between two Object
arrays over the specified ranges, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller range.
If the two arrays, over the specified ranges, share a common prefix then the returned relative index is the length of the common prefix and it follows that there is a mismatch between the two elements at that relative index within the respective arrays. If one array is a proper prefix of the other, over the specified ranges, then the returned relative index is the length of the smaller range and it follows that the relative index is only valid for the array with the larger range. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex) && Arrays.equals(a, aFromIndex, aFromIndex + pl, b, bFromIndex, bFromIndex + pl) && !Objects.equals(a[aFromIndex + pl], b[bFromIndex + pl]) </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a proper prefix if the following expression is true:
<code>(aToIndex - aFromIndex) != (bToIndex - bFromIndex) && Arrays.equals(a, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex), b, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex)) </code>
Parameters | |
---|---|
a |
Array<Any!>: the first array to be tested for a mismatch |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
Array<Any!>: the second array to be tested for a mismatch |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Int |
the relative index of the first mismatch between the two arrays over the specified ranges, otherwise -1 . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: Array<Any!>,
b: Array<Any!>
): Int
Finds and returns the index of the first mismatch between two Object
arrays, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller array.
If the two arrays share a common prefix then the returned index is the length of the common prefix and it follows that there is a mismatch between the two elements at that index within the respective arrays. If one array is a proper prefix of the other then the returned index is the length of the smaller array and it follows that the index is only valid for the larger array. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(a.length, b.length) && Arrays.equals(a, 0, pl, b, 0, pl) && !Objects.equals(a[pl], b[pl]) </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
, share a proper prefix if the following expression is true:
<code>a.length != b.length && Arrays.equals(a, 0, Math.min(a.length, b.length), b, 0, Math.min(a.length, b.length)) </code>
Parameters | |
---|---|
a |
Array<Any!>: the first array to be tested for a mismatch |
b |
Array<Any!>: the second array to be tested for a mismatch |
Return | |
---|---|
Int |
the index of the first mismatch between the two arrays, otherwise -1 . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: LongArray,
aFromIndex: Int,
aToIndex: Int,
b: LongArray,
bFromIndex: Int,
bToIndex: Int
): Int
Finds and returns the relative index of the first mismatch between two long
arrays over the specified ranges, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller range.
If the two arrays, over the specified ranges, share a common prefix then the returned relative index is the length of the common prefix and it follows that there is a mismatch between the two elements at that relative index within the respective arrays. If one array is a proper prefix of the other, over the specified ranges, then the returned relative index is the length of the smaller range and it follows that the relative index is only valid for the array with the larger range. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex) && Arrays.equals(a, aFromIndex, aFromIndex + pl, b, bFromIndex, bFromIndex + pl) && a[aFromIndex + pl] != b[bFromIndex + pl] </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a proper prefix if the following expression is true:
<code>(aToIndex - aFromIndex) != (bToIndex - bFromIndex) && Arrays.equals(a, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex), b, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex)) </code>
Parameters | |
---|---|
a |
LongArray: the first array to be tested for a mismatch |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
LongArray: the second array to be tested for a mismatch |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Int |
the relative index of the first mismatch between the two arrays over the specified ranges, otherwise -1 . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: LongArray,
b: LongArray
): Int
Finds and returns the index of the first mismatch between two long
arrays, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller array.
If the two arrays share a common prefix then the returned index is the length of the common prefix and it follows that there is a mismatch between the two elements at that index within the respective arrays. If one array is a proper prefix of the other then the returned index is the length of the smaller array and it follows that the index is only valid for the larger array. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(a.length, b.length) && Arrays.equals(a, 0, pl, b, 0, pl) && a[pl] != b[pl] </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
, share a proper prefix if the following expression is true:
<code>a.length != b.length && Arrays.equals(a, 0, Math.min(a.length, b.length), b, 0, Math.min(a.length, b.length)) </code>
Parameters | |
---|---|
a |
LongArray: the first array to be tested for a mismatch |
b |
LongArray: the second array to be tested for a mismatch |
Return | |
---|---|
Int |
the index of the first mismatch between the two arrays, otherwise -1 . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: ShortArray,
aFromIndex: Int,
aToIndex: Int,
b: ShortArray,
bFromIndex: Int,
bToIndex: Int
): Int
Finds and returns the relative index of the first mismatch between two short
arrays over the specified ranges, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller range.
If the two arrays, over the specified ranges, share a common prefix then the returned relative index is the length of the common prefix and it follows that there is a mismatch between the two elements at that relative index within the respective arrays. If one array is a proper prefix of the other, over the specified ranges, then the returned relative index is the length of the smaller range and it follows that the relative index is only valid for the array with the larger range. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex) && Arrays.equals(a, aFromIndex, aFromIndex + pl, b, bFromIndex, bFromIndex + pl) && a[aFromIndex + pl] != b[bFromIndex + pl] </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a proper prefix if the following expression is true:
<code>(aToIndex - aFromIndex) != (bToIndex - bFromIndex) && Arrays.equals(a, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex), b, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex)) </code>
Parameters | |
---|---|
a |
ShortArray: the first array to be tested for a mismatch |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
ShortArray: the second array to be tested for a mismatch |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
Return | |
---|---|
Int |
the relative index of the first mismatch between the two arrays over the specified ranges, otherwise -1 . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array is null |
mismatch
static fun mismatch(
a: ShortArray,
b: ShortArray
): Int
Finds and returns the index of the first mismatch between two short
arrays, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller array.
If the two arrays share a common prefix then the returned index is the length of the common prefix and it follows that there is a mismatch between the two elements at that index within the respective arrays. If one array is a proper prefix of the other then the returned index is the length of the smaller array and it follows that the index is only valid for the larger array. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(a.length, b.length) && Arrays.equals(a, 0, pl, b, 0, pl) && a[pl] != b[pl] </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
, share a proper prefix if the following expression is true:
<code>a.length != b.length && Arrays.equals(a, 0, Math.min(a.length, b.length), b, 0, Math.min(a.length, b.length)) </code>
Parameters | |
---|---|
a |
ShortArray: the first array to be tested for a mismatch |
b |
ShortArray: the second array to be tested for a mismatch |
Return | |
---|---|
Int |
the index of the first mismatch between the two arrays, otherwise -1 . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if either array is null |
mismatch
static fun <T : Any!> mismatch(
a: Array<T>,
aFromIndex: Int,
aToIndex: Int,
b: Array<T>,
bFromIndex: Int,
bToIndex: Int,
cmp: Comparator<in T>
): Int
Finds and returns the relative index of the first mismatch between two Object
arrays over the specified ranges, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller range.
If the two arrays, over the specified ranges, share a common prefix then the returned relative index is the length of the common prefix and it follows that there is a mismatch between the two elements at that relative index within the respective arrays. If one array is a proper prefix of the other, over the specified ranges, then the returned relative index is the length of the smaller range and it follows that the relative index is only valid for the array with the larger range. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex) && Arrays.equals(a, aFromIndex, aFromIndex + pl, b, bFromIndex, bFromIndex + pl, cmp) && cmp.compare(a[aFromIndex + pl], b[bFromIndex + pl]) != 0 </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
with specified ranges [aFromIndex
, aToIndex
) and [bFromIndex
, bToIndex
) respectively, share a proper prefix if the following expression is true:
<code>(aToIndex - aFromIndex) != (bToIndex - bFromIndex) && Arrays.equals(a, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex), b, 0, Math.min(aToIndex - aFromIndex, bToIndex - bFromIndex), cmp) </code>
Parameters | |
---|---|
a |
Array<T>: the first array to be tested for a mismatch |
aFromIndex |
Int: the index (inclusive) of the first element in the first array to be tested |
aToIndex |
Int: the index (exclusive) of the last element in the first array to be tested |
b |
Array<T>: the second array to be tested for a mismatch |
bFromIndex |
Int: the index (inclusive) of the first element in the second array to be tested |
bToIndex |
Int: the index (exclusive) of the last element in the second array to be tested |
cmp |
Comparator<in T>: the comparator to compare array elements |
<T> |
the type of array elements |
Return | |
---|---|
Int |
the relative index of the first mismatch between the two arrays over the specified ranges, otherwise -1 . |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if aFromIndex > aToIndex or if bFromIndex > bToIndex |
java.lang.ArrayIndexOutOfBoundsException |
if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length |
java.lang.NullPointerException |
if either array or the comparator is null |
mismatch
static fun <T : Any!> mismatch(
a: Array<T>,
b: Array<T>,
cmp: Comparator<in T>
): Int
Finds and returns the index of the first mismatch between two Object
arrays, otherwise return -1 if no mismatch is found. The index will be in the range of 0 (inclusive) up to the length (inclusive) of the smaller array.
The specified comparator is used to determine if two array elements from the each array are not equal.
If the two arrays share a common prefix then the returned index is the length of the common prefix and it follows that there is a mismatch between the two elements at that index within the respective arrays. If one array is a proper prefix of the other then the returned index is the length of the smaller array and it follows that the index is only valid for the larger array. Otherwise, there is no mismatch.
Two non-null
arrays, a
and b
, share a common prefix of length pl
if the following expression is true:
<code>pl >= 0 && pl < Math.min(a.length, b.length) && Arrays.equals(a, 0, pl, b, 0, pl, cmp) cmp.compare(a[pl], b[pl]) != 0 </code>
0
indicates that the first elements from each array mismatch.
Two non-null
arrays, a
and b
, share a proper prefix if the following expression is true:
<code>a.length != b.length && Arrays.equals(a, 0, Math.min(a.length, b.length), b, 0, Math.min(a.length, b.length), cmp) </code>
Parameters | |
---|---|
a |
Array<T>: the first array to be tested for a mismatch |
b |
Array<T>: the second array to be tested for a mismatch |
cmp |
Comparator<in T>: the comparator to compare array elements |
<T> |
the type of array elements |
Return | |
---|---|
Int |
the index of the first mismatch between the two arrays, otherwise -1 . |
Exceptions | |
---|---|
java.lang.NullPointerException |
if either array or the comparator is null |
parallelPrefix
static fun parallelPrefix(
array: DoubleArray,
fromIndex: Int,
toIndex: Int,
op: DoubleBinaryOperator
): Unit
Performs parallelPrefix(double[],java.util.function.DoubleBinaryOperator)
for the given subrange of the array.
Parameters | |
---|---|
array |
DoubleArray: the array |
fromIndex |
Int: the index of the first element, inclusive |
toIndex |
Int: the index of the last element, exclusive |
op |
DoubleBinaryOperator: a side-effect-free, associative function to perform the cumulation |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > array.length |
java.lang.NullPointerException |
if the specified array or function is null |
parallelPrefix
static fun parallelPrefix(
array: DoubleArray,
op: DoubleBinaryOperator
): Unit
Cumulates, in parallel, each element of the given array in place, using the supplied function. For example if the array initially holds [2.0, 1.0, 0.0, 3.0]
and the operation performs addition, then upon return the array holds [2.0, 3.0, 3.0, 6.0]
. Parallel prefix computation is usually more efficient than sequential loops for large arrays.
Because floating-point operations may not be strictly associative, the returned result may not be identical to the value that would be obtained if the operation was performed sequentially.
Parameters | |
---|---|
array |
DoubleArray: the array, which is modified in-place by this method |
op |
DoubleBinaryOperator: a side-effect-free function to perform the cumulation |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the specified array or function is null |
parallelPrefix
static fun parallelPrefix(
array: IntArray,
fromIndex: Int,
toIndex: Int,
op: IntBinaryOperator
): Unit
Performs parallelPrefix(int[],java.util.function.IntBinaryOperator)
for the given subrange of the array.
Parameters | |
---|---|
array |
IntArray: the array |
fromIndex |
Int: the index of the first element, inclusive |
toIndex |
Int: the index of the last element, exclusive |
op |
IntBinaryOperator: a side-effect-free, associative function to perform the cumulation |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > array.length |
java.lang.NullPointerException |
if the specified array or function is null |
parallelPrefix
static fun parallelPrefix(
array: IntArray,
op: IntBinaryOperator
): Unit
Cumulates, in parallel, each element of the given array in place, using the supplied function. For example if the array initially holds [2, 1, 0, 3]
and the operation performs addition, then upon return the array holds [2, 3, 3, 6]
. Parallel prefix computation is usually more efficient than sequential loops for large arrays.
Parameters | |
---|---|
array |
IntArray: the array, which is modified in-place by this method |
op |
IntBinaryOperator: a side-effect-free, associative function to perform the cumulation |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the specified array or function is null |
parallelPrefix
static fun parallelPrefix(
array: LongArray,
fromIndex: Int,
toIndex: Int,
op: LongBinaryOperator
): Unit
Performs parallelPrefix(long[],java.util.function.LongBinaryOperator)
for the given subrange of the array.
Parameters | |
---|---|
array |
LongArray: the array |
fromIndex |
Int: the index of the first element, inclusive |
toIndex |
Int: the index of the last element, exclusive |
op |
LongBinaryOperator: a side-effect-free, associative function to perform the cumulation |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > array.length |
java.lang.NullPointerException |
if the specified array or function is null |
parallelPrefix
static fun parallelPrefix(
array: LongArray,
op: LongBinaryOperator
): Unit
Cumulates, in parallel, each element of the given array in place, using the supplied function. For example if the array initially holds [2, 1, 0, 3]
and the operation performs addition, then upon return the array holds [2, 3, 3, 6]
. Parallel prefix computation is usually more efficient than sequential loops for large arrays.
Parameters | |
---|---|
array |
LongArray: the array, which is modified in-place by this method |
op |
LongBinaryOperator: a side-effect-free, associative function to perform the cumulation |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the specified array or function is null |
parallelPrefix
static fun <T : Any!> parallelPrefix(
array: Array<T>,
fromIndex: Int,
toIndex: Int,
op: BinaryOperator<T>
): Unit
Performs parallelPrefix(java.lang.Object[],java.util.function.BinaryOperator)
for the given subrange of the array.
Parameters | |
---|---|
<T> |
the class of the objects in the array |
array |
Array<T>: the array |
fromIndex |
Int: the index of the first element, inclusive |
toIndex |
Int: the index of the last element, exclusive |
op |
BinaryOperator<T>: a side-effect-free, associative function to perform the cumulation |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > array.length |
java.lang.NullPointerException |
if the specified array or function is null |
parallelPrefix
static fun <T : Any!> parallelPrefix(
array: Array<T>,
op: BinaryOperator<T>
): Unit
Cumulates, in parallel, each element of the given array in place, using the supplied function. For example if the array initially holds [2, 1, 0, 3]
and the operation performs addition, then upon return the array holds [2, 3, 3, 6]
. Parallel prefix computation is usually more efficient than sequential loops for large arrays.
Parameters | |
---|---|
<T> |
the class of the objects in the array |
array |
Array<T>: the array, which is modified in-place by this method |
op |
BinaryOperator<T>: a side-effect-free, associative function to perform the cumulation |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the specified array or function is null |
parallelSetAll
static fun parallelSetAll(
array: DoubleArray,
generator: IntToDoubleFunction
): Unit
Set all elements of the specified array, in parallel, using the provided generator function to compute each element.
If the generator function throws an exception, an unchecked exception is thrown from parallelSetAll
and the array is left in an indeterminate state.
Parameters | |
---|---|
array |
DoubleArray: array to be initialized |
generator |
IntToDoubleFunction: a function accepting an index and producing the desired value for that position |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the generator is null |
parallelSetAll
static fun parallelSetAll(
array: IntArray,
generator: IntUnaryOperator
): Unit
Set all elements of the specified array, in parallel, using the provided generator function to compute each element.
If the generator function throws an exception, an unchecked exception is thrown from parallelSetAll
and the array is left in an indeterminate state.
Parameters | |
---|---|
array |
IntArray: array to be initialized |
generator |
IntUnaryOperator: a function accepting an index and producing the desired value for that position |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the generator is null |
parallelSetAll
static fun parallelSetAll(
array: LongArray,
generator: IntToLongFunction
): Unit
Set all elements of the specified array, in parallel, using the provided generator function to compute each element.
If the generator function throws an exception, an unchecked exception is thrown from parallelSetAll
and the array is left in an indeterminate state.
Parameters | |
---|---|
array |
LongArray: array to be initialized |
generator |
IntToLongFunction: a function accepting an index and producing the desired value for that position |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the generator is null |
parallelSetAll
static fun <T : Any!> parallelSetAll(
array: Array<T>,
generator: IntFunction<out T>
): Unit
Set all elements of the specified array, in parallel, using the provided generator function to compute each element.
If the generator function throws an exception, an unchecked exception is thrown from parallelSetAll
and the array is left in an indeterminate state.
Parameters | |
---|---|
<T> |
type of elements of the array |
array |
Array<T>: array to be initialized |
generator |
IntFunction<out T>: a function accepting an index and producing the desired value for that position |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the generator is null |
parallelSort
static fun parallelSort(a: ByteArray): Unit
Sorts the specified array into ascending numerical order.
Parameters | |
---|---|
a |
ByteArray: the array to be sorted |
parallelSort
static fun parallelSort(
a: ByteArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending numerical order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
Parameters | |
---|---|
a |
ByteArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
parallelSort
static fun parallelSort(a: CharArray): Unit
Sorts the specified array into ascending numerical order.
Parameters | |
---|---|
a |
CharArray: the array to be sorted |
parallelSort
static fun parallelSort(
a: CharArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending numerical order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
Parameters | |
---|---|
a |
CharArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
parallelSort
static fun parallelSort(a: DoubleArray): Unit
Sorts the specified array into ascending numerical order.
The <
relation does not provide a total order on all double values: -0.0d == 0.0d
is true
and a Double.NaN
value compares neither less than, greater than, nor equal to any value, even itself. This method uses the total order imposed by the method Double.compareTo
: -0.0d
is treated as less than value 0.0d
and Double.NaN
is considered greater than any other value and all Double.NaN
values are considered equal.
Parameters | |
---|---|
a |
DoubleArray: the array to be sorted |
parallelSort
static fun parallelSort(
a: DoubleArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending numerical order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
The <
relation does not provide a total order on all double values: -0.0d == 0.0d
is true
and a Double.NaN
value compares neither less than, greater than, nor equal to any value, even itself. This method uses the total order imposed by the method Double.compareTo
: -0.0d
is treated as less than value 0.0d
and Double.NaN
is considered greater than any other value and all Double.NaN
values are considered equal.
Parameters | |
---|---|
a |
DoubleArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
parallelSort
static fun parallelSort(a: FloatArray): Unit
Sorts the specified array into ascending numerical order.
The <
relation does not provide a total order on all float values: -0.0f == 0.0f
is true
and a Float.NaN
value compares neither less than, greater than, nor equal to any value, even itself. This method uses the total order imposed by the method Float.compareTo
: -0.0f
is treated as less than value 0.0f
and Float.NaN
is considered greater than any other value and all Float.NaN
values are considered equal.
Parameters | |
---|---|
a |
FloatArray: the array to be sorted |
parallelSort
static fun parallelSort(
a: FloatArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending numerical order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
The <
relation does not provide a total order on all float values: -0.0f == 0.0f
is true
and a Float.NaN
value compares neither less than, greater than, nor equal to any value, even itself. This method uses the total order imposed by the method Float.compareTo
: -0.0f
is treated as less than value 0.0f
and Float.NaN
is considered greater than any other value and all Float.NaN
values are considered equal.
Parameters | |
---|---|
a |
FloatArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
parallelSort
static fun parallelSort(a: IntArray): Unit
Sorts the specified array into ascending numerical order.
Parameters | |
---|---|
a |
IntArray: the array to be sorted |
parallelSort
static fun parallelSort(
a: IntArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending numerical order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
Parameters | |
---|---|
a |
IntArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
parallelSort
static fun parallelSort(a: LongArray): Unit
Sorts the specified array into ascending numerical order.
Parameters | |
---|---|
a |
LongArray: the array to be sorted |
parallelSort
static fun parallelSort(
a: LongArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending numerical order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
Parameters | |
---|---|
a |
LongArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
parallelSort
static fun parallelSort(a: ShortArray): Unit
Sorts the specified array into ascending numerical order.
Parameters | |
---|---|
a |
ShortArray: the array to be sorted |
parallelSort
static fun parallelSort(
a: ShortArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending numerical order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
Parameters | |
---|---|
a |
ShortArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
parallelSort
static fun <T : Comparable<T>!> parallelSort(a: Array<T>): Unit
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.
Parameters | |
---|---|
<T> |
the class of the objects to be sorted |
a |
Array<T>: the array to be sorted |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the array contains elements that are not mutually comparable (for example, strings and integers) |
java.lang.IllegalArgumentException |
(optional) if the natural ordering of the array elements is found to violate the Comparable contract |
parallelSort
static fun <T : Comparable<T>!> parallelSort(
a: Array<T>,
fromIndex: Int,
toIndex: Int
): Unit
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.
Parameters | |
---|---|
<T> |
the class of the objects to be sorted |
a |
Array<T>: the array to be sorted |
fromIndex |
Int: the index of the first element (inclusive) to be sorted |
toIndex |
Int: the index of the last element (exclusive) to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex or (optional) if the natural ordering of the array elements is found to violate the Comparable contract |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
java.lang.ClassCastException |
if the array contains elements that are not mutually comparable (for example, strings and integers). |
parallelSort
static fun <T : Any!> parallelSort(
a: Array<T>,
fromIndex: Int,
toIndex: Int,
cmp: Comparator<in T>?
): Unit
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.
Parameters | |
---|---|
<T> |
the class of the objects to be sorted |
a |
Array<T>: the array to be sorted |
fromIndex |
Int: the index of the first element (inclusive) to be sorted |
toIndex |
Int: the index of the last element (exclusive) to be sorted |
cmp |
Comparator<in T>?: the comparator to determine the order of the array. A null value indicates that the elements' natural ordering should be used. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex or (optional) if the natural ordering of the array elements is found to violate the Comparable contract |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
java.lang.ClassCastException |
if the array contains elements that are not mutually comparable (for example, strings and integers). |
parallelSort
static fun <T : Any!> parallelSort(
a: Array<T>,
cmp: Comparator<in T>?
): Unit
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.
Parameters | |
---|---|
<T> |
the class of the objects to be sorted |
a |
Array<T>: the array to be sorted |
cmp |
Comparator<in T>?: the comparator to determine the order of the array. A null value indicates that the elements' natural ordering should be used. |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the array contains elements that are not mutually comparable using the specified comparator |
java.lang.IllegalArgumentException |
(optional) if the comparator is found to violate the java.util.Comparator contract |
setAll
static fun setAll(
array: DoubleArray,
generator: IntToDoubleFunction
): Unit
Set all elements of the specified array, using the provided generator function to compute each element.
If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
Parameters | |
---|---|
array |
DoubleArray: array to be initialized |
generator |
IntToDoubleFunction: a function accepting an index and producing the desired value for that position |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the generator is null |
setAll
static fun setAll(
array: IntArray,
generator: IntUnaryOperator
): Unit
Set all elements of the specified array, using the provided generator function to compute each element.
If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
Parameters | |
---|---|
array |
IntArray: array to be initialized |
generator |
IntUnaryOperator: a function accepting an index and producing the desired value for that position |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the generator is null |
setAll
static fun setAll(
array: LongArray,
generator: IntToLongFunction
): Unit
Set all elements of the specified array, using the provided generator function to compute each element.
If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
Parameters | |
---|---|
array |
LongArray: array to be initialized |
generator |
IntToLongFunction: a function accepting an index and producing the desired value for that position |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the generator is null |
setAll
static fun <T : Any!> setAll(
array: Array<T>,
generator: IntFunction<out T>
): Unit
Set all elements of the specified array, using the provided generator function to compute each element.
If the generator function throws an exception, it is relayed to the caller and the array is left in an indeterminate state.
Parameters | |
---|---|
<T> |
type of elements of the array |
array |
Array<T>: array to be initialized |
generator |
IntFunction<out T>: a function accepting an index and producing the desired value for that position |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the generator is null |
sort
static fun sort(a: ByteArray): Unit
Sorts the specified array into ascending numerical order.
Parameters | |
---|---|
a |
ByteArray: the array to be sorted |
sort
static fun sort(
a: ByteArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
Parameters | |
---|---|
a |
ByteArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
sort
static fun sort(a: CharArray): Unit
Sorts the specified array into ascending numerical order.
Parameters | |
---|---|
a |
CharArray: the array to be sorted |
sort
static fun sort(
a: CharArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
Parameters | |
---|---|
a |
CharArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
sort
static fun sort(a: DoubleArray): Unit
Sorts the specified array into ascending numerical order.
The <
relation does not provide a total order on all double values: -0.0d == 0.0d
is true
and a Double.NaN
value compares neither less than, greater than, nor equal to any value, even itself. This method uses the total order imposed by the method Double.compareTo
: -0.0d
is treated as less than value 0.0d
and Double.NaN
is considered greater than any other value and all Double.NaN
values are considered equal.
Parameters | |
---|---|
a |
DoubleArray: the array to be sorted |
sort
static fun sort(
a: DoubleArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
The <
relation does not provide a total order on all double values: -0.0d == 0.0d
is true
and a Double.NaN
value compares neither less than, greater than, nor equal to any value, even itself. This method uses the total order imposed by the method Double.compareTo
: -0.0d
is treated as less than value 0.0d
and Double.NaN
is considered greater than any other value and all Double.NaN
values are considered equal.
Parameters | |
---|---|
a |
DoubleArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
sort
static fun sort(a: FloatArray): Unit
Sorts the specified array into ascending numerical order.
The <
relation does not provide a total order on all float values: -0.0f == 0.0f
is true
and a Float.NaN
value compares neither less than, greater than, nor equal to any value, even itself. This method uses the total order imposed by the method Float.compareTo
: -0.0f
is treated as less than value 0.0f
and Float.NaN
is considered greater than any other value and all Float.NaN
values are considered equal.
Parameters | |
---|---|
a |
FloatArray: the array to be sorted |
sort
static fun sort(
a: FloatArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
The <
relation does not provide a total order on all float values: -0.0f == 0.0f
is true
and a Float.NaN
value compares neither less than, greater than, nor equal to any value, even itself. This method uses the total order imposed by the method Float.compareTo
: -0.0f
is treated as less than value 0.0f
and Float.NaN
is considered greater than any other value and all Float.NaN
values are considered equal.
Parameters | |
---|---|
a |
FloatArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
sort
static fun sort(a: IntArray): Unit
Sorts the specified array into ascending numerical order.
Parameters | |
---|---|
a |
IntArray: the array to be sorted |
sort
static fun sort(
a: IntArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
Parameters | |
---|---|
a |
IntArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
sort
static fun sort(a: Array<Any!>): Unit
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.
Implementation note: This implementation is a stable, adaptive, iterative mergesort that requires far fewer than n lg(n) comparisons when the input array is partially sorted, while offering the performance of a traditional mergesort when the input array is randomly ordered. If the input array is nearly sorted, the implementation requires approximately n comparisons. Temporary storage requirements vary from a small constant for nearly sorted input arrays to n/2 object references for randomly ordered input arrays.
The implementation takes equal advantage of ascending and descending order in its input array, and can take advantage of ascending and descending order in different parts of the same input array. It is well-suited to merging two or more sorted arrays: simply concatenate the arrays and sort the resulting array.
The implementation was adapted from Tim Peters's list sort for Python ( TimSort). It uses techniques from Peter McIlroy's "Optimistic Sorting and Information Theoretic Complexity", in Proceedings of the Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474, January 1993.
Parameters | |
---|---|
a |
Array<Any!>: the array to be sorted |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the array contains elements that are not mutually comparable (for example, strings and integers) |
java.lang.IllegalArgumentException |
(optional) if the natural ordering of the array elements is found to violate the Comparable contract |
sort
static fun sort(
a: Array<Any!>,
fromIndex: Int,
toIndex: Int
): Unit
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.
Implementation note: This implementation is a stable, adaptive, iterative mergesort that requires far fewer than n lg(n) comparisons when the input array is partially sorted, while offering the performance of a traditional mergesort when the input array is randomly ordered. If the input array is nearly sorted, the implementation requires approximately n comparisons. Temporary storage requirements vary from a small constant for nearly sorted input arrays to n/2 object references for randomly ordered input arrays.
The implementation takes equal advantage of ascending and descending order in its input array, and can take advantage of ascending and descending order in different parts of the same input array. It is well-suited to merging two or more sorted arrays: simply concatenate the arrays and sort the resulting array.
The implementation was adapted from Tim Peters's list sort for Python ( TimSort). It uses techniques from Peter McIlroy's "Optimistic Sorting and Information Theoretic Complexity", in Proceedings of the Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474, January 1993.
Parameters | |
---|---|
a |
Array<Any!>: the array to be sorted |
fromIndex |
Int: the index of the first element (inclusive) to be sorted |
toIndex |
Int: the index of the last element (exclusive) to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex or (optional) if the natural ordering of the array elements is found to violate the Comparable contract |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
java.lang.ClassCastException |
if the array contains elements that are not mutually comparable (for example, strings and integers). |
sort
static fun sort(a: LongArray): Unit
Sorts the specified array into ascending numerical order.
Parameters | |
---|---|
a |
LongArray: the array to be sorted |
sort
static fun sort(
a: LongArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
Parameters | |
---|---|
a |
LongArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
sort
static fun sort(a: ShortArray): Unit
Sorts the specified array into ascending numerical order.
Parameters | |
---|---|
a |
ShortArray: the array to be sorted |
sort
static fun sort(
a: ShortArray,
fromIndex: Int,
toIndex: Int
): Unit
Sorts the specified range of the array into ascending order. The range to be sorted extends from the index fromIndex
, inclusive, to the index toIndex
, exclusive. If fromIndex == toIndex
, the range to be sorted is empty.
Parameters | |
---|---|
a |
ShortArray: the array to be sorted |
fromIndex |
Int: the index of the first element, inclusive, to be sorted |
toIndex |
Int: the index of the last element, exclusive, to be sorted |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if fromIndex > toIndex |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
sort
static fun <T : Any!> sort(
a: Array<T>,
fromIndex: Int,
toIndex: Int,
c: Comparator<in T>?
): Unit
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.
Implementation note: This implementation is a stable, adaptive, iterative mergesort that requires far fewer than n lg(n) comparisons when the input array is partially sorted, while offering the performance of a traditional mergesort when the input array is randomly ordered. If the input array is nearly sorted, the implementation requires approximately n comparisons. Temporary storage requirements vary from a small constant for nearly sorted input arrays to n/2 object references for randomly ordered input arrays.
The implementation takes equal advantage of ascending and descending order in its input array, and can take advantage of ascending and descending order in different parts of the same input array. It is well-suited to merging two or more sorted arrays: simply concatenate the arrays and sort the resulting array.
The implementation was adapted from Tim Peters's list sort for Python ( TimSort). It uses techniques from Peter McIlroy's "Optimistic Sorting and Information Theoretic Complexity", in Proceedings of the Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474, January 1993.
Parameters | |
---|---|
<T> |
the class of the objects to be sorted |
a |
Array<T>: the array to be sorted |
fromIndex |
Int: the index of the first element (inclusive) to be sorted |
toIndex |
Int: the index of the last element (exclusive) to be sorted |
c |
Comparator<in T>?: the comparator to determine the order of the array. A null value indicates that the elements' natural ordering should be used. |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the array contains elements that are not mutually comparable using the specified comparator. |
java.lang.IllegalArgumentException |
if fromIndex > toIndex or (optional) if the comparator is found to violate the Comparator contract |
java.lang.ArrayIndexOutOfBoundsException |
if fromIndex < 0 or toIndex > a.length |
sort
static fun <T : Any!> sort(
a: Array<T>,
c: Comparator<in T>?
): Unit
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.
Implementation note: This implementation is a stable, adaptive, iterative mergesort that requires far fewer than n lg(n) comparisons when the input array is partially sorted, while offering the performance of a traditional mergesort when the input array is randomly ordered. If the input array is nearly sorted, the implementation requires approximately n comparisons. Temporary storage requirements vary from a small constant for nearly sorted input arrays to n/2 object references for randomly ordered input arrays.
The implementation takes equal advantage of ascending and descending order in its input array, and can take advantage of ascending and descending order in different parts of the same input array. It is well-suited to merging two or more sorted arrays: simply concatenate the arrays and sort the resulting array.
The implementation was adapted from Tim Peters's list sort for Python ( TimSort). It uses techniques from Peter McIlroy's "Optimistic Sorting and Information Theoretic Complexity", in Proceedings of the Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474, January 1993.
Parameters | |
---|---|
<T> |
the class of the objects to be sorted |
a |
Array<T>: the array to be sorted |
c |
Comparator<in T>?: the comparator to determine the order of the array. A null value indicates that the elements' natural ordering should be used. |
Exceptions | |
---|---|
java.lang.ClassCastException |
if the array contains elements that are not mutually comparable using the specified comparator |
java.lang.IllegalArgumentException |
(optional) if the comparator is found to violate the Comparator contract |
spliterator
static fun spliterator(array: DoubleArray): Spliterator.OfDouble
Returns a Spliterator.OfDouble
covering all of the specified array.
The spliterator reports Spliterator.SIZED
, Spliterator.SUBSIZED
, Spliterator.ORDERED
, and Spliterator.IMMUTABLE
.
Parameters | |
---|---|
array |
DoubleArray: the array, assumed to be unmodified during use |
Return | |
---|---|
Spliterator.OfDouble |
a spliterator for the array elements |
spliterator
static fun spliterator(
array: DoubleArray,
startInclusive: Int,
endExclusive: Int
): Spliterator.OfDouble
Returns a Spliterator.OfDouble
covering the specified range of the specified array.
The spliterator reports Spliterator.SIZED
, Spliterator.SUBSIZED
, Spliterator.ORDERED
, and Spliterator.IMMUTABLE
.
Parameters | |
---|---|
array |
DoubleArray: the array, assumed to be unmodified during use |
startInclusive |
Int: the first index to cover, inclusive |
endExclusive |
Int: index immediately past the last index to cover |
Return | |
---|---|
Spliterator.OfDouble |
a spliterator for the array elements |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if startInclusive is negative, endExclusive is less than startInclusive , or endExclusive is greater than the array size |
spliterator
static fun spliterator(array: IntArray): Spliterator.OfInt
Returns a Spliterator.OfInt
covering all of the specified array.
The spliterator reports Spliterator.SIZED
, Spliterator.SUBSIZED
, Spliterator.ORDERED
, and Spliterator.IMMUTABLE
.
Parameters | |
---|---|
array |
IntArray: the array, assumed to be unmodified during use |
Return | |
---|---|
Spliterator.OfInt |
a spliterator for the array elements |
spliterator
static fun spliterator(
array: IntArray,
startInclusive: Int,
endExclusive: Int
): Spliterator.OfInt
Returns a Spliterator.OfInt
covering the specified range of the specified array.
The spliterator reports Spliterator.SIZED
, Spliterator.SUBSIZED
, Spliterator.ORDERED
, and Spliterator.IMMUTABLE
.
Parameters | |
---|---|
array |
IntArray: the array, assumed to be unmodified during use |
startInclusive |
Int: the first index to cover, inclusive |
endExclusive |
Int: index immediately past the last index to cover |
Return | |
---|---|
Spliterator.OfInt |
a spliterator for the array elements |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if startInclusive is negative, endExclusive is less than startInclusive , or endExclusive is greater than the array size |
spliterator
static fun spliterator(array: LongArray): Spliterator.OfLong
Returns a Spliterator.OfLong
covering all of the specified array.
The spliterator reports Spliterator.SIZED
, Spliterator.SUBSIZED
, Spliterator.ORDERED
, and Spliterator.IMMUTABLE
.
Parameters | |
---|---|
array |
LongArray: the array, assumed to be unmodified during use |
Return | |
---|---|
Spliterator.OfLong |
the spliterator for the array elements |
spliterator
static fun spliterator(
array: LongArray,
startInclusive: Int,
endExclusive: Int
): Spliterator.OfLong
Returns a Spliterator.OfLong
covering the specified range of the specified array.
The spliterator reports Spliterator.SIZED
, Spliterator.SUBSIZED
, Spliterator.ORDERED
, and Spliterator.IMMUTABLE
.
Parameters | |
---|---|
array |
LongArray: the array, assumed to be unmodified during use |
startInclusive |
Int: the first index to cover, inclusive |
endExclusive |
Int: index immediately past the last index to cover |
Return | |
---|---|
Spliterator.OfLong |
a spliterator for the array elements |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if startInclusive is negative, endExclusive is less than startInclusive , or endExclusive is greater than the array size |
spliterator
static fun <T : Any!> spliterator(array: Array<T>): Spliterator<T>
Returns a Spliterator
covering all of the specified array.
The spliterator reports Spliterator.SIZED
, Spliterator.SUBSIZED
, Spliterator.ORDERED
, and Spliterator.IMMUTABLE
.
Parameters | |
---|---|
<T> |
type of elements |
array |
Array<T>: the array, assumed to be unmodified during use |
Return | |
---|---|
Spliterator<T> |
a spliterator for the array elements |
spliterator
static fun <T : Any!> spliterator(
array: Array<T>,
startInclusive: Int,
endExclusive: Int
): Spliterator<T>
Returns a Spliterator
covering the specified range of the specified array.
The spliterator reports Spliterator.SIZED
, Spliterator.SUBSIZED
, Spliterator.ORDERED
, and Spliterator.IMMUTABLE
.
Parameters | |
---|---|
<T> |
type of elements |
array |
Array<T>: the array, assumed to be unmodified during use |
startInclusive |
Int: the first index to cover, inclusive |
endExclusive |
Int: index immediately past the last index to cover |
Return | |
---|---|
Spliterator<T> |
a spliterator for the array elements |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if startInclusive is negative, endExclusive is less than startInclusive , or endExclusive is greater than the array size |
stream
static fun stream(array: DoubleArray): DoubleStream
Returns a sequential DoubleStream
with the specified array as its source.
Parameters | |
---|---|
array |
DoubleArray: the array, assumed to be unmodified during use |
Return | |
---|---|
DoubleStream |
a DoubleStream for the array |
stream
static fun stream(
array: DoubleArray,
startInclusive: Int,
endExclusive: Int
): DoubleStream
Returns a sequential DoubleStream
with the specified range of the specified array as its source.
Parameters | |
---|---|
array |
DoubleArray: the array, assumed to be unmodified during use |
startInclusive |
Int: the first index to cover, inclusive |
endExclusive |
Int: index immediately past the last index to cover |
Return | |
---|---|
DoubleStream |
a DoubleStream for the array range |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if startInclusive is negative, endExclusive is less than startInclusive , or endExclusive is greater than the array size |
stream
static fun stream(array: IntArray): IntStream
Returns a sequential IntStream
with the specified array as its source.
Parameters | |
---|---|
array |
IntArray: the array, assumed to be unmodified during use |
Return | |
---|---|
IntStream |
an IntStream for the array |
stream
static fun stream(
array: IntArray,
startInclusive: Int,
endExclusive: Int
): IntStream
Returns a sequential IntStream
with the specified range of the specified array as its source.
Parameters | |
---|---|
array |
IntArray: the array, assumed to be unmodified during use |
startInclusive |
Int: the first index to cover, inclusive |
endExclusive |
Int: index immediately past the last index to cover |
Return | |
---|---|
IntStream |
an IntStream for the array range |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if startInclusive is negative, endExclusive is less than startInclusive , or endExclusive is greater than the array size |
stream
static fun stream(array: LongArray): LongStream
Returns a sequential LongStream
with the specified array as its source.
Parameters | |
---|---|
array |
LongArray: the array, assumed to be unmodified during use |
Return | |
---|---|
LongStream |
a LongStream for the array |
stream
static fun stream(
array: LongArray,
startInclusive: Int,
endExclusive: Int
): LongStream
Returns a sequential LongStream
with the specified range of the specified array as its source.
Parameters | |
---|---|
array |
LongArray: the array, assumed to be unmodified during use |
startInclusive |
Int: the first index to cover, inclusive |
endExclusive |
Int: index immediately past the last index to cover |
Return | |
---|---|
LongStream |
a LongStream for the array range |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if startInclusive is negative, endExclusive is less than startInclusive , or endExclusive is greater than the array size |
stream
static fun <T : Any!> stream(array: Array<T>): Stream<T>
Returns a sequential Stream
with the specified array as its source.
Parameters | |
---|---|
<T> |
The type of the array elements |
array |
Array<T>: The array, assumed to be unmodified during use |
Return | |
---|---|
Stream<T> |
a Stream for the array |
stream
static fun <T : Any!> stream(
array: Array<T>,
startInclusive: Int,
endExclusive: Int
): Stream<T>
Returns a sequential Stream
with the specified range of the specified array as its source.
Parameters | |
---|---|
<T> |
the type of the array elements |
array |
Array<T>: the array, assumed to be unmodified during use |
startInclusive |
Int: the first index to cover, inclusive |
endExclusive |
Int: index immediately past the last index to cover |
Return | |
---|---|
Stream<T> |
a Stream for the array range |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
if startInclusive is negative, endExclusive is less than startInclusive , or endExclusive is greater than the array size |
toString
static fun toString(a: BooleanArray?): String
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
.
Parameters | |
---|---|
a |
BooleanArray?: the array whose string representation to return |
Return | |
---|---|
String |
a string representation of a |
toString
static fun toString(a: ByteArray?): String
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
.
Parameters | |
---|---|
a |
ByteArray?: the array whose string representation to return |
Return | |
---|---|
String |
a string representation of a |
toString
static fun toString(a: CharArray?): String
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
.
Parameters | |
---|---|
a |
CharArray?: the array whose string representation to return |
Return | |
---|---|
String |
a string representation of a |
toString
static fun toString(a: DoubleArray?): String
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
.
Parameters | |
---|---|
a |
DoubleArray?: the array whose string representation to return |
Return | |
---|---|
String |
a string representation of a |
toString
static fun toString(a: FloatArray?): String
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
.
Parameters | |
---|---|
a |
FloatArray?: the array whose string representation to return |
Return | |
---|---|
String |
a string representation of a |
toString
static fun toString(a: IntArray?): String
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
.
Parameters | |
---|---|
a |
IntArray?: the array whose string representation to return |
Return | |
---|---|
String |
a string representation of a |
toString
static fun toString(a: Array<Any!>?): String
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.
Parameters | |
---|---|
a |
Array<Any!>?: the array whose string representation to return |
Return | |
---|---|
String |
a string representation of a |
See Also
toString
static fun toString(a: LongArray?): String
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
.
Parameters | |
---|---|
a |
LongArray?: the array whose string representation to return |
Return | |
---|---|
String |
a string representation of a |
toString
static fun toString(a: ShortArray?): String
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
.
Parameters | |
---|---|
a |
ShortArray?: the array whose string representation to return |
Return | |
---|---|
String |
a string representation of a |