MutableMap

interface MutableMap<K, V> : Map<K, V> (source)

A map supporting association replacement, removal and clearing.

Read-only Map aliases observe the same mutations. An equal existing key is associated with the new value rather than creating a second association.

Type Parameters

K

key type.

V

value type.

See also

Inheritors

Types

Link copied to clipboard
interface MutableEntry<K, V> : Map.Entry<K, V>

A map entry whose associated value can be replaced without changing its key.

Properties

Link copied to clipboard
abstract val entries: Set<Map.Entry<K, V>>

Read-only set of this map's key-value entries.

Link copied to clipboard
abstract val keys: Set<K>

Read-only set of this map's keys.

Link copied to clipboard
abstract val size: Int

Number of key-value associations in this map.

Link copied to clipboard
abstract val values: Collection<V>

Read-only collection of this map's values, retaining duplicates from different keys.

Functions

Link copied to clipboard
abstract fun clear()

Removes all associations from this map.

Link copied to clipboard
operator fun <K, V> Map<K, V>.contains(key: K): Boolean

Checks key membership using key in map syntax.

Link copied to clipboard
abstract fun containsKey(key: K): Boolean

Checks whether an association exists for key, including one whose value is null.

Link copied to clipboard
abstract fun containsValue(value: V): Boolean

Checks whether any stored value equals value.

Link copied to clipboard
abstract operator fun get(key: K): V?

Returns the value associated with key, or null when the key is absent.

Link copied to clipboard
inline fun <K, V> MutableMap<K, V>.getOrPut(key: K, defaultValue: () -> V): V

Returns a non-null value for key, or computes and stores a default value.

Link copied to clipboard
abstract fun isEmpty(): Boolean

Checks whether this map contains no associations.

Link copied to clipboard
fun <K, V> Map<K, V>.isNotEmpty(): Boolean

Checks whether this map contains at least one association.

Link copied to clipboard
operator fun <K, V> Map<K, V>.iterator(): Iterator<Map.Entry<K, V>>

Returns an iterator over this map's entries, enabling for ((key, value) in map).

Link copied to clipboard
abstract fun put(key: K, value: V): V?

Associates key with value, replacing an existing value for an equal key.

Link copied to clipboard
abstract fun putAll(p0: Map<out K?, out V?>?)
Link copied to clipboard
operator fun <K, V> MutableMap<K, V>.set(key: K, value: V)

Associates key with value using indexed assignment, discarding the previous value.