KtMutableMap<K, V> class abstract

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
Implementers
Available extensions

Constructors

KtMutableMap.empty()
factory
KtMutableMap.from([Map<K, V> map = const {}])
factory

Properties

dart Map<K, V>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns a read-only dart:core Map
no setter
dart Map<K, V>

Available on KtMutableMap<K, V>, provided by the KtMutableMapExtensions extension

Creates a Map instance that wraps the original KtMap. It acts as a view.
no setter
entries KtMutableSet<KtMutableMapEntry<K, V>>
Returns a KtMutableSet of all key/value pairs in this map.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
iter Iterable<KtMapEntry<K, V>>
Access to a Iterable to be used in for-loops
no setterinherited
keys KtMutableSet<K>
Returns a KtMutableSet of all keys in this map.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size int
Returns the number of key/value pairs in the map.
no setterinherited
values KtMutableCollection<V>
Returns a KtMutableCollection of all values in this map. Note that this collection may contain duplicate values.
no setteroverride

Methods

all(bool predicate(K key, V value)) bool

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns true if all entries match the given predicate. predicate must not be null.
any(bool predicate(K key, V value)) bool

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns true if there is at least one entry that matches the given predicate. predicate must not be null.
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 specified key.
inherited
containsValue(V value) bool
Returns true if the map maps one or more keys to the specified value.
inherited
count([bool predicate(KtMapEntry<K, V>)?]) int

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns the number of entries matching the given predicate or the number of entries when predicate = null.
filter(bool predicate(KtMapEntry<K, V> entry)) KtMap<K, V>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns a new map containing all key-value pairs matching the given predicate.
filterKeys(bool predicate(K)) KtMap<K, V>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns a map containing all key-value pairs with keys matching the given predicate.
filterNot(bool predicate(KtMapEntry<K, V> entry)) KtMap<K, V>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns a new map containing all key-value pairs not matching the given predicate.
filterNotTo<M extends KtMutableMap>(M destination, bool predicate(KtMapEntry<K, V> entry)) → M

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Appends all entries not matching the given predicate into the given destination.
filterTo<M extends KtMutableMap>(M destination, bool predicate(KtMapEntry<K, V> entry)) → M

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Appends all entries matching the given predicate into the mutable map given as destination parameter.
filterValues(bool predicate(V)) KtMap<K, V>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns a map containing all key-value pairs with values matching the given predicate.
forEach(dynamic action(K key, V value)) → void

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Performs given action on each key/value pair from this map.
get(K key) → V?
Returns the value corresponding to the given key, or null 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, or defaultValue if such a key is not present in the map.
inherited
getOrElse(K key, V defaultValue()) → V

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns the value for the given key, or the result of the defaultValue function if there was no entry for the given key.
getOrPut(K key, V defaultValue()) → V

Available on KtMutableMap<K, V>, provided by the KtMutableMapExtensions extension

Returns the value for the given key. If the key is not found in the map, calls the defaultValue function, puts its result into the map under the given key and returns it.
getValue(K key) → V

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns the value for the given key or throws an exception if there is no such key in the map.
ifEmpty<R extends KtMap<K, V>>(R defaultValue()) → R

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns this map if it's not empty or the result of calling defaultValue function if the map is empty.
isEmpty() bool
Returns true if the map is empty (contains no elements), false otherwise.
inherited
isNotEmpty() bool

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns true if this map is not empty.
iterator() KtMutableIterator<KtMutableMapEntry<K, V>>

Available on KtMutableMap<K, V>, provided by the KtMutableMapExtensions extension

Returns an Iterator over the entries in the Map.
iterator() KtIterator<KtMapEntry<K, V>>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns an Iterator over the entries in the Map.
map<R>(R transform(KtMapEntry<K, V> entry)) KtList<R>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns a list containing the results of applying the given transform function to each entry in the original map.
mapKeys<R>(R transform(KtMapEntry<K, V>)) KtMap<R, V>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

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.
mapKeysTo<R, M extends KtMutableMap>(M destination, R transform(KtMapEntry<K, V> entry)) → M

Available on KtMap<K, V>, provided by the KtMapExtensions extension

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.
mapTo<R, M extends KtMutableCollection>(M destination, R transform(KtMapEntry<K, V> entry)) → M

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Applies the given transform function to each entry of the original map and appends the results to the given destination.
mapValues<R>(R transform(KtMapEntry<K, V>)) KtMap<K, R>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns a new map with entries having the keys of this map and the values obtained by applying the transform function to each entry in this Map.
mapValuesTo<R, M extends KtMutableMap>(M destination, R transform(KtMapEntry<K, V> entry)) → M

Available on KtMap<K, V>, provided by the KtMapExtensions extension

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.
maxBy<R extends Comparable>(R selector(KtMapEntry<K, V>)) KtMapEntry<K, V>?

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns the first entry yielding the largest value of the given function or null if there are no entries.
maxWith(Comparator<KtMapEntry<K, V>> comparator) KtMapEntry<K, V>?

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns the first entry having the largest value according to the provided comparator or null if there are no entries.
minBy<R extends Comparable>(R selector(KtMapEntry<K, V>)) KtMapEntry<K, V>?

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns the first entry yielding the smallest value of the given function or null if there are no entries.
minus(K key) KtMap<K, V>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns a map containing all entries of the original map except the entry with the given key.
minWith(Comparator<KtMapEntry<K, V>> comparator) KtMapEntry<K, V>?

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns the first entry having the smallest value according to the provided comparator or null if there are no entries.
none(bool predicate(K key, V value)) bool

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns true if there is no entries in the map that match the given predicate. predicate must not be null.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orEmpty() KtMap<K, V>

Available on KtMap<K, V>?, provided by the NullableKtMapExtensions extension

Returns the KtMap if its not null, or the empty KtMap otherwise.
plus(KtMap<K, V> map) KtMap<K, V>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Creates a new read-only map by replacing or adding entries to this map from another map.
put(K key, V value) → V?
Associates the specified value with the specified key in the map.
putAll(KtMap<K, V> from) → void
Updates this map with key/value pairs from the specified map from.
putAllPairs(KtIterable<KtPair<K, V>> pairs) → void

Available on KtMutableMap<K, V>, provided by the KtMutableMapExtensions extension

Puts all the given pairs into this KtMutableMap with the first component in the pair being the key and the second the value.
putIfAbsent(K key, V value) → V?

Available on KtMutableMap<K, V>, provided by the KtMutableMapExtensions extension

If the specified key is not already associated with a value (or is mapped to null) associates it with the given value and returns null, else returns the current value.
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.
toList() KtList<KtPair<K, V>>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns a KtList containing all key-value pairs.
toMap() KtMap<K, V>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns a new read-only map containing all key-value pairs from the original map.
toMutableMap() KtMutableMap<K, V>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns a new mutable map containing all key-value pairs from the original map.
toString() String
A string representation of this object.
inherited

Operators

operator +(KtMap<K, V> map) KtMap<K, V>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Creates a new read-only map by replacing or adding entries to this map from another map.
operator -(K key) KtMap<K, V>

Available on KtMap<K, V>, provided by the KtMapExtensions extension

Returns a map containing all entries of the original map except the entry with the given key.
operator ==(Object other) bool
The equality operator.
inherited
operator [](K key) → V?
Returns the value corresponding to the given key, or null if such a key is not present in the map.
inherited
operator []=(K key, V value) → void
Associates the specified value with the specified key in the map.