HashMap<K, V> class
An unordered collection of key-value pairs.
In the C++ STL, this matches std::unordered_map.
It utilizes a fast hash table under the hood and makes no guarantees
about the iteration order of the elements.
- Mixed-in types
-
- IterableMixin<
Pair< K, V> >
- IterableMixin<
Constructors
- HashMap()
- Creates an empty HashMap.
-
HashMap.from(Map<
K, V> other) - Creates a HashMap from an existing Dart Map.
Properties
- empty → bool
-
Returns
trueif the map is empty.no setter -
first
→ Pair<
K, V> -
The first element.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setteroverride
- isEmpty → bool
-
Whether this collection has no elements.
no setterinherited
- isNotEmpty → bool
-
Returns
trueif the map is not empty.no setteroverride -
iterator
→ Iterator<
Pair< K, V> > -
A new
Iteratorthat allows iterating the elements of thisIterable.no setteroverride -
last
→ Pair<
K, V> -
The last element.
no setterinherited
- length → int
-
The number of elements in this Iterable.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
single
→ Pair<
K, V> -
Checks that this iterable has only one element, and returns that element.
no setterinherited
- size → int
-
Returns the number of elements in the map.
no setter
Methods
-
any(
bool test(Pair< K, V> element)) → bool -
Checks whether any element of this iterable satisfies
test.inherited -
cast<
R> () → Iterable< R> -
A view of this iterable as an iterable of
Rinstances.inherited -
clear(
) → void - Removes all elements from the map.
-
contains(
Object? element) → bool -
Whether the collection contains an element equal to
element.inherited -
containsKey(
K key) → bool -
Returns
trueif the map contains the specifiedkey. -
elementAt(
int index) → Pair< K, V> -
Returns the
indexth element.inherited -
erase(
K key) → bool -
Removes the element with the specified
key. -
every(
bool test(Pair< K, V> element)) → bool -
Checks whether every element of this iterable satisfies
test.inherited -
expand<
T> (Iterable< T> toElements(Pair<K, V> element)) → Iterable<T> -
Expands each element of this Iterable into zero or more elements.
inherited
-
firstWhere(
bool test(Pair< K, V> element), {Pair<K, V> orElse()?}) → Pair<K, V> -
The first element that satisfies the given predicate
test.inherited -
fold<
T> (T initialValue, T combine(T previousValue, Pair< K, V> element)) → T -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< Pair< other) → Iterable<K, V> >Pair< K, V> > -
Creates the lazy concatenation of this iterable and
other.inherited -
forEach(
void action(Pair< K, V> element)) → void -
Invokes
actionon each element of this iterable in iteration order.inherited -
insert(
K key, V value) → void - Inserts a key-value pair. If the key already exists, its value is updated.
-
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
lastWhere(
bool test(Pair< K, V> element), {Pair<K, V> orElse()?}) → Pair<K, V> -
The last element that satisfies the given predicate
test.inherited -
map<
T> (T toElement(Pair< K, V> e)) → Iterable<T> -
The current elements of this iterable modified by
toElement.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reduce(
Pair< K, V> combine(Pair<K, V> value, Pair<K, V> element)) → Pair<K, V> -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
singleWhere(
bool test(Pair< K, V> element), {Pair<K, V> orElse()?}) → Pair<K, V> -
The single element that satisfies
test.inherited -
skip(
int count) → Iterable< Pair< K, V> > -
Creates an Iterable that provides all but the first
countelements.inherited -
skipWhile(
bool test(Pair< K, V> value)) → Iterable<Pair< K, V> > -
Creates an
Iterablethat skips leading elements whiletestis satisfied.inherited -
swap(
HashMap< K, V> other) → void -
Exchanges the contents of this map with those of
other. -
take(
int count) → Iterable< Pair< K, V> > -
Creates a lazy iterable of the
countfirst elements of this iterable.inherited -
takeWhile(
bool test(Pair< K, V> value)) → Iterable<Pair< K, V> > -
Creates a lazy iterable of the leading elements satisfying
test.inherited -
toList(
{bool growable = true}) → List< Pair< K, V> > -
Creates a List containing the elements of this Iterable.
inherited
-
toSet(
) → Set< Pair< K, V> > -
Creates a Set containing the same elements as this iterable.
inherited
-
toString(
) → String -
Returns a string representation of (some of) the elements of
this.inherited -
where(
bool test(Pair< K, V> element)) → Iterable<Pair< K, V> > -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test.inherited -
whereType<
T> () → Iterable< T> -
Creates a new lazy Iterable with all elements that have type
T.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
-
operator [](
K key) → V? -
Returns the value associated with the
key, or null if it doesn't exist. -
operator []=(
K key, V value) → void -
Associates the
valuewith thekey.