
name.remal.kotlin.collections.Map.kt Maven / Gradle / Ivy
package name.remal
import java.util.Collections.synchronizedMap
import java.util.stream.Stream
fun > M?.nullIfEmpty(): M? = nullIf(Map<*, *>::isEmpty)
fun Map.asSynchronized(): Map = synchronizedMap(this)
inline fun Map.forEachIndexed(action: (index: Int, key: K, value: V) -> Unit) {
this.entries.forEachIndexed { index, entry ->
action(index, entry.key, entry.value)
}
}
fun Map.filterNotNullKeys(): Map = filterKeys { it != null }.uncheckedCast()
fun Map.filterNotNullValues(): Map = filterValues { it != null }.uncheckedCast()
fun Map.stream(): Stream> = entries.stream()
© 2015 - 2025 Weber Informatics LLC | Privacy Policy