當前位置: 首頁>>代碼示例>>C#>>正文


C# Node.setForm方法代碼示例

本文整理匯總了C#中Tree.Node.setForm方法的典型用法代碼示例。如果您正苦於以下問題:C# Node.setForm方法的具體用法?C# Node.setForm怎麽用?C# Node.setForm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tree.Node的用法示例。


在下文中一共展示了Node.setForm方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: print

        public override void print(Node t, int n, bool p)
        {
            // Indent (if necessary)
            for (int i = 0; i < n; i++) {
                Console.Write("    ");
            }

            // Get the car and cdr
            Node    car = t.getCar(),
                    cdr = t.getCdr();

            Console.Write("(");     // (
            car.print(n, true);     // Condition
            Console.WriteLine();    // Carriage return
            n++;                    // Increase indentation for the
                                    // subsequent arguments

            // Set form to regular so it can all print on the same line
            // Use false parameter to tell the regular form to not print the
            // carriage return
            t.setForm(new Regular(false));

            while (!cdr.isNil()) {  // Print cond's conditions and expressions
                for (int i = 0; i < n; i++) {   // Indent the parameters of cond
                    Console.Write("    ");
                }
                cdr.getCar().print(0, false);   // Implicitly recur on cars
                Console.WriteLine();            // Carriage return
                cdr = cdr.getCdr();     // Recur down the right side of the tree
            }

            // Decrease indentation because only the arguments needed to
            // be indented
            n--;

            // Indent (if necessary), print the final right parenthesis and the
            // final carriage return
            for (int i = 0; i < n; i++) {
                Console.Write("    ");
            }

            // Print final right paren and carriage return
            cdr.print(0, true);
            Console.WriteLine();
        }
開發者ID:HurricaneFist,項目名稱:cs4101proj1,代碼行數:45,代碼來源:Cond.cs

示例2: print

        public override void print(Node t, int n, bool p)
        {
            // Indent (if necessary)
            for (int i = 0; i < n; i++) {
                Console.Write("    ");
            }

            // Get the car and cdr
            Node    car = t.getCar(),
                    cdr = t.getCdr();

            Console.Write("(");     // (
            car.print(n, true);     // Begin
            Console.WriteLine();    // Carriage return
            n++;                    // Increase indentation

            // Set form to regular so it can all print on the same line
            // Use false parameter to tell the regular form to not print the
            // carriage return
            t.setForm(new Regular(false));

            while (!cdr.isNil()) {
                // Indent the parameters of begin if necessary
                for (int i = 0; i < n; i++) {
                    Console.Write("    ");
                }
                // Print the cadr
                // (This implicitly recurs on the left of the tree)
                cdr.getCar().print(0, false);
                Console.WriteLine();
                // Recur on the right of the tree.
                cdr = cdr.getCdr();
            }

            // Print the final right parenthesis with no indentation
            // and carriage return
            cdr.print(0, true);
            Console.WriteLine();
        }
開發者ID:HurricaneFist,項目名稱:cs4101proj1,代碼行數:39,代碼來源:Begin.cs

示例3: print

        public override void print(Node t, int n, bool p)
        {
            // Indent (if necessary)

            for (int i = 0; i < n; i++)
                Console.Write("    ");

            // Get the car and cdr

            Node car = t.getCar(),
                 cdr = t.getCdr();

            // Print "(begin "
            Console.Write("(");
            car.print(n, true);
            Console.WriteLine();
            n++;

            // Set form to regular so it can all print on the same line
            // Use false parameter to tell the regular form to not print the
            // carriage return
            t.setForm(new Regular(false));

            while (!cdr.isNil()) {
                // Indent and print all parameters (cadrs) recursively
                for (int i = 0; i < n; i++)
                    Console.Write("    ");
                cdr.getCar().print(0, false);
                Console.WriteLine();
                cdr = cdr.getCdr();
            }

            // Print the final right parenthesis and carriage return
            cdr.print(0, true);
            Console.WriteLine();
        }
開發者ID:HurricaneFist,項目名稱:cs4101proj1,代碼行數:36,代碼來源:Let.cs


注:本文中的Tree.Node.setForm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。