예제 #1
0
        // Search miss is the beauty here.
        private TernaryTrieNode <V> GetHelper(string key, TernaryTrieNode <V> node, int d)
        {
            if (d == key.Length || node == null)
            {
                return(node);
            }
            char c      = key.ElementAt(d);
            var  parent = node.Get(c);

            return(GetHelper(key, parent, d + 1));
        }
예제 #2
0
        private int SearchTrie(string key, TernaryTrieNode <V> node, int d, int length)
        {
            if (node == null)
            {
                return(length);
            }
            if (node.Value != null)
            {
                length = d;
            }
            if (d == key.Length)
            {
                return(length);
            }
            char c      = key.ElementAt(d);
            var  parent = node.Get(c);

            return(SearchTrie(key, parent, d + 1, length));
        }