com.jtransc.ds.MapExt.kt Maven / Gradle / Ivy
package com.jtransc.ds
inline fun MutableMap.getOrPut2(key: T1, generator: () -> T2): T2 {
if (key !in this) this[key] = generator()
return this[key]!!
}
fun Map>.combinedWith(that: Map>): Map> {
return (this.keys + that.keys).distinct()
.map { it to (this[it] ?: listOf()) + (that[it] ?: listOf()) }
.toMap()
}