associate

inline fun <T, K, V> Iterable<T>.associate(transform: (T) -> Pair<K, V>, resolve: (key: K, currentValue: V, newValue: V) -> V): Map<K, V>

Returns a map containing key-value pairs provided by transform function applied to elements of the given collection.

All pairs are added in order of iteration. If some key is already added to the map, adding new key-value pair with the key is resolved with resolve function which takes the key, current value corresponding to the key, and new value from the pair.

Return

the result map.

Parameters

transform

function which transforms each element to key-value pair.

resolve

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