static void printPred(step root) { Console.Write(root.getC()); Console.Write(": "); foreach (step s in root.getPred()) { Console.Write(s.getC()); } Console.WriteLine(); foreach (step s in root.getPred()) { printPred(s); } }
static Stack <step> makeOrder(step root, List <step> order) { foreach (step s in root.getPred()) { if (!s.getPushed()) { order.Add(s); s.push(); Console.Write(s.getC()); Console.WriteLine(" added"); } } if (order.Count != 0) { order.Sort(compareSteps); step top = order[0]; Console.Write(top.getC()); Console.WriteLine(" pushed"); order.Remove(top); Stack <step> orderStack = makeOrder(top, order); orderStack.Push(top); return(orderStack); } return(new Stack <step>()); }