Ejemplo n.º 1
0
 public void Add(string word, int index = 0)
 {
     if (word.Length == index + 1)
     {
         IsWord = true;
     }
     else
     {
         var      next = word[index + 1];
         WordNode child;
         if (!Children.TryGetValue(next, out child))
         {
             Children[next] = new WordNode(next);
         }
         else if (Children[next].Children.Count == 0)
         {
             Children[next] = new WordNode(next)
             {
                 IsWord = true
             }
         }
         ;
         Children[next].Add(word, index + 1);
     }
 }
Ejemplo n.º 2
0
 private void Build(string[] words)
 {
     foreach (var word in words)
     {
         var first = word[0];
         WordNode child;
         if (!Children.TryGetValue(first, out child))
         {
             child = new WordNode(first);
             Children.Add(first, child);
         }
         child.Add(word);
     }
 }
Ejemplo n.º 3
0
 private void Build(string[] words)
 {
     foreach (var word in words)
     {
         var      first = word[0];
         WordNode child;
         if (!Children.TryGetValue(first, out child))
         {
             child = new WordNode(first);
             Children.Add(first, child);
         }
         child.Add(word);
     }
 }
Ejemplo n.º 4
0
 public void Add(string word, int index = 0)
 {
     if (word.Length == index + 1)
         IsWord = true;
     else
     {
         var next = word[index + 1];
         WordNode child;
         if (!Children.TryGetValue(next, out child))
             Children[next] = new WordNode(next);
         else if (Children[next].Children.Count == 0)
             Children[next] = new WordNode(next) { IsWord = true };
         Children[next].Add(word, index + 1);
     }
 }