示例#1
0
 public void AddLetter(char letter)
 {
     if (_nodes.ContainsKey(letter))
     {
         throw new ArgumentException("Key already exist!");
     }
     _nodes[letter] = new PrefixNode(Word + letter);
 }
示例#2
0
 private static IEnumerable <string> EnumerateWords(PrefixNode node)
 {
     if (node.IsEndOfWord)
     {
         yield return(node.Word);
     }
     foreach (var nextNode in node.GetNextNodes())
     {
         foreach (var result in EnumerateWords(nextNode))
         {
             yield return(result);
         }
     }
 }