stdlib: Add clear and remove methods in AbstractMutableCollection
This commit is contained in:
@@ -790,9 +790,9 @@ task lateinit_notInitialized(type: RunKonanTest) {
|
||||
source = "codegen/lateinit/notInitialized.kt"
|
||||
}
|
||||
|
||||
task AbstractMutableCollectionRemoveAll(type: RunKonanTest) {
|
||||
task AbstractMutableCollection(type: RunKonanTest) {
|
||||
expectedExitStatus = 0
|
||||
source = "runtime/collections/AbstractMutableCollectionRemoveAll.kt"
|
||||
source = "runtime/collections/AbstractMutableCollection.kt"
|
||||
}
|
||||
|
||||
task array0(type: RunKonanTest) {
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ inline fun <T, R : Comparable<R>> assertSorted(list: List<out T>, message: Strin
|
||||
}
|
||||
val it = list.iterator()
|
||||
var prev = selector(it.next())
|
||||
while(it.hasNext()) {
|
||||
while (it.hasNext()) {
|
||||
val cur = selector(it.next())
|
||||
assertTrue(prev.compareTo(cur) <= 0, message)
|
||||
prev = cur
|
||||
@@ -21,7 +21,7 @@ inline fun <T, R : Comparable<R>> assertSortedDescending(list: List<out T>, mess
|
||||
}
|
||||
val it = list.iterator()
|
||||
var prev = selector(it.next())
|
||||
while(it.hasNext()) {
|
||||
while (it.hasNext()) {
|
||||
val cur = selector(it.next())
|
||||
assertTrue(prev.compareTo(cur) >= 0, message)
|
||||
prev = cur
|
||||
|
||||
+4
-11
@@ -15,17 +15,6 @@ class TestCollection(): AbstractMutableCollection<Int>() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun remove(element: Int): Boolean {
|
||||
val it = iterator()
|
||||
while(it.hasNext()) {
|
||||
if (it.next() == element) {
|
||||
it.remove()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun iterator(): MutableIterator<Int> = object: MutableIterator<Int> {
|
||||
var nextIndex = 0
|
||||
|
||||
@@ -67,4 +56,8 @@ fun main(args: Array<String>) {
|
||||
assertEquals(c, listOf(3, 4, 5, 4))
|
||||
c.retainAll(listOf(4, 5))
|
||||
assertEquals(c, listOf(4, 5, 4))
|
||||
c.remove(4)
|
||||
assertEquals(c, listOf(5, 4))
|
||||
c.clear()
|
||||
assertEquals(c, listOf())
|
||||
}
|
||||
Reference in New Issue
Block a user