Extract kotlin.collections expect classes into separate files

Add missing expect declarations for AbstractMutableMap/Set.
This commit is contained in:
Ilya Gorbunov
2017-12-22 07:15:05 +03:00
parent 93ef16deaf
commit fb13347864
10 changed files with 327 additions and 174 deletions
@@ -1,174 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.collections
open expect class ArrayList<E> : MutableList<E> {
constructor(capacity: Int)
constructor()
constructor(c: Collection<E>)
fun trimToSize()
fun ensureCapacity(minCapacity: Int)
// From List
override val size: Int
override fun isEmpty(): Boolean
override fun contains(element: @UnsafeVariance E): Boolean
override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean
override operator fun get(index: Int): E
override fun indexOf(element: @UnsafeVariance E): Int
override fun lastIndexOf(element: @UnsafeVariance E): Int
// From MutableCollection
override fun iterator(): MutableIterator<E>
// From MutableList
override fun add(element: E): Boolean
override fun remove(element: E): Boolean
override fun addAll(elements: Collection<E>): Boolean
override fun addAll(index: Int, elements: Collection<E>): Boolean
override fun removeAll(elements: Collection<E>): Boolean
override fun retainAll(elements: Collection<E>): Boolean
override fun clear()
override operator fun set(index: Int, element: E): E
override fun add(index: Int, element: E)
override fun removeAt(index: Int): E
override fun listIterator(): MutableListIterator<E>
override fun listIterator(index: Int): MutableListIterator<E>
override fun subList(fromIndex: Int, toIndex: Int): MutableList<E>
}
open expect class HashMap<K, V> : MutableMap<K, V> {
constructor()
constructor(initialCapacity: Int)
constructor(initialCapacity: Int, loadFactor: Float)
constructor(original: Map<out K, V>)
// From Map
override val size: Int
override fun isEmpty(): Boolean
override fun containsKey(key: K): Boolean
override fun containsValue(value: @UnsafeVariance V): Boolean
override operator 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<out K, V>)
override fun clear()
override val keys: MutableSet<K>
override val values: MutableCollection<V>
override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
}
open expect class LinkedHashMap<K, V> : HashMap<K, V> {
constructor()
constructor(initialCapacity: Int)
constructor(initialCapacity: Int, loadFactor: Float)
constructor(original: Map<out K, V>)
}
open expect class HashSet<E> : MutableSet<E> {
constructor()
constructor(initialCapacity: Int)
constructor(initialCapacity: Int, loadFactor: Float)
constructor(c: Collection<E>)
// 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<E>
override fun add(element: E): Boolean
override fun remove(element: E): Boolean
override fun addAll(elements: Collection<E>): Boolean
override fun removeAll(elements: Collection<E>): Boolean
override fun retainAll(elements: Collection<E>): Boolean
override fun clear()
}
open expect class LinkedHashSet<E> : HashSet<E> {
constructor()
constructor(initialCapacity: Int)
constructor(initialCapacity: Int, loadFactor: Float)
constructor(c: Collection<E>)
}
expect interface RandomAccess
expect abstract class AbstractMutableList<E> : MutableList<E> {
protected constructor()
// From List
override fun isEmpty(): Boolean
override fun contains(element: @UnsafeVariance E): Boolean
override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean
override fun indexOf(element: @UnsafeVariance E): Int
override fun lastIndexOf(element: @UnsafeVariance E): Int
// From MutableCollection
override fun iterator(): MutableIterator<E>
// From MutableList
override fun add(element: E): Boolean
override fun remove(element: E): Boolean
override fun addAll(elements: Collection<E>): Boolean
override fun addAll(index: Int, elements: Collection<E>): Boolean
override fun removeAll(elements: Collection<E>): Boolean
override fun retainAll(elements: Collection<E>): Boolean
override fun clear()
override fun listIterator(): MutableListIterator<E>
override fun listIterator(index: Int): MutableListIterator<E>
override fun subList(fromIndex: Int, toIndex: Int): MutableList<E>
}
// From collections.kt
/** Returns the array if it's not `null`, or an empty array otherwise. */
expect inline fun <reified T> Array<out T>?.orEmpty(): Array<out T>
expect inline fun <reified T> Collection<T>.toTypedArray(): Array<T>
@SinceKotlin("1.2")
expect fun <T> MutableList<T>.fill(value: T): Unit
@SinceKotlin("1.2")
expect fun <T> MutableList<T>.shuffle(): Unit
@SinceKotlin("1.2")
expect fun <T> Iterable<T>.shuffled(): List<T>
expect fun <T : Comparable<T>> MutableList<T>.sort(): Unit
expect fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit
// from Grouping.kt
public expect fun <T, K> Grouping<T, K>.eachCount(): Map<K, Int>
// public expect inline fun <T, K> Grouping<T, K>.eachSumOf(valueSelector: (T) -> Int): Map<K, Int>
internal expect fun copyToArrayImpl(collection: Collection<*>): Array<Any?>
internal expect fun <T> copyToArrayImpl(collection: Collection<*>, array: Array<T>): Array<T>
internal expect fun <T> arrayOfNulls(reference: Array<T>, size: Int): Array<T>
internal expect fun <K, V> Map<K, V>.toSingletonMapOrSelf(): Map<K, V>
internal expect fun <K, V> Map<out K, V>.toSingletonMap(): Map<K, V>
internal expect fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<out Any?>
@@ -0,0 +1,43 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.collections
expect abstract class AbstractMutableList<E> : MutableList<E> {
protected constructor()
// From List
override fun isEmpty(): Boolean
override fun contains(element: @UnsafeVariance E): Boolean
override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean
override fun indexOf(element: @UnsafeVariance E): Int
override fun lastIndexOf(element: @UnsafeVariance E): Int
// From MutableCollection
override fun iterator(): MutableIterator<E>
// From MutableList
override fun add(element: E): Boolean
override fun remove(element: E): Boolean
override fun addAll(elements: Collection<E>): Boolean
override fun addAll(index: Int, elements: Collection<E>): Boolean
override fun removeAll(elements: Collection<E>): Boolean
override fun retainAll(elements: Collection<E>): Boolean
override fun clear()
override fun listIterator(): MutableListIterator<E>
override fun listIterator(index: Int): MutableListIterator<E>
override fun subList(fromIndex: Int, toIndex: Int): MutableList<E>
}
@@ -0,0 +1,32 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.collections
expect abstract class AbstractMutableMap<K, V> : MutableMap<K, V> {
protected constructor()
/**
* Associates the specified [value] with the specified [key] in the map.
*
* This method is redeclared as abstract, because it's not implemented in the base class,
* so it must be always overridden in the concrete mutable collection implementation.
*
* @return the previous value associated with the key, or `null` if the key was not present in the map.
*/
abstract override fun put(key: K, value: V): V?
}
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.collections
expect abstract class AbstractMutableSet<E> : MutableSet<E> {
protected constructor()
abstract override fun add(element: E): Boolean
}
@@ -0,0 +1,53 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.collections
expect open class ArrayList<E> : MutableList<E> {
constructor()
constructor(initialCapacity: Int)
constructor(elements: Collection<E>)
fun trimToSize()
fun ensureCapacity(minCapacity: Int)
// From List
override val size: Int
override fun isEmpty(): Boolean
override fun contains(element: @UnsafeVariance E): Boolean
override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean
override operator fun get(index: Int): E
override fun indexOf(element: @UnsafeVariance E): Int
override fun lastIndexOf(element: @UnsafeVariance E): Int
// From MutableCollection
override fun iterator(): MutableIterator<E>
// From MutableList
override fun add(element: E): Boolean
override fun remove(element: E): Boolean
override fun addAll(elements: Collection<E>): Boolean
override fun addAll(index: Int, elements: Collection<E>): Boolean
override fun removeAll(elements: Collection<E>): Boolean
override fun retainAll(elements: Collection<E>): Boolean
override fun clear()
override operator fun set(index: Int, element: E): E
override fun add(index: Int, element: E)
override fun removeAt(index: Int): E
override fun listIterator(): MutableListIterator<E>
override fun listIterator(index: Int): MutableListIterator<E>
override fun subList(fromIndex: Int, toIndex: Int): MutableList<E>
}
@@ -0,0 +1,49 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.collections
expect interface RandomAccess
/** Returns the array if it's not `null`, or an empty array otherwise. */
expect inline fun <reified T> Array<out T>?.orEmpty(): Array<out T>
expect inline fun <reified T> Collection<T>.toTypedArray(): Array<T>
@SinceKotlin("1.2")
expect fun <T> MutableList<T>.fill(value: T): Unit
@SinceKotlin("1.2")
expect fun <T> MutableList<T>.shuffle(): Unit
@SinceKotlin("1.2")
expect fun <T> Iterable<T>.shuffled(): List<T>
expect fun <T : Comparable<T>> MutableList<T>.sort(): Unit
expect fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit
// from Grouping.kt
public expect fun <T, K> Grouping<T, K>.eachCount(): Map<K, Int>
// public expect inline fun <T, K> Grouping<T, K>.eachSumOf(valueSelector: (T) -> Int): Map<K, Int>
internal expect fun copyToArrayImpl(collection: Collection<*>): Array<Any?>
internal expect fun <T> copyToArrayImpl(collection: Collection<*>, array: Array<T>): Array<T>
internal expect fun <T> arrayOfNulls(reference: Array<T>, size: Int): Array<T>
internal expect fun <K, V> Map<K, V>.toSingletonMapOrSelf(): Map<K, V>
internal expect fun <K, V> Map<out K, V>.toSingletonMap(): Map<K, V>
internal expect fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<out Any?>
@@ -0,0 +1,40 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.collections
open expect class HashMap<K, V> : MutableMap<K, V> {
constructor()
constructor(initialCapacity: Int)
constructor(initialCapacity: Int, loadFactor: Float)
constructor(original: Map<out K, V>)
// From Map
override val size: Int
override fun isEmpty(): Boolean
override fun containsKey(key: K): Boolean
override fun containsValue(value: @UnsafeVariance V): Boolean
override operator 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<out K, V>)
override fun clear()
override val keys: MutableSet<K>
override val values: MutableCollection<V>
override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
}
@@ -0,0 +1,39 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.collections
open expect class HashSet<E> : MutableSet<E> {
constructor()
constructor(initialCapacity: Int)
constructor(initialCapacity: Int, loadFactor: Float)
constructor(elements: Collection<E>)
// 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<E>
override fun add(element: E): Boolean
override fun remove(element: E): Boolean
override fun addAll(elements: Collection<E>): Boolean
override fun removeAll(elements: Collection<E>): Boolean
override fun retainAll(elements: Collection<E>): Boolean
override fun clear()
}
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.collections
open expect class LinkedHashMap<K, V> : HashMap<K, V> {
constructor()
constructor(initialCapacity: Int)
constructor(initialCapacity: Int, loadFactor: Float)
constructor(original: Map<out K, V>)
}
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.collections
open expect class LinkedHashSet<E> : HashSet<E> {
constructor()
constructor(initialCapacity: Int)
constructor(initialCapacity: Int, loadFactor: Float)
constructor(elements: Collection<E>)
}