/// <summary> /// Adds a new key value pair, overwriting the existing value if the given key is already in use /// </summary> /// <param name="key">Key to search for value by</param> /// <param name="value">Value associated with key</param> public void Add(TKey key, TValue value) { ITrieNode <TKeyBit, TValue> node = _root; IEnumerable <TKeyBit> bs = this._keyMapper(key); foreach (TKeyBit b in bs) { node = node.MoveToChild(b); } node.Value = value; }
/// <summary> /// Moves to the Node associated with the given Key creating new nodes if necessary /// </summary> /// <param name="key">Key</param> /// <returns>Trie Node</returns> public ITrieNode <TKeyBit, TValue> MoveToNode(TKey key) { ITrieNode <TKeyBit, TValue> node = _root; IEnumerable <TKeyBit> bs = this._keyMapper(key); foreach (TKeyBit b in bs) { node = node.MoveToChild(b); } return(node); }