public void NextSuperTriNode(SuperTriNode superTriNode, TriNode triNode, int id) { for (int i = 0; i < 26; i++) { if (triNode.children [i] != null) { if (superTriNode.children [i] == null) { superTriNode.children [i] = new SuperTriNode(); } if (!superTriNode.children[i].hitList.Contains(id)) { superTriNode.children[i].hitList.Add(id); } NextSuperTriNode(superTriNode.children [i], triNode.children [i], id); } } }
public List <int> ContainsRecords(string s) { string realS = s.ToLower(); List <int> result = null; SuperTriNode curNode = root; for (int i = 0; i < realS.Length; i++) { int c = realS [i] - 'a'; if ((c < 0) || (c >= 26)) { continue; } if (curNode.children [c] == null) { return(null); } curNode = curNode.children [c]; result = curNode.hitList; } return(result); }
public SuperTri() { root = new SuperTriNode(); }