Correct abstract mutable collections declarations in kotlin-stdlib-common
Add SinceKotlin(1.3) to the new and substantially changed common declarations #KT-28091
This commit is contained in:
@@ -10,11 +10,11 @@ package kotlin.collections
|
||||
*
|
||||
* @param E the type of elements contained in the collection. The collection is invariant on its element type.
|
||||
*/
|
||||
public abstract class AbstractMutableCollection<E> protected constructor() : AbstractCollection<E>(), MutableCollection<E> {
|
||||
public actual abstract class AbstractMutableCollection<E> protected actual constructor() : AbstractCollection<E>(), MutableCollection<E> {
|
||||
|
||||
abstract override fun add(element: E): Boolean
|
||||
actual abstract override fun add(element: E): Boolean
|
||||
|
||||
override fun remove(element: E): Boolean {
|
||||
actual override fun remove(element: E): Boolean {
|
||||
val iterator = iterator()
|
||||
while (iterator.hasNext()) {
|
||||
if (iterator.next() == element) {
|
||||
@@ -25,7 +25,7 @@ public abstract class AbstractMutableCollection<E> protected constructor() : Abs
|
||||
return false
|
||||
}
|
||||
|
||||
override fun addAll(elements: Collection<E>): Boolean {
|
||||
actual override fun addAll(elements: Collection<E>): Boolean {
|
||||
var modified = false
|
||||
for (element in elements) {
|
||||
if (add(element)) modified = true
|
||||
@@ -33,10 +33,10 @@ public abstract class AbstractMutableCollection<E> protected constructor() : Abs
|
||||
return modified
|
||||
}
|
||||
|
||||
override fun removeAll(elements: Collection<E>): Boolean = (this as MutableIterable<E>).removeAll { it in elements }
|
||||
override fun retainAll(elements: Collection<E>): Boolean = (this as MutableIterable<E>).removeAll { it !in elements }
|
||||
actual override fun removeAll(elements: Collection<E>): Boolean = (this as MutableIterable<E>).removeAll { it in elements }
|
||||
actual override fun retainAll(elements: Collection<E>): Boolean = (this as MutableIterable<E>).removeAll { it !in elements }
|
||||
|
||||
override fun clear(): Unit {
|
||||
actual override fun clear(): Unit {
|
||||
val iterator = this.iterator()
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next()
|
||||
|
||||
@@ -41,12 +41,12 @@ public actual abstract class AbstractMutableMap<K, V> protected actual construct
|
||||
|
||||
}
|
||||
|
||||
override fun clear() {
|
||||
actual override fun clear() {
|
||||
entries.clear()
|
||||
}
|
||||
|
||||
private var _keys: MutableSet<K>? = null
|
||||
override val keys: MutableSet<K>
|
||||
actual override val keys: MutableSet<K>
|
||||
get() {
|
||||
if (_keys == null) {
|
||||
_keys = object : AbstractMutableSet<K>() {
|
||||
@@ -82,14 +82,14 @@ public actual abstract class AbstractMutableMap<K, V> protected actual construct
|
||||
|
||||
actual abstract override fun put(key: K, value: V): V?
|
||||
|
||||
override fun putAll(from: Map<out K, V>) {
|
||||
actual override fun putAll(from: Map<out K, V>) {
|
||||
for ((key, value) in from) {
|
||||
put(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
private var _values: MutableCollection<V>? = null
|
||||
override val values: MutableCollection<V>
|
||||
actual override val values: MutableCollection<V>
|
||||
get() {
|
||||
if (_values == null) {
|
||||
_values = object : AbstractMutableCollection<V>() {
|
||||
@@ -122,10 +122,10 @@ public actual abstract class AbstractMutableMap<K, V> protected actual construct
|
||||
return _values!!
|
||||
}
|
||||
|
||||
override fun remove(key: K): V? {
|
||||
actual override fun remove(key: K): V? {
|
||||
val iter = entries.iterator()
|
||||
while (iter.hasNext()) {
|
||||
var entry = iter.next()
|
||||
val entry = iter.next()
|
||||
val k = entry.key
|
||||
if (key == k) {
|
||||
val value = entry.value
|
||||
|
||||
Reference in New Issue
Block a user