All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy