string[] AcceptStates(char[] stack) { StringTree pnode = GetStringTreeAt(stack); if (stack == null || stack.Length == 0) { pnode = this; } else { if (pnode == null || pnode.child == null) { return(new string[0]); } else { pnode = pnode.child; } } ArrayList allres = new ArrayList(); while (pnode != null) { int index = pnode.AcceptStateCount; int size = index; char[] buffer = new char[pnode.Depth(2)]; string[] results = new string[size]; pnode.MatchItem(buffer, ref index, 0, size, results); allres.AddRange(results); pnode = pnode.next; } return(allres.ToArray(typeof(string)) as string[]); }
int Depth(int depth) { int c = 0, n = 0; if (child != null) { c = child.Depth(depth + 1); } if (next != null) { n = next.Depth(depth); } if (c > depth) { depth = c; } if (n > depth) { depth = n; } return(depth); }