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
-
dart
→ Map<
K, V> -
Available on KtMap<
Returns a read-only dart:core MapK, V> , provided by the KtMapExtensions extensionno setter -
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
-
all(
bool predicate(K key, V value)) → bool -
Available on KtMap<
Returns true if all entries match the givenK, V> , provided by the KtMapExtensions extensionpredicate
.predicate
must not be null. -
any(
bool predicate(K key, V value)) → bool -
Available on KtMap<
Returns true if there is at least one entry that matches the givenK, V> , provided by the KtMapExtensions extensionpredicate
.predicate
must not be null. -
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
. -
count(
[bool predicate(KtMapEntry< K, V> )?]) → int -
Available on KtMap<
Returns the number of entries matching the givenK, V> , provided by the KtMapExtensions extensionpredicate
or the number of entries whenpredicate = null
. -
filter(
bool predicate(KtMapEntry< K, V> entry)) → KtMap<K, V> -
Available on KtMap<
Returns a new map containing all key-value pairs matching the givenK, V> , provided by the KtMapExtensions extensionpredicate
. -
filterKeys(
bool predicate(K)) → KtMap< K, V> -
Available on KtMap<
Returns a map containing all key-value pairs with keys matching the givenK, V> , provided by the KtMapExtensions extensionpredicate
. -
filterNot(
bool predicate(KtMapEntry< K, V> entry)) → KtMap<K, V> -
Available on KtMap<
Returns a new map containing all key-value pairs not matching the givenK, V> , provided by the KtMapExtensions extensionpredicate
. -
filterNotTo<
M extends KtMutableMap> (M destination, bool predicate(KtMapEntry< K, V> entry)) → M -
Available on KtMap<
Appends all entries not matching the givenK, V> , provided by the KtMapExtensions extensionpredicate
into the givendestination
. -
filterTo<
M extends KtMutableMap> (M destination, bool predicate(KtMapEntry< K, V> entry)) → M -
Available on KtMap<
Appends all entries matching the givenK, V> , provided by the KtMapExtensions extensionpredicate
into the mutable map given asdestination
parameter. -
filterValues(
bool predicate(V)) → KtMap< K, V> -
Available on KtMap<
Returns a map containing all key-value pairs with values matching the givenK, V> , provided by the KtMapExtensions extensionpredicate
. -
forEach(
dynamic action(K key, V value)) → void -
Available on KtMap<
Performs givenK, V> , provided by the KtMapExtensions extensionaction
on each key/value pair from this map. -
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. -
getOrElse(
K key, V defaultValue()) → V -
Available on KtMap<
Returns the value for the given key, or the result of theK, V> , provided by the KtMapExtensions extensiondefaultValue
function if there was no entry for the given key. -
getValue(
K key) → V -
Available on KtMap<
Returns the value for the givenK, V> , provided by the KtMapExtensions extensionkey
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<
Returns this map if it's not empty or the result of callingK, V> , provided by the KtMapExtensions extensiondefaultValue
function if the map is empty. -
isEmpty(
) → bool -
Returns
true
if the map is empty (contains no elements),false
otherwise. -
isNotEmpty(
) → bool -
Available on KtMap<
ReturnsK, V> , provided by the KtMapExtensions extensiontrue
if this map is not empty. -
iterator(
) → KtIterator< KtMapEntry< K, V> > -
Available on KtMap<
Returns an Iterator over the entries in the Map.K, V> , provided by the KtMapExtensions extension -
map<
R> (R transform(KtMapEntry< K, V> entry)) → KtList<R> -
Available on KtMap<
Returns a list containing the results of applying the givenK, V> , provided by the KtMapExtensions extensiontransform
function to each entry in the original map. -
mapKeys<
R> (R transform(KtMapEntry< K, V> )) → KtMap<R, V> -
Available on KtMap<
Returns a new Map with entries having the keys obtained by applying theK, V> , provided by the KtMapExtensions extensiontransform
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<
Populates the givenK, V> , provided by the KtMapExtensions extensiondestination
map with entries having the keys obtained by applying thetransform
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<
Applies the givenK, V> , provided by the KtMapExtensions extensiontransform
function to each entry of the original map and appends the results to the givendestination
. -
mapValues<
R> (R transform(KtMapEntry< K, V> )) → KtMap<K, R> -
Available on KtMap<
Returns a new map with entries having the keys of this map and the values obtained by applying theK, V> , provided by the KtMapExtensions extensiontransform
function to each entry in this Map. -
mapValuesTo<
R, M extends KtMutableMap> (M destination, R transform(KtMapEntry< K, V> entry)) → M -
Available on KtMap<
Populates the givenK, V> , provided by the KtMapExtensions extensiondestination
map with entries having the keys of this map and the values obtained by applying thetransform
function to each entry in this Map. -
maxBy<
R extends Comparable> (R selector(KtMapEntry< K, V> )) → KtMapEntry<K, V> ? -
Available on KtMap<
Returns the first entry yielding the largest value of the given function orK, V> , provided by the KtMapExtensions extensionnull
if there are no entries. -
maxWith(
Comparator< KtMapEntry< comparator) → KtMapEntry<K, V> >K, V> ? -
Available on KtMap<
Returns the first entry having the largest value according to the providedK, V> , provided by the KtMapExtensions extensioncomparator
ornull
if there are no entries. -
minBy<
R extends Comparable> (R selector(KtMapEntry< K, V> )) → KtMapEntry<K, V> ? -
Available on KtMap<
Returns the first entry yielding the smallest value of the given function orK, V> , provided by the KtMapExtensions extensionnull
if there are no entries. -
minus(
K key) → KtMap< K, V> -
Available on KtMap<
Returns a map containing all entries of the original map except the entry with the givenK, V> , provided by the KtMapExtensions extensionkey
. -
minWith(
Comparator< KtMapEntry< comparator) → KtMapEntry<K, V> >K, V> ? -
Available on KtMap<
Returns the first entry having the smallest value according to the providedK, V> , provided by the KtMapExtensions extensioncomparator
ornull
if there are no entries. -
none(
bool predicate(K key, V value)) → bool -
Available on KtMap<
ReturnsK, V> , provided by the KtMapExtensions extensiontrue
if there is no entries in the map that match the givenpredicate
.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<
Returns the KtMap if its notK, V> ?, provided by the NullableKtMapExtensions extensionnull
, or the empty KtMap otherwise. -
plus(
KtMap< K, V> map) → KtMap<K, V> -
Available on KtMap<
Creates a new read-only map by replacing or adding entries to this map from anotherK, V> , provided by the KtMapExtensions extensionmap
. -
toList(
) → KtList< KtPair< K, V> > -
Available on KtMap<
Returns a KtList containing all key-value pairs.K, V> , provided by the KtMapExtensions extension -
toMap(
) → KtMap< K, V> -
Available on KtMap<
Returns a new read-only map containing all key-value pairs from the original map.K, V> , provided by the KtMapExtensions extension -
toMutableMap(
) → KtMutableMap< K, V> -
Available on KtMap<
Returns a new mutable map containing all key-value pairs from the original map.K, V> , provided by the KtMapExtensions extension -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator +(
KtMap< K, V> map) → KtMap<K, V> -
Available on KtMap<
Creates a new read-only map by replacing or adding entries to this map from anotherK, V> , provided by the KtMapExtensions extensionmap
. -
operator -(
K key) → KtMap< K, V> -
Available on KtMap<
Returns a map containing all entries of the original map except the entry with the givenK, V> , provided by the KtMapExtensions extensionkey
. -
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.