です。
/**
* To modify, use the InsertIntoNew and RemoveFromNew methods
* which return a new instance with minimal changes (about Log C),
* so this is an efficient way to make changes without having
* to copy the entire data structure.
*/
InsertIntoNew()
方法を見てみてください:
/** Return a new tree with the key-value pair inserted
* If the key is already present, it replaces the value
* This operation is O(Log N) where N is the number of keys
*/
public ImmutableDictionary<K,V> InsertIntoNew(K key, V val)
{ ... }
RemoveFromNew()
方法:Immutable AVL Tree in C#:
/** Try to remove the key, and return the resulting Dict
* if the key is not found, old_node is Empty, else old_node is the Dict
* with matching Key
*/
public ImmutableDictionary<K,V> RemoveFromNew(K key, out ImmutableDictionary<K,V> old_node)
{ ... }
をまた、別の実装があります。これは同じO(log N)ルックアップと挿入時間を持ちます。