put method

PersistentHashMap<K, V> put(
  1. K key,
  2. V value
)

If this map does not already contain the given key to value mapping then create a new version of the map which contains all mappings from the current one plus the given key to value mapping.

Implementation

PersistentHashMap<K, V> put(K key, V value) {
  final _TrieNode newRoot =
      (_root ?? _CompressedNode.empty).put(0, key, key.hashCode, value);
  if (newRoot == _root) {
    return this;
  }
  return PersistentHashMap<K, V>._(newRoot);
}