Exemplo n.º 1
0
 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>());
 }
Exemplo n.º 2
0
        static void printOrder(step root)
        {
            List <step> order = new List <step>();

            root.push();
            Stack <step> orderStack = makeOrder(root, order);

            while (orderStack.Count != 0)
            {
                Console.Write(orderStack.Pop().getC());
            }
            Console.Write(root.getC());
        }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 private static int compareSteps(step left, step right)
 {
     return(left.getC().CompareTo(right.getC()));
 }