JS: drop Collections.reverse and java.util.Collections altogether

This commit is contained in:
Alexander Udalov
2016-11-02 12:35:23 +03:00
parent e8fecea871
commit 3db459c1d8
5 changed files with 19 additions and 15 deletions
+14
View File
@@ -61,3 +61,17 @@ public fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit {
@library("collectionsSort")
private fun <T> collectionsSort(list: MutableList<T>, comparator: Comparator<in T>): Unit = noImpl
/**
* Reverses elements in the list in-place.
*/
public fun <T> MutableList<T>.reverse(): Unit {
val size = this.size
for (i in 0..(size / 2) - 1) {
val i2 = size - i - 1
val tmp = this[i]
this[i] = this[i2]
this[i2] = tmp
}
}
@@ -1,14 +0,0 @@
package java.util
public object Collections {
@Deprecated("Use list.reverse() instead.", ReplaceWith("list.reverse()"))
public fun <T> reverse(list: MutableList<T>): Unit {
val size = list.size
for (i in 0..(size / 2) - 1) {
val i2 = size - i - 1
val tmp = list[i]
list[i] = list[i2]
list[i2] = tmp
}
}
}