KtMap<K, V> class
abstract
A 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. Methods in this interface support only read-only access to the map; read-write access is supported through the KtMutableMap interface. @param K the type of map keys. The map is invariant on its key type, as it can accept key as a parameter (of containsKey for example) and return it in keys set. @param V the type of map values. The map is covariant on its value type.
- Implementers
- Available extensions
Constructors
- KtMap.empty()
-
constfactory
-
KtMap.from([Map<
K, V> map = const {}]) -
factory
Properties
-
entries
→ KtSet<
KtMapEntry< K, V> > -
Returns a read-only KtSet of all key/value pairs in this map.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
iter
→ Iterable<
KtMapEntry< K, V> > -
Access to a
Iterable
to be used in for-loopsno setter -
keys
→ KtSet<
K> -
Returns a read-only KtSet of all keys in this map.
no setter
- 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 setter
-
values
→ KtCollection<
V> -
Returns a read-only KtCollection of all values in this map. Note that this collection may contain duplicate values.
no setter
Methods
-
asMap(
) → Map< K, V> - Returns a read-only dart:core Map
-
containsKey(
K key) → bool -
Returns
true
if the map contains the specifiedkey
. -
containsValue(
V value) → bool -
Returns
true
if the map maps one or more keys to the specifiedvalue
. -
get(
K key) → V? -
Returns the value corresponding to the given
key
, ornull
if such a key is not present in the map. -
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. -
isEmpty(
) → bool -
Returns
true
if the map is empty (contains no elements),false
otherwise. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
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.