stdlib: Improve ArrayList.removeAll implementation.

This patch replaces ArrayList.removeAll implementation with a
faster one. It also adds the AbstractMutableCollection class
containing default implementations for addAll, removeAll and
retainAll methods and fixes tests to check if removeAll removes
all occurrences found or not.
This commit is contained in:
Ilya Matveev
2017-04-14 12:50:22 +07:00
committed by ilmat192
parent 69a49f987c
commit 321386d95e
7 changed files with 139 additions and 46 deletions
@@ -85,9 +85,9 @@ fun testRemove() {
}
fun testRemoveAll() {
val a = ArrayList(listOf("1", "2", "3", "4", "5"))
val a = ArrayList(listOf("1", "2", "3", "4", "5", "1"))
assertFalse(a.removeAll(listOf("6", "7", "8")))
assertEquals(listOf("1", "2", "3", "4", "5"), a)
assertEquals(listOf("1", "2", "3", "4", "5", "1"), a)
assertTrue(a.removeAll(listOf("5", "3", "1")))
assertEquals(listOf("2", "4"), a)
}
@@ -277,9 +277,9 @@ fun testSubListSubListRemoveAt() {
}
fun testSubListRemoveAll() {
val a = ArrayList(listOf("1", "2", "3", "4", "5"))
val s = a.subList(1, 4)
assertEquals(listOf("2", "3", "4"), s)
val a = ArrayList(listOf("1", "2", "3", "3", "4", "5"))
val s = a.subList(1, 5)
assertEquals(listOf("2", "3", "3", "4"), s)
assertTrue(s.removeAll(listOf("3", "5")))
assertEquals(listOf("2", "4"), s)