computeIfPresent

fun computeIfPresent(key: K, remappingFunction: (K, V) -> V?): V?

If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and its current mapped value. If the function returns null, the mapping is removed.

Throws

if the remapping function modifies this map