Transform builtin Map declaration and adjust stdlib

This commit is contained in:
Denis Zharkov
2015-10-12 19:54:12 +03:00
committed by Mikhail Glukhikh
parent f0e3fd617d
commit 6fa8083a70
11 changed files with 146 additions and 53 deletions
@@ -66,12 +66,12 @@ private class MapWithDefaultImpl<K, out V>(public override val map: Map<K,V>, pr
override fun toString(): String = map.toString()
override val size: Int get() = map.size()
override val isEmpty: Boolean get() = map.isEmpty()
override fun containsKey(key: Any?): Boolean = map.containsKey(key)
override fun containsValue(value: Any?): Boolean = map.containsValue(value)
override fun get(key: Any?): V? = map.get(key)
override fun keySet(): Set<K> = map.keySet()
override fun values(): Collection<V> = map.values()
override fun entrySet(): Set<Map.Entry<K, V>> = map.entrySet()
override fun containsKey(key: K): Boolean = map.containsKey(key)
override fun containsValue(value: @UnsafeVariance V): Boolean = map.containsValue(value)
override fun get(key: K): V? = map.get(key)
override val keys: Set<K> get() = map.keys
override val values: Collection<V> get() = map.values
override val entries: Set<Map.Entry<K, V>> get() = map.entries
override fun getOrImplicitDefault(key: K): V = map.getOrElse(key, { default(key) })
}
@@ -82,15 +82,15 @@ private class MutableMapWithDefaultImpl<K, V>(public override val map: MutableMa
override fun toString(): String = map.toString()
override val size: Int get() = map.size()
override val isEmpty: Boolean get() = map.isEmpty()
override fun containsKey(key: Any?): Boolean = map.containsKey(key)
override fun containsValue(value: Any?): Boolean = map.containsValue(value)
override fun get(key: Any?): V? = map.get(key)
override fun keySet(): MutableSet<K> = map.keySet()
override fun values(): MutableCollection<V> = map.values()
override fun entrySet(): MutableSet<MutableMap.MutableEntry<K, V>> = map.entrySet()
override fun containsKey(key: K): Boolean = map.containsKey(key)
override fun containsValue(value: @UnsafeVariance V): Boolean = map.containsValue(value)
override fun get(key: K): V? = map.get(key)
override val keys: MutableSet<K> get() = map.keys
override val values: MutableCollection<V> get() = map.values
override val entries: MutableSet<MutableMap.MutableEntry<K, V>> get() = map.entries
override fun put(key: K, value: V): V? = map.put(key, value)
override fun remove(key: Any?): V? = map.remove(key)
override fun remove(key: K): V? = map.remove(key)
override fun putAll(m: Map<out K, V>) = map.putAll(m)
override fun clear() = map.clear()
@@ -14,12 +14,12 @@ private object EmptyMap : Map<Any, Nothing>, Serializable {
override val size: Int get() = 0
override val isEmpty: Boolean get() = true
override fun containsKey(key: Any?): Boolean = false
override fun containsValue(value: Any?): Boolean = false
override fun get(key: Any?): Nothing? = null
override fun entrySet(): Set<Map.Entry<Any, Nothing>> = EmptySet
override fun keySet(): Set<Any> = EmptySet
override fun values(): Collection<Nothing> = EmptyList
override fun containsKey(key: Any): Boolean = false
override fun containsValue(value: Nothing): Boolean = false
override fun get(key: Any): Nothing? = null
override val entries: Set<Map.Entry<Any, Nothing>> get() = EmptySet
override val keys: Set<Any> get() = EmptySet
override val values: Collection<Nothing> get() = EmptyList
private fun readResolve(): Any = EmptyMap
}
@@ -34,6 +34,37 @@ public fun <E> MutableCollection<E>.remove(o: Any?): Boolean = remove(o as E)
@Deprecated("Use 'length' property instead", ReplaceWith("this.length"))
public fun CharSequence.length(): Int = length
@Deprecated("Use explicit cast to Map<Any?, V> instead", ReplaceWith("(this as Map<Any?, V>).get(o)"))
public inline operator fun <K, V> Map<K, V>.get(o: Any?): V? = get(o as K)
@Deprecated("Use explicit cast to Map<Any?, V> instead", ReplaceWith("(this as Map<Any?, V>).containsKey(o)"))
public inline fun <K, V> Map<K, V>.containsKey(o: Any?): Boolean = containsKey(o as K)
@Deprecated("Use explicit cast to Map<K, Any?> instead", ReplaceWith("(this as Map<K, Any?>).containsValue(o)"))
public inline fun <K, V> Map<K, V>.containsValue(o: Any?): Boolean = containsValue(o as V)
@Deprecated("Use 'keys' instead", ReplaceWith("this.keys()"))
public inline fun <K, V> Map<K, V>.keySet(): Set<K> = keys
@kotlin.jvm.JvmName("mutableKeys")
@Deprecated("Use 'keys' instead", ReplaceWith("this.keys"))
public inline fun <K, V> MutableMap<K, V>.keySet(): MutableSet<K> = keys
@Deprecated("Use 'entries' instead", ReplaceWith("this.entries"))
public inline fun <K, V> Map<K, V>.entrySet(): Set<Map.Entry<K, V>> = entries
@kotlin.jvm.JvmName("mutableEntrySet")
@Deprecated("Use 'entries' instead", ReplaceWith("this.entries"))
public inline fun <K, V> MutableMap<K, V>.entrySet(): MutableSet<MutableMap.MutableEntry<K, V>> = entries
@Deprecated("Use 'values' properties instead", ReplaceWith("this.values"))
public inline fun <K, V> Map<K, V>.values(): Collection<V> = values
@kotlin.jvm.JvmName("mutableValues")
@Deprecated("Use 'values' properties instead", ReplaceWith("this.values"))
public inline fun <K, V> MutableMap<K, V>.values(): MutableCollection<V> = values
/**
* Adds the specified [element] to this mutable collection.
*/