KT-16602: Provide samples for sorting API usage
This commit is contained in:
@@ -1728,6 +1728,8 @@ public actual inline fun <T> Array<T>.plusElement(element: T): Array<T> {
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortArray
|
||||
*/
|
||||
public actual fun IntArray.sort(): Unit {
|
||||
if (size > 1) java.util.Arrays.sort(this)
|
||||
@@ -1735,6 +1737,8 @@ public actual fun IntArray.sort(): Unit {
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortArray
|
||||
*/
|
||||
public actual fun LongArray.sort(): Unit {
|
||||
if (size > 1) java.util.Arrays.sort(this)
|
||||
@@ -1742,6 +1746,8 @@ public actual fun LongArray.sort(): Unit {
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortArray
|
||||
*/
|
||||
public actual fun ByteArray.sort(): Unit {
|
||||
if (size > 1) java.util.Arrays.sort(this)
|
||||
@@ -1749,6 +1755,8 @@ public actual fun ByteArray.sort(): Unit {
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortArray
|
||||
*/
|
||||
public actual fun ShortArray.sort(): Unit {
|
||||
if (size > 1) java.util.Arrays.sort(this)
|
||||
@@ -1756,6 +1764,8 @@ public actual fun ShortArray.sort(): Unit {
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortArray
|
||||
*/
|
||||
public actual fun DoubleArray.sort(): Unit {
|
||||
if (size > 1) java.util.Arrays.sort(this)
|
||||
@@ -1763,6 +1773,8 @@ public actual fun DoubleArray.sort(): Unit {
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortArray
|
||||
*/
|
||||
public actual fun FloatArray.sort(): Unit {
|
||||
if (size > 1) java.util.Arrays.sort(this)
|
||||
@@ -1770,6 +1782,8 @@ public actual fun FloatArray.sort(): Unit {
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortArray
|
||||
*/
|
||||
public actual fun CharArray.sort(): Unit {
|
||||
if (size > 1) java.util.Arrays.sort(this)
|
||||
@@ -1779,6 +1793,8 @@ public actual fun CharArray.sort(): Unit {
|
||||
* Sorts the array in-place according to the natural order of its elements.
|
||||
*
|
||||
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortArrayOfComparable
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun <T : Comparable<T>> Array<out T>.sort(): Unit {
|
||||
@@ -1801,6 +1817,8 @@ public fun <T> Array<out T>.sort(): Unit {
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfComparable
|
||||
*/
|
||||
public fun <T> Array<out T>.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
@@ -1808,6 +1826,8 @@ public fun <T> Array<out T>.sort(fromIndex: Int = 0, toIndex: Int = size): Unit
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfComparable
|
||||
*/
|
||||
public fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
@@ -1815,6 +1835,8 @@ public fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfComparable
|
||||
*/
|
||||
public fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
@@ -1822,6 +1844,8 @@ public fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfComparable
|
||||
*/
|
||||
public fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
@@ -1829,6 +1853,8 @@ public fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfComparable
|
||||
*/
|
||||
public fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
@@ -1836,6 +1862,8 @@ public fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfComparable
|
||||
*/
|
||||
public fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
@@ -1843,6 +1871,8 @@ public fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfComparable
|
||||
*/
|
||||
public fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
@@ -1850,6 +1880,8 @@ public fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
|
||||
/**
|
||||
* Sorts a range in the array in-place.
|
||||
*
|
||||
* @sample samples.collections.Arrays.Sorting.sortRangeOfComparable
|
||||
*/
|
||||
public fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
|
||||
java.util.Arrays.sort(this, fromIndex, toIndex)
|
||||
|
||||
Reference in New Issue
Block a user