Multimap< K, V> class
An associative container that maps a key to multiple values.
Key lookups return mutable collections that are views of the multimap. Updates to the multimap are reflected in these collections and similarly, modifications to the returned collections are reflected in the multimap.
Constructors
- Multimap()
-
Constructs a new list-backed multimap.
factory
- Multimap.fromIterable(Iterable iterable, { K key(dynamic element), V value(dynamic element) })
-
Constructs a new list-backed multimap. For each element e of
iterable
, adds an association from key to value.key
andvalue
each default to the identity function.factory
Properties
- isEmpty → bool
-
Returns true if there is no key in the multimap.
read-only
- isNotEmpty → bool
-
Returns true if there is at least one key in the multimap.
read-only
-
keys
→ Iterable<
K> -
The keys of this.
read-only
- length → int
-
The number of keys in the multimap.
read-only
-
values
→ Iterable<
V> -
The values of this.
read-only
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
add(
K key, V value) → void - Adds an association from the given key to the given value.
-
addAll(
Multimap< K, V> other) → void -
Adds all associations of
other
to this multimap. [...] -
addValues(
K key, Iterable< V> values) → void - Adds an association from the given key to each of the given values.
-
asMap(
) → Map< K, Iterable< V>> - Returns a view of this multimap as a map.
-
clear(
) → void - Removes all data from the multimap.
-
contains(
Object key, Object value) → bool -
Returns whether this multimap contains the given association between
key
andvalue
. -
containsKey(
Object key) → bool -
Returns whether this multimap contains the given
key
. -
containsValue(
Object value) → bool -
Returns whether this multimap contains the given
value
. -
forEach(
void f(K key, V value)) → void -
Applies
f
to each {key, value} pair of the multimap. [...] -
forEachKey(
void f(K key, Iterable< V> value)) → void -
Applies
f
to each {key,Iterable<value>
} pair of the multimap. [...] -
remove(
Object key, V value) → bool -
Removes the association between the given
key
andvalue
. Returnstrue
if the association existed,false
otherwise. -
removeAll(
Object key) → Iterable< V> -
Removes the association for the given
key
. Returns the collection of removed values, or an empty iterable ifkey
was unmapped. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator [](
Object key) → Iterable< V> -
Returns the values for the given
key
. An empty iterable is returned ifkey
is not mapped. The returned collection is a view on the multimap. Updates to the collection modify the multimap and likewise, modifications to the multimap are reflected in the returned collection. -
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited