mapValuesTo

inline fun <K, V, W, D : MutableMap<K, W>> Map<out K, V>.mapValuesTo(destination: D, transform: (Map.Entry<K, V>) -> W, resolve: (key: K, currentValue: W, newValue: W) -> W): D

Populates the given destination map with entries having the keys of this map and the values obtained by applying the transform function to each entry in this map 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 key-value pair to new value.

resolve

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