Package-level declarations

Functions

Link copied to clipboard
inline fun <K, V> MutableMap<in K, V>.applyToKey(key: K, transform: (currentValue: V?) -> V): V

Applies the transformation to the value corresponding to the given key or null instead if it's not present.

Link copied to clipboard
inline fun <T, K, V> Iterable<T>.associate(transform: (T) -> Pair<K, V>, resolve: (key: K, currentValue: V, newValue: V) -> V): Map<K, V>

Returns a map containing key-value pairs provided by transform function applied to elements of the given collection.

Link copied to clipboard
inline fun <T, K> Iterable<T>.associateBy(keySelector: (T) -> K, resolve: (key: K, currentValue: T, newValue: T) -> T): Map<K, T>

Returns a map containing the elements from the given collection indexed by the key returned from keySelector function applied to each element.

inline fun <T, K, V> Iterable<T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V, resolve: (key: K, currentValue: V, newValue: V) -> V): Map<K, V>

Returns a map containing the values provided by valueTransform and indexed by keySelector functions applied to elements of the given collection.

Link copied to clipboard
inline fun <T, K, D : MutableMap<K, T>> Iterable<T>.associateByTo(destination: D, keySelector: (T) -> K, resolve: (key: K, currentValue: T, newValue: T) -> T): D

Populates the destination map with key-value pairs, where key is provided by keySelector function applied to each element of the given collection and value is the element itself, resolving conflicts with resolve function and returns the destination.

inline fun <T, K, V, D : MutableMap<K, V>> Iterable<T>.associateByTo(destination: D, keySelector: (T) -> K, valueTransform: (T) -> V, resolve: (key: K, currentValue: V, newValue: V) -> V): D

Populates the destination map with key-value pairs, where key is provided by keySelector function and value is provided by valueTransform applied to each element of the given collection, resolving conflicts with resolve function and returns the destination.

Link copied to clipboard
inline fun <T, K, V, D : MutableMap<K, V>> Iterable<T>.associateTo(destination: D, transform: (T) -> Pair<K, V>, resolve: (key: K, currentValue: V, newValue: V) -> V): D

Populates the destination map with key-value pairs provided by transform function applied to each element of the given collection resolving conflicts with resolve function and returns the destination.

Link copied to clipboard
inline fun <K, V, R> Map<in K, V>.computeOn(key: K, compute: (V?) -> R): R

Computes the given lambda compute on value corresponding to the provided key or null if the key is not present.

Link copied to clipboard
inline fun <K, V, R> Map<K, V>.computeOnOrElse(key: K, defaultResult: R, compute: (key: K, value: V) -> R): R
inline fun <K, V, R> Map<K, V>.computeOnOrElse(key: K, defaultResult: () -> R, compute: (value: V) -> R): R

Computes the given lambda compute on value corresponding to the provided key or computes the given lambda defaultResult if the key is not present.

Link copied to clipboard
inline fun <K, V, W, D : MutableMap<K, W>> Map<out K, V>.copyMapTo(destination: D, transform: (Map.Entry<K, V>) -> W): D

Transforms values of entries of this map with the given transformation and copies resulting entries to the destination map overriding present ones if needed. Is equivalent to

Link copied to clipboard
inline fun <K, V, W, D : MutableMap<K, W>> Map<out K, V>.copyMapToBy(destination: D, transform: (Map.Entry<K, V>) -> W, resolve: (key: K, currentValue: W, newValue: V) -> W): D

Transforms values of entries of this map with the given transformation and copies resulting entries to the destination map merging present entries with new ones using resolve lambda. Is equivalent to

Link copied to clipboard
fun <K, V, D : MutableMap<K, V>> Map<out K, V>.copyTo(destination: D): D

Copies entries of this map to the destination map overriding present ones if needed.

Link copied to clipboard
inline fun <K, V : W, W, D : MutableMap<K, W>> Map<out K, V>.copyToBy(destination: D, resolve: (key: K, currentValue: W, newValue: V) -> W): D

Copies entries of this map to the destination map merging present entries with new ones using resolve lambda.

Link copied to clipboard
inline fun <K, V, R> Map<out K, V>.fold(initial: R, operation: (acc: R, Map.Entry<K, V>) -> R): R

Accumulates value starting with initial value and applying operation to current accumulator value and each entry of the map.

Link copied to clipboard
inline fun <K, V, L> Map<out K, V>.mapKeys(transform: (Map.Entry<K, V>) -> L, resolve: (key: L, currentValue: V, newValue: V) -> V): Map<L, V>

Returns a new map with entries having the keys obtained by applying the transform function to each entry in this map and the values of this map and resolving conflicts with resolve function.

Link copied to clipboard
inline fun <K, V, L, D : MutableMap<L, V>> Map<out K, V>.mapKeysTo(destination: D, transform: (Map.Entry<K, V>) -> L, resolve: (key: L, currentValue: V, newValue: V) -> V): D

Populates the given destination map with entries having the keys obtained by applying the transform function to each entry in this map and the values of this map, resolving conflicts with resolve function and returns the destination.

Link copied to clipboard
inline fun <K, V, T : R, R> Map<out K, V>.mapReduce(transform: (Map.Entry<K, V>) -> T, operation: (acc: R, T) -> R): R

Lazily applies the given transform function to each entry of the map getting a new element and accumulates value starting with the first element and applying operation one-by-one to current accumulator value and each element.

Link copied to clipboard
inline fun <K, V, T : R, R> Map<out K, V>.mapReduceOrNull(transform: (Map.Entry<K, V>) -> T, operation: (acc: R, T) -> R): R?

Lazily applies the given transform function to each entry of the map getting a new element and accumulates value starting with the first element and applying operation one-by-one to current accumulator value and each element.

Link copied to clipboard
inline fun <K, V, W, D : MutableMap<K, W>> Map<out K, V>.mapValuesTo(destination: D, transform: (Map.Entry<K, V>) -> W, resolve: (key: K, currentValue: W, newValue: W) -> W): D

Populates the given destination map with entries having the keys of this map and the values obtained by applying the transform function to each entry in this map resolving conflicts with resolve function and returns the destination.

Link copied to clipboard
fun <K, V1 : W, V2 : W, W> merge(map1: Map<out K, V1>, map2: Map<out K, V2>): Map<K, W>

Merges the first map and the second map prioritising the second one.

Link copied to clipboard
inline fun <K, V1 : W, V2 : W, W> mergeBy(map1: Map<out K, V1>, map2: Map<out K, V2>, resolve: (key: K, value1: V1, value2: V2) -> W): Map<K, W>

Merges the first map and the second map resolving conflicts with resolve lambda.

Link copied to clipboard
fun <K, V, D : MutableMap<in K, in V>> mergeTo(map1: Map<out K, V>, map2: Map<out K, V>, destination: D): D

Merges the first map and the second map prioritising the second one, puts result to the destination and returns the destination.

Link copied to clipboard
inline fun <K, V1 : W, V2 : W, W, D : MutableMap<K, W>> mergeToBy(map1: Map<out K, V1>, map2: Map<out K, V2>, destination: D, resolve: (key: K, value1: V1, value2: V2) -> W): D

Merges the first map and the second map resolving conflicts with resolve lambda, puts result to the destination and returns the destination.

Link copied to clipboard
inline fun <K, V1, V2> mergingAll(map1: Map<out K, V1>, map2: Map<out K, V2>, operation1: (Map.Entry<K, V1>) -> Boolean, operation2: (Map.Entry<K, V2>) -> Boolean, operationMerge: (key: K, value1: V1, value2: V2) -> Boolean): Boolean

Returns true if:

Link copied to clipboard
inline fun <K, V1, V2> mergingAny(map1: Map<out K, V1>, map2: Map<out K, V2>, operation1: (Map.Entry<K, V1>) -> Boolean, operation2: (Map.Entry<K, V2>) -> Boolean, operationMerge: (key: K, value1: V1, value2: V2) -> Boolean): Boolean

Returns false if:

Link copied to clipboard
inline fun <K, V1, V2, R> mergingFold(map1: Map<out K, V1>, map2: Map<out K, V2>, initial: R, operation1: (acc: R, Map.Entry<K, V1>) -> R, operation2: (acc: R, Map.Entry<K, V2>) -> R, operationMerge: (acc: R, key: K, value1: V1, value2: V2) -> R): R

Accumulates value starting with initial value and applying operation1 to current accumulator value and each entry of map1 which key does not appear in map2, operation2 to current accumulator value and each entry of map2 which key does not appear in map2, and operationMerge to current accumulator value and triple of a common key of the maps and both its corresponding values in map1 and map2.

Link copied to clipboard
inline fun <K, V1, V2> mergingNone(map1: Map<out K, V1>, map2: Map<out K, V2>, operation1: (Map.Entry<K, V1>) -> Boolean, operation2: (Map.Entry<K, V2>) -> Boolean, operationMerge: (key: K, value1: V1, value2: V2) -> Boolean): Boolean

Returns true if:

Link copied to clipboard
inline fun <K, V> MutableMap<K, V>.putOrChange(key: K, valueOnPut: V, transformOnChange: (key: K, currentValue: V, newValue: V) -> V): V

Depending on presence of value corresponding to the given key either puts new value valueOnPut or changes the present value with transformOnChange.

inline fun <K, V> MutableMap<K, V>.putOrChange(key: K, valueOnPut: () -> V, transformOnChange: (currentValue: V) -> V): V

Depending on presence of value corresponding to the given key either puts new value calculated by valueOnPut or changes the present value with transformOnChange.

Link copied to clipboard
inline fun <K, V> Map<in K, V>.withAppliedToKey(key: K, transform: (currentValue: V?) -> V): Map<K, V>

Creates copy of the map and applies the transformation to the value corresponding to the given key in the copy or null instead if it's not present.

Link copied to clipboard
inline fun <K, V> Map<out K, V>.withPutOrChanged(key: K, valueOnPut: V, transformOnChange: (key: K, currentValue: V, newValue: V) -> V): Map<K, V>

Creates copy of the map and depending on presence of value corresponding to the given key either puts new value valueOnPut or changes the present value with transformOnChange.

inline fun <K, V> Map<out K, V>.withPutOrChanged(key: K, valueOnPut: () -> V, transformOnChange: (currentValue: V) -> V): Map<K, V>

Creates copy of the map and depending on presence of value corresponding to the given key either puts new value calculated by valueOnPut or changes the present value with transformOnChange.