com.jtransc.lang.MapExt.kt Maven / Gradle / Ivy
package com.jtransc.lang
import java.util.*
fun HashMap.putIfAbsentJre7(key: K, value: V): V? = if (!containsKey(key)) put(key, value) else get(key)
fun Map>.mergeMapListWith(other: Map>): Map> {
val first = this
val second = other
return (this.keys + other.keys).distinct().map {
it to ((first[it] ?: listOf()) + (second[it] ?: listOf()))
}.toMap()
}