示例#1
0
        /**
         * Remove the value that a key leads to and any redundant nodes which result from this action.
         * Clears the current matching process.
         * Key of the value to remove.
         */
        public void Remove(string key)
        {
            TrieNode <V> node = root;

            foreach (char c in key)
            {
                node = node.GetChild(c);
            }
            node.Value = null;

            //Remove all ancestor nodes which don't lead to a value.
            while (node != root && !node.IsTerminater() && node.NumChildren() == 0)
            {
                char prevKey = node.Key;  node = node.Parent;  node.RemoveChild(prevKey);
            }
            Matcher.ResetMatch();
        }
示例#2
0
 /**
  * Check if the currently entered prefix is an existing string in the trie.
  * Returns: True if the currently entered prefix is an existing string, false otherwise.
  */
 public bool IsExactMatch()
 {
     return(currMatch.IsTerminater());
 }