From 824b506abe693fc4319f9cab1794c4cdb9980f63 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 27 Dec 2017 18:21:24 +0300 Subject: [PATCH] Remove inheritance between LinkedHashSet/Map and HashSet/Map --- .../common/src/kotlin/collections/HashMap.kt | 2 +- .../common/src/kotlin/collections/HashSet.kt | 2 +- .../src/kotlin/collections/LinkedHashMap.kt | 18 +++++++++++++++++- .../src/kotlin/collections/LinkedHashSet.kt | 17 ++++++++++++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/libraries/stdlib/common/src/kotlin/collections/HashMap.kt b/libraries/stdlib/common/src/kotlin/collections/HashMap.kt index fd12b3445d6..07a7149c740 100644 --- a/libraries/stdlib/common/src/kotlin/collections/HashMap.kt +++ b/libraries/stdlib/common/src/kotlin/collections/HashMap.kt @@ -16,7 +16,7 @@ package kotlin.collections -open expect class HashMap : MutableMap { +expect class HashMap : MutableMap { constructor() constructor(initialCapacity: Int) constructor(initialCapacity: Int, loadFactor: Float) diff --git a/libraries/stdlib/common/src/kotlin/collections/HashSet.kt b/libraries/stdlib/common/src/kotlin/collections/HashSet.kt index 9f572996bae..f9a34a9f208 100644 --- a/libraries/stdlib/common/src/kotlin/collections/HashSet.kt +++ b/libraries/stdlib/common/src/kotlin/collections/HashSet.kt @@ -16,7 +16,7 @@ package kotlin.collections -open expect class HashSet : MutableSet { +expect class HashSet : MutableSet { constructor() constructor(initialCapacity: Int) constructor(initialCapacity: Int, loadFactor: Float) diff --git a/libraries/stdlib/common/src/kotlin/collections/LinkedHashMap.kt b/libraries/stdlib/common/src/kotlin/collections/LinkedHashMap.kt index f466fca41fe..37312829ce1 100644 --- a/libraries/stdlib/common/src/kotlin/collections/LinkedHashMap.kt +++ b/libraries/stdlib/common/src/kotlin/collections/LinkedHashMap.kt @@ -16,9 +16,25 @@ package kotlin.collections -open expect class LinkedHashMap : HashMap { +expect class LinkedHashMap : MutableMap { constructor() constructor(initialCapacity: Int) constructor(initialCapacity: Int, loadFactor: Float) constructor(original: Map) + + // From Map + override val size: Int + override fun isEmpty(): Boolean + override fun containsKey(key: K): Boolean + override fun containsValue(value: V): Boolean + override fun get(key: K): V? + + // From MutableMap + override fun put(key: K, value: V): V? + override fun remove(key: K): V? + override fun putAll(from: Map) + override fun clear() + override val keys: MutableSet + override val values: MutableCollection + override val entries: MutableSet> } \ No newline at end of file diff --git a/libraries/stdlib/common/src/kotlin/collections/LinkedHashSet.kt b/libraries/stdlib/common/src/kotlin/collections/LinkedHashSet.kt index 341be8db208..5ba1eefcf23 100644 --- a/libraries/stdlib/common/src/kotlin/collections/LinkedHashSet.kt +++ b/libraries/stdlib/common/src/kotlin/collections/LinkedHashSet.kt @@ -16,9 +16,24 @@ package kotlin.collections -open expect class LinkedHashSet : HashSet { +expect class LinkedHashSet : MutableSet { constructor() constructor(initialCapacity: Int) constructor(initialCapacity: Int, loadFactor: Float) constructor(elements: Collection) + + // From Set + override val size: Int + override fun isEmpty(): Boolean + override fun contains(element: @UnsafeVariance E): Boolean + override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean + + // From MutableSet + override fun iterator(): MutableIterator + override fun add(element: E): Boolean + override fun remove(element: E): Boolean + override fun addAll(elements: Collection): Boolean + override fun removeAll(elements: Collection): Boolean + override fun retainAll(elements: Collection): Boolean + override fun clear() } \ No newline at end of file