MapExtensions<K, V> extension

Extensions for Map operations and utilities.

on

Properties

firstEntry MapEntry<K, V>?

Available on Map<K, V>, provided by the MapExtensions extension

Returns the first key-value pair, or null if the map is empty.
no setter
isNotEmpty bool

Available on Map<K, V>, provided by the MapExtensions extension

Returns true if the map is not empty.
no setter
lastEntry MapEntry<K, V>?

Available on Map<K, V>, provided by the MapExtensions extension

Returns the last key-value pair, or null if the map is empty.
no setter

Methods

all(bool test(K, V)) bool

Available on Map<K, V>, provided by the MapExtensions extension

Returns true if all entries match the predicate.
any(bool test(K, V)) bool

Available on Map<K, V>, provided by the MapExtensions extension

Returns true if the map contains any entry matching the predicate.
filter(bool test(K, V)) Map<K, V>

Available on Map<K, V>, provided by the MapExtensions extension

Filters the map by a predicate.
getOrDefault(K key, V defaultValue) → V

Available on Map<K, V>, provided by the MapExtensions extension

Returns the value for the key or a default value.
getOrNull(K key) → V?

Available on Map<K, V>, provided by the MapExtensions extension

Returns the value for the key or null if not found.
getOrPut(K key, V defaultValue()) → V

Available on Map<K, V>, provided by the MapExtensions extension

Returns the value for the key or computes it if not found.
invert() Map<V, K>

Available on Map<K, V>, provided by the MapExtensions extension

Inverts the map, swapping keys and values.
keysWhere(bool test(K, V)) List<K>

Available on Map<K, V>, provided by the MapExtensions extension

Returns a list of keys that match the predicate.
mapEntries<K2, V2>(MapEntry<K2, V2> transform(K key, V value)) Map<K2, V2>

Available on Map<K, V>, provided by the MapExtensions extension

Maps the map to a new map with transformed keys and values.
mapKeys<K2>(K2 mapper(K)) Map<K2, V>

Available on Map<K, V>, provided by the MapExtensions extension

Returns a new map with keys transformed by the mapper function.
mapValues<V2>(V2 mapper(V)) Map<K, V2>

Available on Map<K, V>, provided by the MapExtensions extension

Returns a new map with values transformed by the mapper function.
merge(Map<K, V> other) Map<K, V>

Available on Map<K, V>, provided by the MapExtensions extension

Merges this map with another map.
mergeWith(Map<K, V> other, V mergeFunction(V, V)) Map<K, V>

Available on Map<K, V>, provided by the MapExtensions extension

Merges this map with another map using a merge function for conflicts.
removeWhere(bool test(K, V)) → void

Available on Map<K, V>, provided by the MapExtensions extension

Removes entries that match the predicate.
sortedByKey([int compare(K, K)?]) Map<K, V>

Available on Map<K, V>, provided by the MapExtensions extension

Returns a new map sorted by keys.
sortedByValue([int compare(V, V)?]) Map<K, V>

Available on Map<K, V>, provided by the MapExtensions extension

Returns a new map sorted by values.
valuesWhere(bool test(K, V)) List<V>

Available on Map<K, V>, provided by the MapExtensions extension

Returns a list of values that match the predicate.