GetChild() public method

public GetChild ( char c ) : TrieNode
c char
return TrieNode
Exemplo n.º 1
0
 private TrieNode Contains(char c, TrieNode node)
 {
     if (node.Contains(c))
     {
         return node.GetChild(c);
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 2
0
 private TrieNode Insert(char c, TrieNode node)
 {
     if (node.Contains(c)) return node.GetChild(c);
     else
     {
         int n = Convert.ToByte(c) - TrieNode.ASCIIA;
         TrieNode t = new TrieNode();
         node.nodes[n] = t;
         return t;
     }
 }
Exemplo n.º 3
0
 private TrieNode Contains(char c, TrieNode node)
 {
     if (node.Contains(c))
     {
         return(node.GetChild(c));
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 4
0
 private TrieNode Insert(char c, TrieNode node)
 {
     if (node.Contains(c))
     {
         return(node.GetChild(c));
     }
     else
     {
         int      n = Convert.ToByte(c) - TrieNode.ASCIIA;
         TrieNode t = new TrieNode();
         node.nodes[n] = t;
         return(t);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Recursive method to add word. Gets the first char of the word,
        /// creates the child TrieNode if null, and recurses with the first
        /// char removed from the word. If the word length is 0, return.
        /// </summary>
        private void AddWord(TrieNode trieNode, char[] word)
        {
            if (word.Length == 0)
            {
                trieNode.WordCount++;
                return;
            }
            var      c     = Utilities.FirstChar(word);
            TrieNode child = trieNode.GetChild(c);

            if (child == null)
            {
                child = TrieFactory.CreateTrieNode(c, trieNode);
                trieNode.SetChild(child);
            }
            var cRemoved = Utilities.FirstCharRemoved(word);

            AddWord(child, cRemoved);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Recursive method to add word. Gets the first char of the word, 
 /// creates the child TrieNode if null, and recurses with the first
 /// char removed from the word. If the word length is 0, return.
 /// </summary>
 private void AddWord(TrieNode trieNode, char[] word)
 {
     if (word.Length == 0)
     {
         trieNode.WordCount++;
         return;
     }
     var c = Utilities.FirstChar(word);
     TrieNode child = trieNode.GetChild(c);
     if (child == null)
     {
         child = TrieFactory.CreateTrieNode(c, trieNode);
         trieNode.SetChild(child);
     }
     var cRemoved = Utilities.FirstCharRemoved(word);
     AddWord(child, cRemoved);
 }