JS: drop Collections.max
This commit is contained in:
@@ -1,13 +1,6 @@
|
||||
package java.util
|
||||
|
||||
import java.lang.*
|
||||
import java.util.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
public object Collections {
|
||||
@Deprecated("Use collection.maxWith(comparator) instead.", ReplaceWith("col.maxWith(comp)"))
|
||||
public fun <T> max(col: Collection<T>, comp: Comparator<in T>): T = java.util.max(col, comp)
|
||||
|
||||
@Deprecated("Use list.reverse() instead.", ReplaceWith("list.reverse()"))
|
||||
public fun <T> reverse(list: MutableList<T>): Unit {
|
||||
val size = list.size
|
||||
@@ -19,6 +12,3 @@ public object Collections {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@library("collectionsMax")
|
||||
private fun <T> max(col: Collection<T>, comp: Comparator<in T>): T = noImpl
|
||||
|
||||
-16
@@ -759,22 +759,6 @@
|
||||
compare: throwAbstractFunctionInvocationError("Comparator#compare")
|
||||
});
|
||||
|
||||
Kotlin.collectionsMax = function (c, comp) {
|
||||
if (c.isEmpty()) {
|
||||
//TODO: which exception?
|
||||
throw new Error();
|
||||
}
|
||||
var it = c.iterator();
|
||||
var max = it.next();
|
||||
while (it.hasNext()) {
|
||||
var el = it.next();
|
||||
if (comp.compare(max, el) < 0) {
|
||||
max = el;
|
||||
}
|
||||
}
|
||||
return max;
|
||||
};
|
||||
|
||||
Kotlin.collectionsSort = function (mutableList, comparator) {
|
||||
var boundComparator = void 0;
|
||||
if (comparator !== void 0) {
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
package test.collections.js
|
||||
|
||||
import java.util.*
|
||||
|
||||
import kotlin.test.*
|
||||
import org.junit.Test as test
|
||||
import kotlin.comparisons.*
|
||||
import org.junit.Test as test
|
||||
|
||||
class JsCollectionsTest {
|
||||
val TEST_LIST = arrayOf(2, 0, 9, 7, 1).toList()
|
||||
val MAX_ELEMENT = 9
|
||||
val COMPARATOR = Comparator { x: Int, y: Int -> if (x > y) 1 else if (x < y) -1 else 0 }
|
||||
|
||||
@test fun maxWithComparator() {
|
||||
assertEquals(MAX_ELEMENT, Collections.max(TEST_LIST, COMPARATOR))
|
||||
}
|
||||
|
||||
@test fun collectionToArray() {
|
||||
val array = TEST_LIST.toTypedArray()
|
||||
|
||||
Reference in New Issue
Block a user