kotlin.collections.MutableCollectionsJVM.kt Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
@file:kotlin.jvm.JvmMultifileClass
@file:kotlin.jvm.JvmName("CollectionsKt")
package kotlin.collections
@Deprecated("Use sortWith(comparator) instead.", ReplaceWith("this.sortWith(comparator)"), level = DeprecationLevel.ERROR)
@kotlin.internal.InlineOnly
@Suppress("UNUSED_PARAMETER")
public inline fun MutableList.sort(comparator: Comparator): Unit = throw NotImplementedError()
@Deprecated("Use sortWith(Comparator(comparison)) instead.", ReplaceWith("this.sortWith(Comparator(comparison))"), level = DeprecationLevel.ERROR)
@kotlin.internal.InlineOnly
@Suppress("UNUSED_PARAMETER")
public inline fun MutableList.sort(comparison: (T, T) -> Int): Unit = throw NotImplementedError()
/**
* Sorts elements in the list in-place according to their natural sort order.
*/
public actual fun > MutableList.sort(): Unit {
if (size > 1) java.util.Collections.sort(this)
}
/**
* Sorts elements in the list in-place according to the order specified with [comparator].
*/
public actual fun MutableList.sortWith(comparator: Comparator): Unit {
if (size > 1) java.util.Collections.sort(this, comparator)
}
/**
* Fills the list with the provided [value].
*
* Each element in the list gets replaced with the [value].
*/
@kotlin.internal.InlineOnly
@SinceKotlin("1.2")
public actual inline fun MutableList.fill(value: T) {
java.util.Collections.fill(this, value)
}
/**
* Randomly shuffles elements in this mutable list.
*/
@kotlin.internal.InlineOnly
@SinceKotlin("1.2")
public actual inline fun MutableList.shuffle() {
java.util.Collections.shuffle(this)
}
/**
* Randomly shuffles elements in this mutable list using the specified [random] instance as the source of randomness.
*/
@kotlin.internal.InlineOnly
@SinceKotlin("1.2")
public inline fun MutableList.shuffle(random: java.util.Random) {
java.util.Collections.shuffle(this, random)
}
/**
* Returns a new list with the elements of this list randomly shuffled.
*/
@SinceKotlin("1.2")
public actual fun Iterable.shuffled(): List = toMutableList().apply { shuffle() }
/**
* Returns a new list with the elements of this list randomly shuffled
* using the specified [random] instance as the source of randomness.
*/
@SinceKotlin("1.2")
public fun Iterable.shuffled(random: java.util.Random): List = toMutableList().apply { shuffle(random) }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy