copyMapToBy

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

Transforms values of entries of this map with the given transformation and copies resulting entries to the destination map merging present entries with new ones using resolve lambda. Is equivalent to

this.mapValues(transform).copyToBy(destination, resolve)

Receiver

map to be transformed and copied.

Return

the destination.

Parameters

destination

map to receive copies.

transform

generates value of transformed entry using initial entry as an argument. Key of transformed entry is the same as initial entry.

resolve

lambda function that resolves overriding. It takes a key, current value corresponding to the key, and a new one and returns value to associate to the key.