Multimap<K, V> class abstract

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.

Implementers

Constructors

Multimap()
Constructs a new list-backed multimap.
factory
Multimap.fromIterable(Iterable iterable, {K key(dynamic)?, V value(dynamic)?})
Constructs a new list-backed multimap.
factory
Multimap.fromMultimap(Multimap<K, V> other)
Constructs a new multimap with the same values as other.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Returns true if there is no key in the multimap.
no setter
isNotEmpty bool
Returns true if there is at least one key in the multimap.
no setter
keys Iterable<K>
The keys of this.
no setter
length int
The number of keys in the multimap.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
values Iterable<V>
The values of this.
no setter

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 and value.
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.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(Object? key, V? value) bool
Removes the association between the given key and value. Returns true 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 if key was unmapped.
removeWhere(bool predicate(K key, V value)) → void
Removes all entries of this multimap that satisfy the given predicate.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](Object? key) Iterable<V>
Returns the values for the given key. An empty iterable is returned if key 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.