CanonicalizedMap<C, K, V>.from constructor

CanonicalizedMap<C, K, V>.from(Map<K, V> other, C canonicalize(K key), { bool isValidKey(Object key) })

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

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.from(Map<K, V> other, C canonicalize(K key),
    {bool isValidKey(Object key)})
    : _canonicalize = canonicalize,
      _isValidKeyFn = isValidKey {
  addAll(other);
}