associateByTo

inline fun <T, K, V, D : MutableMap<K, V>> Iterable<T>.associateByTo(destination: D, keySelector: (T) -> K, valueTransform: (T) -> V, resolve: (key: K, currentValue: V, newValue: V) -> V): D

Populates the destination map with key-value pairs, where key is provided by keySelector function and value is provided by valueTransform applied to each element of the given collection, resolving conflicts with resolve function and returns the destination.

All pairs are added and resolved in order of iteration.

Return

the destination.

Parameters

destination

the destination of the generated key-value pairs.

keySelector

lambda functions that generates keys for the key-value pairs.

valueTransform

lambda functions that generates value for the key-value pairs.

resolve

lambda function that resolves merge conflicts which receives some key, its current, and new corresponding values.


inline fun <T, K, D : MutableMap<K, T>> Iterable<T>.associateByTo(destination: D, keySelector: (T) -> K, resolve: (key: K, currentValue: T, newValue: T) -> T): D

Populates the destination map with key-value pairs, where key is provided by keySelector function applied to each element of the given collection and value is the element itself, resolving conflicts with resolve function and returns the destination.

All pairs are added and resolved in order of iteration.

Return

the destination.

Parameters

destination

the destination of the generated key-value pairs.

keySelector

lambda functions that generates keys for the key-value pairs.

resolve

lambda function that resolves merge conflicts which receives some key, its current, and new corresponding values.