add method
Insert a key
and value
association.
key
is a string to be transformed via keyMapping into a key.
Return true if (key, value) pair did not already exist, false otherwise.
Throws ArgumentError if key
is empty or null.
Throws ArgumentError if keyMapping(
key
)
is empty or null.
Implementation
@override
bool add(String key, V value) {
ArgumentError.checkNotNull(value, 'value');
final addResult = _add(_root, _mapKeyNonEmpty(key).runes.toList(), value);
_root = addResult.rootNode;
// Operation may change keys, values, both, or nothing
if (addResult.newKey) {
_version.value.incKeysVersion();
}
if (addResult.valueChanged) {
_version.value.incValuesVersion();
}
return addResult.newKey || addResult.valueChanged;
}