Dart API Referencedart:coreMap<K, V>

Map<K, V> Interface

A Map is an associative container, mapping a key to a value. Null values are supported.

Default class

HashMapImplementation<K, V>

Subinterfaces

AttributeMap, HashMap<K, V>, Storage

Implemented by

ConstantMap<V>, SplayTreeMap<K, V>

Constructors

Code new Map() #

Creates a map with the default implementation.

Map();

Code new Map.from(Map<K, V> other) #

Creates a Map that contains all key value pairs of other.

Map.from(Map<K, V> other);

Methods

Code void clear() #

Removes all pairs from the map.

void clear();

Code bool containsKey(K key) #

Returns whether this map contains the given key.

bool containsKey(K key);

Code bool containsValue(V value) #

Returns whether this map contains the given value.

bool containsValue(V value);

Code void forEach(void f(K key, V value)) #

Applies f to each {key, value} pair of the map.

void forEach(void f(K key, V value));

Code Collection<K> getKeys() #

Returns a collection containing all the keys in the map.

Collection<K> getKeys();

Code Collection<V> getValues() #

Returns a collection containing all the values in the map.

Collection<V> getValues();

Code bool isEmpty() #

Returns true if there is no {key, value} pair in the map.

bool isEmpty();

Code int get length() #

The number of {key, value} pairs in the map.

int get length();

Code void operator []=(K key, V value) #

Associates the key with the given value.

void operator []=(K key, V value);

Code V operator [](K key) #

Returns the value for the given key or null if key is not in the map. Because null values are supported, one should either use containsKey to distinguish between an absent key and a null value, or use the putIfAbsent method.

V operator [](K key);

Code V putIfAbsent(K key, V ifAbsent()) #

If key is not associated to a value, calls ifAbsent and updates the map by mapping key to the value returned by ifAbsent. Returns the value in the map.

V putIfAbsent(K key, V ifAbsent());

Code V remove(K key) #

Removes the association for the given key. Returns the value for key in the map or null if key is not in the map. Note that values can be null and a returned null value does not always imply that the key is absent.

V remove(K key);