Provide MutableList.fill for JS, annotate new API with @SinceKotlin

#KT-8823 #KT-9010
This commit is contained in:
Ilya Gorbunov
2017-06-09 01:29:29 +03:00
parent bb22d6647b
commit a8fef3a385
4 changed files with 19 additions and 1 deletions
+12
View File
@@ -79,6 +79,18 @@ public fun <T> setOf(element: T): Set<T> = hashSetOf(element)
*/
public fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V> = hashMapOf(pair)
/**
* Fills the list with the provided [value].
*
* Each element in the list gets replaced with the [value].
*/
@SinceKotlin("1.2")
public fun <T> MutableList<T>.fill(value: T) {
for (index in 0..lastIndex) {
this[index] = value
}
}
/**
* Sorts elements in the list in-place according to their natural sort order.
*/