public void Add(string text) { char firstLetter = text[0]; if (!_children.ContainsKey(firstLetter)) { StringTreeNode newNode = new StringTreeNode(firstLetter); _children.Add(firstLetter, newNode); } if (text.Length > 1) { _children[firstLetter].Add(text.Substring(1)); } else { var child = _children[firstLetter]; child.IsWord = true; _children[firstLetter] = child; } }
public StringTree(IEnumerable <string> words) { _root = new StringTreeNode('\0'); Build(words); }