Document fromIndex and toIndex parameters #KT-38388

This commit is contained in:
Abduqodiri Qurbonzoda
2020-04-21 05:59:10 +03:00
parent 3c1b41c020
commit 0c7b04a495
9 changed files with 893 additions and 209 deletions
+187 -36
View File
@@ -247,10 +247,18 @@ public actual fun CharArray.asList(): List<Char> {
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the element to search for.
* @param comparator the comparator according to which this array is sorted.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted according to the specified [comparator].
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
public fun <T> Array<out T>.binarySearch(element: T, comparator: Comparator<in T>, fromIndex: Int = 0, toIndex: Int = size): Int {
return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element, comparator)
@@ -262,10 +270,17 @@ public fun <T> Array<out T>.binarySearch(element: T, comparator: Comparator<in T
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the to search for.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
public fun <T> Array<out T>.binarySearch(element: T, fromIndex: Int = 0, toIndex: Int = size): Int {
return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
@@ -277,10 +292,17 @@ public fun <T> Array<out T>.binarySearch(element: T, fromIndex: Int = 0, toIndex
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the to search for.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
public fun ByteArray.binarySearch(element: Byte, fromIndex: Int = 0, toIndex: Int = size): Int {
return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
@@ -292,10 +314,17 @@ public fun ByteArray.binarySearch(element: Byte, fromIndex: Int = 0, toIndex: In
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the to search for.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex: Int = size): Int {
return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
@@ -307,10 +336,17 @@ public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex:
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the to search for.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
public fun IntArray.binarySearch(element: Int, fromIndex: Int = 0, toIndex: Int = size): Int {
return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
@@ -322,10 +358,17 @@ public fun IntArray.binarySearch(element: Int, fromIndex: Int = 0, toIndex: Int
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the to search for.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
public fun LongArray.binarySearch(element: Long, fromIndex: Int = 0, toIndex: Int = size): Int {
return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
@@ -337,10 +380,17 @@ public fun LongArray.binarySearch(element: Long, fromIndex: Int = 0, toIndex: In
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the to search for.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
public fun FloatArray.binarySearch(element: Float, fromIndex: Int = 0, toIndex: Int = size): Int {
return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
@@ -352,10 +402,17 @@ public fun FloatArray.binarySearch(element: Float, fromIndex: Int = 0, toIndex:
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the to search for.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
public fun DoubleArray.binarySearch(element: Double, fromIndex: Int = 0, toIndex: Int = size): Int {
return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
@@ -367,10 +424,17 @@ public fun DoubleArray.binarySearch(element: Double, fromIndex: Int = 0, toIndex
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the to search for.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
public fun CharArray.binarySearch(element: Char, fromIndex: Int = 0, toIndex: Int = size): Int {
return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
@@ -1556,8 +1620,11 @@ public actual inline fun <T> Array<T>.copyOf(newSize: Int): Array<T?> {
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
@@ -1573,8 +1640,11 @@ public actual inline fun <T> Array<T>.copyOfRange(fromIndex: Int, toIndex: Int):
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
@@ -1590,8 +1660,11 @@ public actual inline fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): By
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
@@ -1607,8 +1680,11 @@ public actual inline fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): S
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
@@ -1624,8 +1700,11 @@ public actual inline fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): Int
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
@@ -1641,8 +1720,11 @@ public actual inline fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): Lo
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
@@ -1658,8 +1740,11 @@ public actual inline fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): F
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
@@ -1675,8 +1760,11 @@ public actual inline fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int):
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
@@ -1692,8 +1780,11 @@ public actual inline fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int):
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive), must be in `0..array.size`
* @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
@@ -1781,8 +1872,8 @@ internal fun CharArray.copyOfRangeImpl(fromIndex: Int, toIndex: Int): CharArray
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive), 0 by default.
* @param toIndex the end of the range (exclusive), size of this array by default.
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
@@ -1795,8 +1886,8 @@ public actual fun <T> Array<T>.fill(element: T, fromIndex: Int = 0, toIndex: Int
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive), 0 by default.
* @param toIndex the end of the range (exclusive), size of this array by default.
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
@@ -1809,8 +1900,8 @@ public actual fun ByteArray.fill(element: Byte, fromIndex: Int = 0, toIndex: Int
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive), 0 by default.
* @param toIndex the end of the range (exclusive), size of this array by default.
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
@@ -1823,8 +1914,8 @@ public actual fun ShortArray.fill(element: Short, fromIndex: Int = 0, toIndex: I
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive), 0 by default.
* @param toIndex the end of the range (exclusive), size of this array by default.
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
@@ -1837,8 +1928,8 @@ public actual fun IntArray.fill(element: Int, fromIndex: Int = 0, toIndex: Int =
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive), 0 by default.
* @param toIndex the end of the range (exclusive), size of this array by default.
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
@@ -1851,8 +1942,8 @@ public actual fun LongArray.fill(element: Long, fromIndex: Int = 0, toIndex: Int
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive), 0 by default.
* @param toIndex the end of the range (exclusive), size of this array by default.
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
@@ -1865,8 +1956,8 @@ public actual fun FloatArray.fill(element: Float, fromIndex: Int = 0, toIndex: I
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive), 0 by default.
* @param toIndex the end of the range (exclusive), size of this array by default.
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
@@ -1879,8 +1970,8 @@ public actual fun DoubleArray.fill(element: Double, fromIndex: Int = 0, toIndex:
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive), 0 by default.
* @param toIndex the end of the range (exclusive), size of this array by default.
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
@@ -1893,8 +1984,8 @@ public actual fun BooleanArray.fill(element: Boolean, fromIndex: Int = 0, toInde
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive), 0 by default.
* @param toIndex the end of the range (exclusive), size of this array by default.
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
@@ -2283,6 +2374,12 @@ public fun <T> Array<out T>.sort(): Unit {
*
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArrayOfComparable
*/
@SinceKotlin("1.4")
@@ -2294,6 +2391,12 @@ public actual fun <T : Comparable<T>> Array<out T>.sort(fromIndex: Int = 0, toIn
/**
* Sorts a range in the array in-place.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
@@ -2304,6 +2407,12 @@ public actual fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit
/**
* Sorts a range in the array in-place.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
@@ -2314,6 +2423,12 @@ public actual fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit
/**
* Sorts a range in the array in-place.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
@@ -2324,6 +2439,12 @@ public actual fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
/**
* Sorts a range in the array in-place.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
@@ -2334,6 +2455,12 @@ public actual fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit
/**
* Sorts a range in the array in-place.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
@@ -2344,6 +2471,12 @@ public actual fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit
/**
* Sorts a range in the array in-place.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
@@ -2354,6 +2487,12 @@ public actual fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size): Uni
/**
* Sorts a range in the array in-place.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
@@ -2366,6 +2505,12 @@ public actual fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit
*
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArrayOfComparable
*/
public fun <T> Array<out T>.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
@@ -2385,6 +2530,12 @@ public actual fun <T> Array<out T>.sortWith(comparator: Comparator<in T>): Unit
* Sorts a range in the array in-place with the given [comparator].
*
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun <T> Array<out T>.sortWith(comparator: Comparator<in T>, fromIndex: Int = 0, toIndex: Int = size): Unit {
@@ -135,10 +135,17 @@ public actual fun UShortArray.asList(): List<UShort> {
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the to search for.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@@ -167,10 +174,17 @@ public fun UIntArray.binarySearch(element: UInt, fromIndex: Int = 0, toIndex: In
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the to search for.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@@ -199,10 +213,17 @@ public fun ULongArray.binarySearch(element: ULong, fromIndex: Int = 0, toIndex:
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the to search for.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@@ -231,10 +252,17 @@ public fun UByteArray.binarySearch(element: UByte, fromIndex: Int = 0, toIndex:
*
* If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
*
* @param element the to search for.
* @param fromIndex the start of the range (inclusive) to search in, 0 by default.
* @param toIndex the end of the range (exclusive) to search in, size of this array by default.
*
* @return the index of the element, if it is contained in the array within the specified range;
* otherwise, the inverted insertion point `(-insertion point - 1)`.
* The insertion point is defined as the index at which the element should be inserted,
* so that the array (or the specified subrange of array) still remains sorted.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes