KtMutableMap<K, V> class
Null safety
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. @param K the type of map keys. The map is invariant on its key type. @param V the type of map values. The mutable map is invariant on its value type.
- Implemented types
-
- KtMap<
K, V>
- KtMap<
- Implementers
- Available Extensions
Constructors
- KtMutableMap.empty()
-
factory
-
KtMutableMap.from([Map<
K, V> map = const {}]) -
factory
Properties
-
entries
→ KtMutableSet<
KtMutableMapEntry< K, V> > -
Returns a KtMutableSet of all key/value pairs in this map.
read-only, override
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
-
iter
→ Iterable<
KtMapEntry< K, V> > -
Access to a
Iterable
to be used in for-loopsread-only, inherited -
keys
→ KtMutableSet<
K> -
Returns a KtMutableSet of all keys in this map.
read-only, override
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
- size → int
-
Returns the number of key/value pairs in the map.
read-only, inherited
-
values
→ KtMutableCollection<
V> -
Returns a KtMutableCollection of all values in this map. Note that this collection may contain duplicate values.
read-only, override
Methods
-
asMap(
) → Map< K, V> -
Creates a Map instance that wraps the original KtMap. It acts as a view. [...]
override
-
clear(
) → void - Removes all elements from this map.
-
containsKey(
K key) → bool -
Returns
true
if the map contains the specifiedkey
.inherited -
containsValue(
V value) → bool -
Returns
true
if the map maps one or more keys to the specifiedvalue
.inherited -
get(
K key) → V? -
Returns the value corresponding to the given
key
, ornull
if such a key is not present in the map.inherited -
getOrDefault(
K key, V defaultValue) → V? -
Returns the value corresponding to the given
key
, ordefaultValue
if such a key is not present in the map.inherited -
isEmpty(
) → bool -
Returns
true
if the map is empty (contains no elements),false
otherwise.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
put(
K key, V value) → V? -
Associates the specified
value
with the specifiedkey
in the map. [...] -
putAll(
KtMap< K, V> from) → void -
Updates this map with key/value pairs from the specified map
from
. -
remove(
K key) → V? - Removes the specified key and its corresponding value from this map. [...]
-
removeMapping(
K key, V value) → bool - Removes the entry for the specified key only if it is mapped to the specified value. [...]
-
toString(
) → String -
A string representation of this object. [...]
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator. [...]
inherited
-
operator [](
K key) → V? -
Returns the value corresponding to the given
key
, ornull
if such a key is not present in the map.inherited -
operator []=(
K key, V value) → void -
Associates the specified
value
with the specifiedkey
in the map.