Align behavoir of collection constructors across platforms #KT-59192
The initialCapacity should be non-negative and loadFactor should be positive. As a part of efforts to stabilize Native stdlib.
This commit is contained in:
committed by
Space Team
parent
0bef1533e2
commit
830c78773c
@@ -77,7 +77,9 @@ actual class HashMap<K, V> private constructor(
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative or [loadFactor] is non-positive.
|
||||
*/
|
||||
actual constructor(initialCapacity: Int, loadFactor: Float) : this(initialCapacity)
|
||||
actual constructor(initialCapacity: Int, loadFactor: Float) : this(initialCapacity) {
|
||||
require(loadFactor > 0) { "Non-positive load factor: $loadFactor" }
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
internal fun build(): Map<K, V> {
|
||||
|
||||
@@ -52,7 +52,7 @@ actual class HashSet<E> internal constructor(
|
||||
*
|
||||
* @throws IllegalArgumentException if [initialCapacity] is negative or [loadFactor] is non-positive.
|
||||
*/
|
||||
actual constructor(initialCapacity: Int, loadFactor: Float) : this(initialCapacity)
|
||||
actual constructor(initialCapacity: Int, loadFactor: Float) : this(HashMap<E, Nothing>(initialCapacity, loadFactor))
|
||||
|
||||
@PublishedApi
|
||||
internal fun build(): Set<E> {
|
||||
|
||||
Reference in New Issue
Block a user