CanonicalizedMap<C, K, V>.fromEntries constructor

CanonicalizedMap<C, K, V>.fromEntries(
  1. Iterable<MapEntry<K, V>> entries,
  2. C canonicalize(
    1. K key
    ), {
  3. bool isValidKey(
    1. K key
    )?,
})

Creates a canonicalized map that is initialized with the key/value pairs of entries.

The canonicalize function should return the canonical value for the given key. Keys with the same canonical value are considered equivalent.

The isValidKey function is called before calling canonicalize for methods that take arbitrary objects. It can be used to filter out keys that can't be canonicalized.

Implementation

CanonicalizedMap.fromEntries(
    Iterable<MapEntry<K, V>> entries, C Function(K key) canonicalize,
    {bool Function(K key)? isValidKey})
    : _canonicalize = canonicalize,
      _isValidKeyFn = isValidKey {
  addEntries(entries);
}