Provide java.util.Collections#shuffle as extensions for collections in JS
#KT-2460
This commit is contained in:
committed by
Ilya Gorbunov
parent
6fc87c532e
commit
e640867238
@@ -149,10 +149,12 @@ expect inline fun <reified T> Array<out T>?.orEmpty(): Array<out T>
|
||||
|
||||
expect inline fun <reified T> Collection<T>.toTypedArray(): Array<T>
|
||||
|
||||
@SinceKotlin("1.2")
|
||||
expect fun <T> MutableList<T>.fill(value: T): Unit
|
||||
expect fun <T : Comparable<T>> MutableList<T>.sort(): Unit
|
||||
expect fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit
|
||||
@SinceKotlin("1.2") header fun <T> MutableList<T>.fill(value: T): Unit
|
||||
@SinceKotlin("1.2") header fun <T> MutableList<T>.shuffle(): Unit
|
||||
@SinceKotlin("1.2") header fun <T> Iterable<T>.shuffled(): List<T>
|
||||
|
||||
header fun <T : Comparable<T>> MutableList<T>.sort(): Unit
|
||||
header fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit
|
||||
|
||||
|
||||
// from Grouping.kt
|
||||
|
||||
@@ -101,7 +101,6 @@ class MutableCollectionTest {
|
||||
assertEquals(listOf(42, 42, 42), list)
|
||||
}
|
||||
|
||||
@JvmVersion
|
||||
@Test fun shuffled() {
|
||||
val list = MutableList(100) { it }
|
||||
val shuffled = list.shuffled()
|
||||
@@ -127,6 +126,4 @@ class MutableCollectionTest {
|
||||
|
||||
assertEquals(shuffled1, shuffled2)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user