Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:core
  3. Map<K,V> class
Map
description

Map<K,V> classabstractinterface

A collection of key/value pairs, from which you retrieve a valueusing its associated key.

There is a finite number of keys in the map,and each key has exactly one value associated with it.

Maps, and their keys and values, can be iterated.The order of iteration is defined by the individual type of map.Examples:

  • The plainHashMap is unordered (no order is guaranteed),
  • theLinkedHashMap iterates in key insertion order,
  • and a sorted map likeSplayTreeMap iterates the keys in sorted order.

It is generally not allowed to modify the map (add or remove keys) whilean operation is being performed on the map, for example in functions calledduring aforEach call.Modifying the map while iterating the keys or valuesmay also break the iteration.

It is generally not allowed to modify the equality of keys (and thus nottheir hashcode) while they are in the map. Some specialized subtypes may bemore permissive, in which case they should document this behavior.

Key equality must be an equality relation. If the key stored in a mapand the key used for lookup do not agree on whether the two are equal,so equality is notsymmetric, then lookup behavior is unspecified.

Implementers

Constructors

Map()
Creates an emptyLinkedHashMap.
factory
Map.from(Mapother)
Creates aLinkedHashMap with the same keys and values asother.
factory
Map.fromEntries(Iterable<MapEntry<K,V>>entries)
Creates a new map and adds all entries.
factory
Map.fromIterable(Iterableiterable, {Kkey(dynamicelement)?,Vvalue(dynamicelement)?})
Creates a Map instance in which the keys and values are computed from theiterable.
factory
Map.fromIterables(Iterable<K>keys,Iterable<V>values)
Creates a map associating the givenkeys to the givenvalues.
factory
Map.identity()
Creates an identity map with the default implementation,LinkedHashMap.
factory
Map.of(Map<K,V>other)
Creates aLinkedHashMap with the same keys and values asother.
factory
Map.unmodifiable(Mapother)
Creates an unmodifiable hash-based map containing the entries ofother.
factory

Properties

entriesIterable<MapEntry<K,V>>
The map entries of thisMap.
no setter
hashCodeint
The hash code for this object.
no setterinherited
isEmptybool
Whether there is no key/value pair in the map.
no setter
isNotEmptybool
Whether there is at least one key/value pair in the map.
no setter
keysIterable<K>
The keys of thisMap.
no setter
lengthint
The number of key/value pairs in the map.
no setter
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited
valuesIterable<V>
The values of thisMap.
no setter

Methods

addAll(Map<K,V>other)→ void
Adds all key/value pairs ofother to this map.
addEntries(Iterable<MapEntry<K,V>>newEntries)→ void
Adds all key/value pairs ofnewEntries to this map.
cast<RK,RV>()Map<RK,RV>
Provides a view of this map as havingRK keys andRV instances,if necessary.
clear()→ void
Removes all entries from the map.
containsKey(Object?key)bool
Whether this map contains the givenkey.
containsValue(Object?value)bool
Whether this map contains the givenvalue.
forEach(voidaction(Kkey,Vvalue))→ void
Appliesaction to each key/value pair of the map.
map<K2,V2>(MapEntry<K2,V2>convert(Kkey,Vvalue))Map<K2,V2>
Returns a new map where all entries of this map are transformed bythe givenconvert function.
noSuchMethod(Invocationinvocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
putIfAbsent(Kkey,VifAbsent())→ V
Look up the value ofkey, or add a new entry if it isn't there.
remove(Object?key)→ V?
Removeskey and its associated value, if present, from the map.
removeWhere(booltest(Kkey,Vvalue))→ void
Removes all entries of this map that satisfy the giventest.
toString()String
A string representation of this object.
inherited
update(Kkey,Vupdate(Vvalue), {VifAbsent()?})→ V
Updates the value for the providedkey.
updateAll(Vupdate(Kkey,Vvalue))→ void
Updates all values.

Operators

operator ==(Objectother)bool
The equality operator.
inherited
operator [](Object?key)→ V?
The value for the givenkey, ornull ifkey is not in the map.
operator []=(Kkey,Vvalue)→ void
Associates thekey with the givenvalue.

Static Methods

castFrom<K,V,K2,V2>(Map<K,V>source)Map<K2,V2>
Adaptssource to be aMap<K2, V2>.
  1. Dart
  2. dart:core
  3. Map<K,V> class
dart:core library

[8]ページ先頭

©2009-2025 Movatter.jp