public static void doMatch(int cIdx, int cInt, ref List<TrieNodePtr> list, List<WordMatch> matches) { List<TrieNodePtr> newList = new List<TrieNodePtr>(); Logger.LogTrace("doMatch cIdx: {} char: {} list size {} matches size {}", cIdx, (char)(cInt + (int)'a'), list.Count, matches.Count); foreach (TrieNodePtr nodePtr in list) { //Found a direct match if (nodePtr.node.children[cInt] != null) { TrieNodePtr newNp = new TrieNodePtr(nodePtr, nodePtr.node.children[cInt]); newList.Add(newNp); newNp.addMatches(matches); } //If last change > 5, then add the rest of the children if (nodePtr.numChanges == 0 || cIdx - nodePtr.rightChangeIndex >= minDistance) { foreach (var x in nodePtr.node.childrenList) { int charInt = x.Item1; TrieNode childNode = x.Item2; //Ignore direct match, was taken care of above if (charInt == cInt) continue; TrieNodePtr newNp = new TrieNodePtr(nodePtr, childNode, cIdx); newList.Add(newNp); newNp.addMatches(matches); } } } list = newList; }