add method
Returns a new map containing the current map plus the given key:value. (if necessary, the given key:value pair will override the current).
Implementation
IMap<K, V> add(K key, V value) {
IMap<K, V> result;
result = config.sort
? IMap._unsafe(
MFlat.fromEntries(_m.entries.followedBy([MapEntry(key, value)]), config: config),
config: config)
: IMap<K, V>._unsafe(_m.add(key: key, value: value), config: config);
// A map created with `add` has a larger counter than its source map.
// This improves the order in which maps are flushed.
// If the outer map is used, it will be flushed before the source map.
// If the source map is not used directly, it will not flush unnecessarily,
// and also may be garbage collected.
result._counter = _counter;
result._count();
return result;
}