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

name.remal.kotlin.collections.Map.kt Maven / Gradle / Ivy

There is a newer version: 1.26.147
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy