public void MoveTo(char c) { if (!CanMoveTo(c)) { throw new Exception("Tried to move to an invalid path."); } CurrentNode = CurrentNode.GetChild(c); }
public Tri(List<string> words) { RootNode = new TriNode('\0'); if(!(words == null)) { words.ForEach(word => RootNode.AddString(word)); } }
public Tri(List <string> words) { RootNode = new TriNode('\0'); if (!(words == null)) { words.ForEach(word => RootNode.AddString(word)); } }
public override bool Equals(object obj) { TriNode node = obj as TriNode; if (node == null) { return(false); } return(this.NodeChar == node.NodeChar); }
public void AddString(string str) { if(str == null) { return; } if(str.Length == 0) { AddChild('\0'); return; } char c = str.ToArray()[0]; TriNode possibleNode = GetChild(c); if(possibleNode == null) { possibleNode = new TriNode(c); _nodeSet.Add(possibleNode); } _nodeSet.Add(possibleNode); possibleNode.AddString(str.Substring(1)); }
public void AddString(string str) { if (str == null) { return; } if (str.Length == 0) { AddChild('\0'); return; } char c = str.ToArray()[0]; TriNode possibleNode = GetChild(c); if (possibleNode == null) { possibleNode = new TriNode(c); _nodeSet.Add(possibleNode); } _nodeSet.Add(possibleNode); possibleNode.AddString(str.Substring(1)); }
public TriNavigator(TriNode seedNode) { CurrentNode = seedNode; }