MutableMap

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

A modifiable 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.

Since Kotlin

1.0

Parameters

K

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

V

the type of map values. The mutable map is invariant in its value type.

Types

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

Represents a key/value pair held by a MutableMap.

Since Kotlin 1.0

Functions

Link copied to clipboard
abstract fun clear()

Removes all elements from this map.

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

Returns true if the map contains the specified key.

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

Returns true if the map maps one or more keys to the specified value.

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

Returns the value corresponding to the given key, or null if such a key is not present in the map.

Since Kotlin 1.0
Link copied to clipboard
abstract fun isEmpty(): Boolean

Returns true if the map is empty (contains no elements), false otherwise.

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

Associates the specified value with the specified key in the map.

Since Kotlin 1.0
Link copied to clipboard
abstract fun putAll(from: Map<out K, V>)

Updates this map with key/value pairs from the specified map from.

Since Kotlin 1.0
Link copied to clipboard
abstract fun remove(key: K): V?

Removes the specified key and its corresponding value from this map.

Since Kotlin 1.0

Properties

Link copied to clipboard
abstract override val entries: MutableSet<MutableMap.MutableEntry<K, V>>

Returns a MutableSet of all key/value pairs in this map.

Since Kotlin 1.0
Link copied to clipboard
abstract override val keys: MutableSet<K>

Returns a MutableSet of all keys in this map.

Since Kotlin 1.0
Link copied to clipboard
abstract val size: Int

Returns the number of key/value pairs in the map.

Since Kotlin 1.0
Link copied to clipboard
abstract override val values: MutableCollection<V>

Returns a MutableCollection of all values in this map. Note that this collection may contain duplicate values.

Since Kotlin 1.0

Extensions

Link copied to clipboard
inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>?
Since Kotlin 1.0
Link copied to clipboard
inline fun <K, V> Map<out K, V>.maxWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>?
Since Kotlin 1.0
Link copied to clipboard
inline fun <K, V, R : Comparable<R>> Map<out K, V>.minBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>?
Since Kotlin 1.0
Link copied to clipboard
fun <K, V> Map<out K, V>.minWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>?
Since Kotlin 1.0
Link copied to clipboard

Converts this Map to a Properties object.

Since Kotlin 1.0
Link copied to clipboard
fun <K : Comparable<K>, V> Map<out K, V>.toSortedMap(): SortedMap<K, V>

Converts this Map to a SortedMap. The resulting SortedMap determines the equality and order of keys according to their natural sorting order.

Since Kotlin 1.0
fun <K, V> Map<out K, V>.toSortedMap(comparator: Comparator<in K>): SortedMap<K, V>

Converts this Map to a SortedMap. The resulting SortedMap determines the equality and order of keys according to the sorting order provided by the given comparator.

Since Kotlin 1.0