public void AddLetter(char letter) { if (_nodes.ContainsKey(letter)) { throw new ArgumentException("Key already exist!"); } _nodes[letter] = new PrefixNode(Word + letter); }
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); } } }