associateTo

inline fun <T, K, V, D : MutableMap<K, V>> Iterable<T>.associateTo(destination: D, transform: (T) -> Pair<K, V>, resolve: (key: K, currentValue: V, newValue: V) -> V): D

Populates the destination map with key-value pairs provided by transform function 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.

transform

function which transforms each element to key-value.

resolve

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