コード例 #1
0
ファイル: BINTREE.CPP プロジェクト: mymindleaks/jHyperDoc
void BTree::printTree(Node* n){

	if( n != NULL ) {
		printSubTree(n);
		printTree(n->left);
		printTree(n->right);
	}
}
コード例 #2
0
ファイル: tree.c プロジェクト: eoinomurchu/CGE
static void printSubTree(const Node *root) {
  if (root) {
    int i;
    for (i = root->depth; i > 0; i--)
      printf("%s", i==1 ? "|____" : "     ");
    printf("%s\n", ((char *)root->data));
    for (i = 0; i < root->count; i++)
      printSubTree(root->children[i]);
  }
}
コード例 #3
0
ファイル: show.c プロジェクト: DeepCoin/compiler
/*
    Prints the AST
        @Param AST Root of the AST
*/
void printAST(Node* AST) {
    /*printNode(AST, 0);*/
    if(AST != NULL) {
        printf("%s\n", NODE_STRING[AST->n_type]);  
        printTabs(1);
        printf("Id(%s)\n", AST->id->id);   
    }
    
    if(AST->next != NULL)
        printSubTree(AST->next,1);
}
コード例 #4
0
ファイル: show.c プロジェクト: DeepCoin/compiler
/* 
    Prints the subtree of a given node
        @Param currentNode root of the subtree
        @Param tabs number of tabs
*/
void printSubTree(Node* currentNode, int tabs) {

    //printTabs(tabs);
    printNode(currentNode, tabs);
            //NODE_1
            if(currentNode->n1 != NULL){
                printSubTree(currentNode->n1, tabs + 1);
            }
            //NODE_2
            if(currentNode->n2 != NULL){
                //printf("lolada:%s\n",NODE_STRING[currentNode->n2->n_type]);
                printSubTree(currentNode->n2, tabs + 1);
            }
            //NODE_3
            if(currentNode->n3 != NULL){
                printSubTree(currentNode->n3, tabs + 1);
            }

    //next Node
    //printf("print next(%s)\n",NODE_STRING[currentNode->n_type]);
    if(currentNode->next != NULL)
        printSubTree(currentNode->next, tabs);
    
}
コード例 #5
0
ファイル: TreeNode.cpp プロジェクト: eddylu94/DataStructures
int TreeNode::printSubTree(TreeNode *n, int level) {
	int a;
	for (a = 0; a < level; a++) {
		cout << "-----";
	}
	cout << n->data << "\n";
	if (n->children.size() == 0) {
		return n->data;
	}
	int size = n->children.size();
	level++;
	int i;
	for (int i = 0; i < size; i++) {
		printSubTree(n->children.at(i), level);
	}
	return -1;
}
コード例 #6
0
ファイル: TreeNode.cpp プロジェクト: eddylu94/DataStructures
void TreeNode::printTree() {
	TreeNode *n = this;
	printSubTree(n, 0);
	cout << "\n";
}
コード例 #7
0
ファイル: tree.c プロジェクト: eoinomurchu/CGE
void printTree(const Tree *tree) {
  printSubTree(tree->root);
}