public void Add(string name) { var nodePointer = _root; foreach (var letter in name) { var nextNode = nodePointer.GetChild(letter); if (nextNode == null) { nextNode = new LetterNode(letter); nodePointer.Children.Add(nextNode); } nextNode.Count += 1; nodePointer = nextNode; } }
public ContactsTrie() { _root = new LetterNode('@'); }