SplayTreeMap<K, V>.fromIterables constructor

SplayTreeMap<K, V>.fromIterables(
  1. Iterable<K> keys,
  2. Iterable<V> values,
  3. [int compare(
    1. K key1,
    2. K key2
  4. bool isValidKey(
    1. dynamic potentialKey

Creates a SplayTreeMap associating the given keys to values.

This constructor iterates over keys and values and maps each element of keys to the corresponding element of values.

If keys contains the same object multiple times, the last occurrence overwrites the previous value.

It is an error if the two Iterables don't have the same length. Example:

final keys = ['1', '2', '3', '4'];
final values = ['A', 'B', 'C', 'D'];
final mapFromIterables = SplayTreeMap.fromIterables(keys, values);
print(mapFromIterables); // {1: A, 2: B, 3: C, 4: D}


factory SplayTreeMap.fromIterables(Iterable<K> keys, Iterable<V> values,
    [int Function(K key1, K key2)? compare,
    bool Function(dynamic potentialKey)? isValidKey]) {
  SplayTreeMap<K, V> map = SplayTreeMap<K, V>(compare, isValidKey);
  MapBase._fillMapWithIterables(map, keys, values);
  return map;