Merge stored empty lists and sets to singe object
This commit is contained in:
@@ -20,6 +20,7 @@ import java.util.LinkedHashMap
|
||||
import java.util.ArrayList
|
||||
import java.util.HashMap
|
||||
import java.util.HashSet
|
||||
import java.util.Collections
|
||||
|
||||
public fun <K, V> Stream<V>.valuesToMap(key: (V) -> K): Map<K, V> {
|
||||
val map = LinkedHashMap<K, V>()
|
||||
@@ -94,3 +95,9 @@ public fun <K, V> newHashMapWithExpectedSize(expectedSize: Int): HashMap<K, V> {
|
||||
public fun <E> newHashSetWithExpectedSize(expectedSize: Int): HashSet<E> {
|
||||
return HashSet(if (expectedSize < 3) 3 else expectedSize + expectedSize / 3 + 1)
|
||||
}
|
||||
|
||||
public fun <T> Collection<T>.toReadOnlyList(): List<T> =
|
||||
if (isEmpty()) Collections.emptyList() else ArrayList(this)
|
||||
|
||||
public fun <T> Collection<T>.toReadOnlySet(): Set<T> =
|
||||
if (isEmpty()) Collections.emptySet() else HashSet(this)
|
||||
Reference in New Issue
Block a user