Get started

PersistentMap

interface PersistentMap<K, out V> : ImmutableMap<K, V> (source)

A generic persistent collection that holds pairs of objects (keys and values) and supports efficiently retrieving the value corresponding to each key. Map keys are unique; the map holds only one value for each key.

Modification operations return new instances of the persistent map with the modification applied.

Type Parameters

K

the type of map keys. The map is invariant on its key type.

V

the type of map values. The persistent map is covariant on its value type.

Types

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

A generic builder of the persistent map. Builder exposes its modification operations through the MutableMap interface.

Functions

Link copied to clipboard
abstract fun builder(): PersistentMap.Builder<K, V>

Returns a new builder with the same contents as this map.

Link copied to clipboard
open fun cleared(): PersistentMap<K, V>

Returns an empty persistent map.

Link copied to clipboard
operator fun <K, V> PersistentMap<out K, V>.minus(key: K): PersistentMap<K, V>

Returns a new persistent map with the specified key and its corresponding value removed, or this instance if it contains no mapping for the key.

operator fun <K, V> PersistentMap<out K, V>.minus(keys: Array<out K>): PersistentMap<K, V>

Returns a new persistent map containing all entries of this map except those whose keys are contained in the specified keys array, or this instance if there are no entries to remove.

operator fun <K, V> PersistentMap<out K, V>.minus(keys: Iterable<K>): PersistentMap<K, V>

Returns a new persistent map containing all entries of this map except those whose keys are contained in the specified keys collection, or this instance if there are no entries to remove.

operator fun <K, V> PersistentMap<out K, V>.minus(keys: Sequence<K>): PersistentMap<K, V>

Returns a new persistent map containing all entries of this map except those whose keys are contained in the specified keys sequence, or this instance if there are no entries to remove.

Link copied to clipboard
inline fun <K, V> PersistentMap<out K, V>.mutate(mutator: (MutableMap<K, V>) -> Unit): PersistentMap<K, V>

Returns a new persistent map with the provided modifications applied, or this instance if no modifications were made in the result of this operation.

Link copied to clipboard
inline operator fun <K, V> PersistentMap<out K, V>.plus(pairs: Array<out Pair<K, V>>): PersistentMap<K, V>
inline operator fun <K, V> PersistentMap<out K, V>.plus(pairs: Iterable<Pair<K, V>>): PersistentMap<K, V>
inline operator fun <K, V> PersistentMap<out K, V>.plus(pairs: Sequence<Pair<K, V>>): PersistentMap<K, V>

Returns a new persistent map with entries from the specified key-value pairs added, or this instance if no modifications were made in the result of this operation.

inline operator fun <K, V> PersistentMap<out K, V>.plus(pair: Pair<K, V>): PersistentMap<K, V>

Returns a new persistent map with an entry from the specified key-value pair added, or this instance if no modifications were made in the result of this operation.

inline operator fun <K, V> PersistentMap<out K, V>.plus(map: Map<out K, V>): PersistentMap<K, V>

Returns a new persistent map with keys and values from the specified map associated, or this instance if no modifications were made in the result of this operation.

Link copied to clipboard
open fun putting(key: K, value: V): PersistentMap<K, V>

Returns a new persistent map with the specified value associated with the specified key, or this instance if no modifications were made in the result of this operation.

Link copied to clipboard
open fun puttingAll(m: Map<out K, V>): PersistentMap<K, V>

Returns a new persistent map with keys and values from the specified m map associated, or this instance if no modifications were made in the result of this operation.

Link copied to clipboard
fun <K, V> PersistentMap<out K, V>.puttingAll(pairs: Array<out Pair<K, V>>): PersistentMap<K, V>
fun <K, V> PersistentMap<out K, V>.puttingAll(pairs: Iterable<Pair<K, V>>): PersistentMap<K, V>
fun <K, V> PersistentMap<out K, V>.puttingAll(pairs: Sequence<Pair<K, V>>): PersistentMap<K, V>

Returns a new persistent map with entries from the specified key-value pairs added, or this instance if no modifications were made in the result of this operation.

fun <K, V> PersistentMap<out K, V>.puttingAll(map: Map<out K, V>): PersistentMap<K, V>

Returns a new persistent map with keys and values from the specified map associated, or this instance if no modifications were made in the result of this operation.

Link copied to clipboard
open fun removing(key: K): PersistentMap<K, V>

Returns a new persistent map with the specified key and its corresponding value removed, or this instance if it contains no mapping for the key.

open fun removing(key: K, value: V): PersistentMap<K, V>

Returns a new persistent map with the entry for the specified key and value removed, or this instance if it contains no entry with the specified key and value.