Package com.github.pgreze.kollections

Types

Link copied to clipboard
interface MapWithDefault<K, V> : Map<K, V>

Map specialization allowing to safely use get (and its short form the [] operator).

Link copied to clipboard
interface MutableMapWithDefault<K, V> : MapWithDefault<K, V> , MutableMap<K, V>

Mutable alternative of MapWithDefault.

Functions

Link copied to clipboard
fun <K, V> multiListWithDefaultOf(vararg entries: Pair<K, List<V>>, defaultValue: (key: K) -> List<V> = { listOf() }): MapWithDefault<K, List<V>>
Link copied to clipboard
fun <K, SK, V> multiMapWithDefaultOf(vararg entries: Pair<K, Map<SK, V>>, defaultValue: (key: K) -> Map<SK, V> = { mapOf() }): MapWithDefault<K, Map<SK, V>>
Link copied to clipboard
fun <K, V> multiSetWithDefaultOf(vararg entries: Pair<K, Set<V>>, defaultValue: (key: K) -> Set<V> = { setOf() }): MapWithDefault<K, Set<V>>
Link copied to clipboard
fun <K, V> mutableMultiListWithDefaultOf(vararg entries: Pair<K, List<V>>, defaultValue: (key: K) -> List<V> = { listOf() }): MutableMapWithDefault<K, List<V>>
Link copied to clipboard
fun <K, SK, V> mutableMultiMapWithDefaultOf(vararg entries: Pair<K, Map<SK, V>>, defaultValue: (key: K) -> Map<SK, V> = { mapOf() }): MutableMapWithDefault<K, Map<SK, V>>
Link copied to clipboard
fun <K, V> mutableMultiSetWithDefaultOf(vararg entries: Pair<K, Set<V>>, defaultValue: (key: K) -> Set<V> = { setOf() }): MutableMapWithDefault<K, Set<V>>
Link copied to clipboard
fun <K, V> Map<K, V>.setDefault(defaultValue: (key: K) -> V): MapWithDefault<K, V>

Create a new MapWithDefault from given map and for each unknown key, returns the value provided by defaultValue provider.

fun <K, V> MutableMap<K, V>.setDefault(defaultValue: (key: K) -> V): MutableMapWithDefault<K, V>

Create a new MutableMapWithDefault from given map and for each unknown key, returns the value provided by defaultValue provider.