Minor cleanup, rename parameters to match supertype names.
This commit is contained in:
@@ -32,9 +32,9 @@ abstract class AbstractMap<K, V> protected constructor() : MutableMap<K, V> {
|
||||
|
||||
override val value: V get() = _value
|
||||
|
||||
override fun setValue(value: V): V {
|
||||
override fun setValue(newValue: V): V {
|
||||
val oldValue = this._value
|
||||
this._value = value
|
||||
this._value = newValue
|
||||
return oldValue
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ abstract class AbstractMap<K, V> protected constructor() : MutableMap<K, V> {
|
||||
this@AbstractMap.clear()
|
||||
}
|
||||
|
||||
override operator fun contains(key: K): Boolean = containsKey(key)
|
||||
override operator fun contains(element: K): Boolean = containsKey(element)
|
||||
|
||||
override operator fun iterator(): MutableIterator<K> {
|
||||
val outerIter = entries.iterator()
|
||||
@@ -118,9 +118,9 @@ abstract class AbstractMap<K, V> protected constructor() : MutableMap<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
override fun remove(key: K): Boolean {
|
||||
if (containsKey(key)) {
|
||||
this@AbstractMap.remove(key)
|
||||
override fun remove(element: K): Boolean {
|
||||
if (containsKey(element)) {
|
||||
this@AbstractMap.remove(element)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -134,8 +134,8 @@ abstract class AbstractMap<K, V> protected constructor() : MutableMap<K, V> {
|
||||
throw UnsupportedOperationException("Put not supported on this map")
|
||||
}
|
||||
|
||||
override fun putAll(map: Map<out K, V>) {
|
||||
for ((key, value) in map) {
|
||||
override fun putAll(from: Map<out K, V>) {
|
||||
for ((key, value) in from) {
|
||||
put(key, value)
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ abstract class AbstractMap<K, V> protected constructor() : MutableMap<K, V> {
|
||||
return object : AbstractCollection<V>() {
|
||||
override fun clear() = this@AbstractMap.clear()
|
||||
|
||||
override operator fun contains(value: V): Boolean = containsValue(value)
|
||||
override operator fun contains(element: V): Boolean = containsValue(element)
|
||||
|
||||
override operator fun iterator(): MutableIterator<V> {
|
||||
val outerIter = entries.iterator()
|
||||
|
||||
@@ -35,9 +35,9 @@ open class HashMap<K, V> : AbstractMap<K, V> {
|
||||
|
||||
override operator fun iterator(): MutableIterator<MutableEntry<K, V>> = internalMap.iterator()
|
||||
|
||||
override fun remove(entry: MutableEntry<K, V>): Boolean {
|
||||
if (contains(entry)) {
|
||||
this@HashMap.remove(entry.key)
|
||||
override fun remove(element: MutableEntry<K, V>): Boolean {
|
||||
if (contains(element)) {
|
||||
this@HashMap.remove(element.key)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
/**
|
||||
* The common interface of [InternalStringMap] and [InternalHashCodeMap].
|
||||
*/
|
||||
internal interface InternalMap<K, V> : MutableIterable<MutableMap.MutableEntry<K, V>> {
|
||||
val equality: EqualityComparator
|
||||
val size: Int
|
||||
|
||||
@@ -70,7 +70,7 @@ internal class InternalStringMap<K, V>(override val equality: EqualityComparator
|
||||
if (key !is String) return null
|
||||
val value = backingMap[key]
|
||||
if (value !== undefined) {
|
||||
deleteProperty(backingMap, key!!)
|
||||
deleteProperty(backingMap, key)
|
||||
size--
|
||||
// structureChanged(host)
|
||||
return value as V
|
||||
@@ -112,7 +112,7 @@ internal class InternalStringMap<K, V>(override val equality: EqualityComparator
|
||||
override val key: K get() = key
|
||||
override val value: V get() = this@InternalStringMap[key] as V
|
||||
|
||||
override fun setValue(value: V): V = this@InternalStringMap.put(key, value) as V
|
||||
override fun setValue(newValue: V): V = this@InternalStringMap.put(key, newValue) as V
|
||||
|
||||
override fun hashCode(): Int = AbstractMap.entryHashCode(this)
|
||||
override fun toString(): String = AbstractMap.entryToString(this)
|
||||
|
||||
@@ -133,9 +133,9 @@ open class LinkedHashMap<K, V> : HashMap<K, V>, Map<K, V> {
|
||||
|
||||
override operator fun iterator(): MutableIterator<MutableEntry<K, V>> = EntryIterator()
|
||||
|
||||
override fun remove(entry: MutableEntry<K, V>): Boolean {
|
||||
if (contains(entry)) {
|
||||
this@LinkedHashMap.remove(entry.key)
|
||||
override fun remove(element: MutableEntry<K, V>): Boolean {
|
||||
if (contains(element)) {
|
||||
this@LinkedHashMap.remove(element.key)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user