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