W3cubDocs

/Dart 2

SplayTreeMap<K, V>.fromIterable constructor

SplayTreeMap<K, V>.fromIterable(Iterable iterable, { K key(dynamic element), V value(dynamic element), int compare(K key1, K key2), bool isValidKey(dynamic potentialKey) })

Creates a SplayTreeMap where the keys and values are computed from the iterable.

For each element of the iterable this constructor computes a key/value pair, by applying key and value respectively.

The keys of the key/value pairs do not need to be unique. The last occurrence of a key will simply overwrite any previous value.

If no functions are specified for key and value the default is to use the iterable value itself.

Implementation

factory SplayTreeMap.fromIterable(Iterable iterable,
    {K key(element),
    V value(element),
    int compare(K key1, K key2),
    bool isValidKey(potentialKey)}) {
  SplayTreeMap<K, V> map = new SplayTreeMap<K, V>(compare, isValidKey);
  MapBase._fillMapWithMappedIterable(map, iterable, key, value);
  return map;
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-collection/SplayTreeMap/SplayTreeMap.fromIterable.html