[stdlib] Explicit visibility and return types: Collections
This commit is contained in:
committed by
Space Team
parent
0dd61c9f81
commit
aa4419b7e3
@@ -17,7 +17,7 @@ import kotlin.js.arrayBufferIsView
|
||||
public actual inline fun <T> Array<out T>?.orEmpty(): Array<out T> = this ?: emptyArray<T>()
|
||||
|
||||
/**
|
||||
* Returns a *typed* array containing all of the elements of this collection.
|
||||
* Returns a *typed* array containing all the elements of this collection.
|
||||
*
|
||||
* Allocates an array of runtime type `T` having its size equal to the size of this collection
|
||||
* and populates the array with the elements of this collection.
|
||||
@@ -120,7 +120,7 @@ public actual fun <T> MutableList<T>.fill(value: T): Unit {
|
||||
public actual fun <T> MutableList<T>.shuffle(): Unit = shuffle(Random)
|
||||
|
||||
/**
|
||||
* Returns a new list with the elements of this list randomly shuffled.
|
||||
* Returns a new list with the elements of this collection randomly shuffled.
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
public actual fun <T> Iterable<T>.shuffled(): List<T> = toMutableList().apply { shuffle() }
|
||||
@@ -225,7 +225,7 @@ internal actual fun checkCountOverflow(count: Int): Int {
|
||||
* JS map and set implementations do not make use of capacities or load factors.
|
||||
*/
|
||||
@PublishedApi
|
||||
internal actual fun mapCapacity(expectedSize: Int) = expectedSize
|
||||
internal actual fun mapCapacity(expectedSize: Int): Int = expectedSize
|
||||
|
||||
/**
|
||||
* Checks a collection builder function capacity argument.
|
||||
|
||||
@@ -161,7 +161,7 @@ public actual open class ArrayList<E> internal constructor(private var array: Ar
|
||||
|
||||
actual override fun lastIndexOf(element: E): Int = array.lastIndexOf(element)
|
||||
|
||||
override fun toString() = arrayToString(array)
|
||||
override fun toString(): String = arrayToString(array)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T> toArray(array: Array<T>): Array<T> {
|
||||
|
||||
@@ -32,7 +32,7 @@ public actual open class HashMap<K, V> : AbstractMutableMap<K, V>, MutableMap<K,
|
||||
/**
|
||||
* Creates a new empty [HashMap].
|
||||
*/
|
||||
actual constructor() : this(InternalHashMap())
|
||||
public actual constructor() : this(InternalHashMap())
|
||||
|
||||
/**
|
||||
* Creates a new empty [HashMap] with the specified initial capacity and load factor.
|
||||
@@ -48,7 +48,7 @@ public actual open class HashMap<K, V> : AbstractMutableMap<K, V>, MutableMap<K,
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative or [loadFactor] is non-positive.
|
||||
*/
|
||||
actual constructor(initialCapacity: Int, loadFactor: Float) : this(InternalHashMap(initialCapacity, loadFactor))
|
||||
public actual constructor(initialCapacity: Int, loadFactor: Float) : this(InternalHashMap(initialCapacity, loadFactor))
|
||||
|
||||
/**
|
||||
* Creates a new empty [HashMap] with the specified initial capacity.
|
||||
@@ -62,12 +62,12 @@ public actual open class HashMap<K, V> : AbstractMutableMap<K, V>, MutableMap<K,
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative.
|
||||
*/
|
||||
actual constructor(initialCapacity: Int) : this(initialCapacity, 1.0f)
|
||||
public actual constructor(initialCapacity: Int) : this(initialCapacity, 1.0f)
|
||||
|
||||
/**
|
||||
* Creates a new [HashMap] filled with the contents of the specified [original] map.
|
||||
*/
|
||||
actual constructor(original: Map<out K, V>) : this(InternalHashMap(original))
|
||||
public actual constructor(original: Map<out K, V>) : this(InternalHashMap(original))
|
||||
|
||||
actual override fun clear() {
|
||||
internalMap.clear()
|
||||
@@ -92,7 +92,7 @@ public actual open class HashMap<K, V> : AbstractMutableMap<K, V>, MutableMap<K,
|
||||
|
||||
actual override val size: Int get() = internalMap.size
|
||||
|
||||
actual override fun putAll(from: Map<out K, V>) = internalMap.putAll(from)
|
||||
actual override fun putAll(from: Map<out K, V>): Unit = internalMap.putAll(from)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,12 +31,12 @@ public actual open class HashSet<E> : AbstractMutableSet<E>, MutableSet<E> {
|
||||
/**
|
||||
* Creates a new empty [HashSet].
|
||||
*/
|
||||
actual constructor() : this(InternalHashMap())
|
||||
public actual constructor() : this(InternalHashMap())
|
||||
|
||||
/**
|
||||
* Creates a new [HashSet] filled with the elements of the specified collection.
|
||||
*/
|
||||
actual constructor(elements: Collection<E>) : this(InternalHashMap(elements.size)) {
|
||||
public actual constructor(elements: Collection<E>) : this(InternalHashMap(elements.size)) {
|
||||
for (element in elements) {
|
||||
internalMap.put(element, true)
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public actual open class HashSet<E> : AbstractMutableSet<E>, MutableSet<E> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative or [loadFactor] is non-positive.
|
||||
*/
|
||||
actual constructor(initialCapacity: Int, loadFactor: Float) : this(InternalHashMap(initialCapacity, loadFactor))
|
||||
public actual constructor(initialCapacity: Int, loadFactor: Float) : this(InternalHashMap(initialCapacity, loadFactor))
|
||||
|
||||
/**
|
||||
* Creates a new empty [HashSet] with the specified initial capacity.
|
||||
@@ -70,7 +70,7 @@ public actual open class HashSet<E> : AbstractMutableSet<E>, MutableSet<E> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative.
|
||||
*/
|
||||
actual constructor(initialCapacity: Int) : this(initialCapacity, 1.0f)
|
||||
public actual constructor(initialCapacity: Int) : this(initialCapacity, 1.0f)
|
||||
|
||||
actual override fun add(element: E): Boolean {
|
||||
return internalMap.put(element, true) == null
|
||||
|
||||
@@ -19,7 +19,7 @@ public actual open class LinkedHashMap<K, V> : HashMap<K, V>, MutableMap<K, V> {
|
||||
/**
|
||||
* Creates a new empty [LinkedHashMap].
|
||||
*/
|
||||
actual constructor() : super()
|
||||
public actual constructor() : super()
|
||||
|
||||
/**
|
||||
* Creates a new empty [LinkedHashMap] with the specified initial capacity.
|
||||
@@ -33,7 +33,7 @@ public actual open class LinkedHashMap<K, V> : HashMap<K, V>, MutableMap<K, V> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative.
|
||||
*/
|
||||
actual constructor(initialCapacity: Int) : super(initialCapacity)
|
||||
public actual constructor(initialCapacity: Int) : super(initialCapacity)
|
||||
|
||||
/**
|
||||
* Creates a new empty [LinkedHashMap] with the specified initial capacity and load factor.
|
||||
@@ -49,14 +49,14 @@ public actual open class LinkedHashMap<K, V> : HashMap<K, V>, MutableMap<K, V> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative or [loadFactor] is non-positive.
|
||||
*/
|
||||
actual constructor(initialCapacity: Int, loadFactor: Float) : super(initialCapacity, loadFactor)
|
||||
public actual constructor(initialCapacity: Int, loadFactor: Float) : super(initialCapacity, loadFactor)
|
||||
|
||||
/**
|
||||
* Creates a new [LinkedHashMap] filled with the contents of the specified [original] map.
|
||||
*
|
||||
* The iteration order of entries in the created map is the same as in the [original] map.
|
||||
*/
|
||||
actual constructor(original: Map<out K, V>) : super(original)
|
||||
public actual constructor(original: Map<out K, V>) : super(original)
|
||||
|
||||
internal constructor(internalMap: InternalMap<K, V>) : super(internalMap)
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@ public actual open class LinkedHashSet<E> : HashSet<E>, MutableSet<E> {
|
||||
/**
|
||||
* Creates a new empty [LinkedHashSet].
|
||||
*/
|
||||
actual constructor() : super()
|
||||
public actual constructor() : super()
|
||||
|
||||
/**
|
||||
* Creates a new [LinkedHashSet] filled with the elements of the specified collection.
|
||||
*
|
||||
* The iteration order of elements in the created set is the same as in the specified collection.
|
||||
*/
|
||||
actual constructor(elements: Collection<E>) : super(elements)
|
||||
public actual constructor(elements: Collection<E>) : super(elements)
|
||||
|
||||
/**
|
||||
* Creates a new empty [LinkedHashSet] with the specified initial capacity and load factor.
|
||||
@@ -41,7 +41,7 @@ public actual open class LinkedHashSet<E> : HashSet<E>, MutableSet<E> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative or [loadFactor] is non-positive.
|
||||
*/
|
||||
actual constructor(initialCapacity: Int, loadFactor: Float) : super(initialCapacity, loadFactor)
|
||||
public actual constructor(initialCapacity: Int, loadFactor: Float) : super(initialCapacity, loadFactor)
|
||||
|
||||
/**
|
||||
* Creates a new empty [LinkedHashSet] with the specified initial capacity.
|
||||
@@ -55,7 +55,7 @@ public actual open class LinkedHashSet<E> : HashSet<E>, MutableSet<E> {
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative.
|
||||
*/
|
||||
actual constructor(initialCapacity: Int) : this(initialCapacity, 1.0f)
|
||||
public actual constructor(initialCapacity: Int) : this(initialCapacity, 1.0f)
|
||||
|
||||
internal constructor(internalMap: InternalMap<E, Boolean>) : super(internalMap)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user