Add documentation on how merging works for toMap() for Iterables, Arrays and Sequences
This commit is contained in:
@@ -488,6 +488,7 @@ public inline fun <K, V> Map<out K, V>.filterNot(predicate: (Map.Entry<K, V>) ->
|
|||||||
* Returns a new map containing all key-value pairs from the given collection of pairs.
|
* Returns a new map containing all key-value pairs from the given collection of pairs.
|
||||||
*
|
*
|
||||||
* The returned map preserves the entry iteration order of the original collection.
|
* The returned map preserves the entry iteration order of the original collection.
|
||||||
|
* Duplicate keys are ignored except for the last one.
|
||||||
*/
|
*/
|
||||||
public fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> {
|
public fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> {
|
||||||
if (this is Collection) {
|
if (this is Collection) {
|
||||||
@@ -510,6 +511,7 @@ public fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(destina
|
|||||||
* Returns a new map containing all key-value pairs from the given array of pairs.
|
* Returns a new map containing all key-value pairs from the given array of pairs.
|
||||||
*
|
*
|
||||||
* The returned map preserves the entry iteration order of the original array.
|
* The returned map preserves the entry iteration order of the original array.
|
||||||
|
* Duplicate keys are ignored except for the last one.
|
||||||
*/
|
*/
|
||||||
public fun <K, V> Array<out Pair<K, V>>.toMap(): Map<K, V> = when (size) {
|
public fun <K, V> Array<out Pair<K, V>>.toMap(): Map<K, V> = when (size) {
|
||||||
0 -> emptyMap()
|
0 -> emptyMap()
|
||||||
@@ -527,6 +529,7 @@ public fun <K, V, M : MutableMap<in K, in V>> Array<out Pair<K, V>>.toMap(destin
|
|||||||
* Returns a new map containing all key-value pairs from the given sequence of pairs.
|
* Returns a new map containing all key-value pairs from the given sequence of pairs.
|
||||||
*
|
*
|
||||||
* The returned map preserves the entry iteration order of the original sequence.
|
* The returned map preserves the entry iteration order of the original sequence.
|
||||||
|
* Duplicate keys are ignored except for the last one.
|
||||||
*/
|
*/
|
||||||
public fun <K, V> Sequence<Pair<K, V>>.toMap(): Map<K, V> = toMap(LinkedHashMap<K, V>()).optimizeReadOnlyMap()
|
public fun <K, V> Sequence<Pair<K, V>>.toMap(): Map<K, V> = toMap(LinkedHashMap<K, V>()).optimizeReadOnlyMap()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user