当前位置: 首页>>代码示例>>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;未经允许,请勿转载。