本文整理匯總了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();
}
示例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();
}
示例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();
}