void tree::print_tree_helper(node * current_node, int level) { theSarf->out<<QString().fill(' ',level*7)<<current_node->to_string(isAffix)<<"\n"; QVector<letter_node* > list=current_node->getLetterChildren(); for(int i=0;i<list.count();i++) print_tree_helper(list.at(i),level+1); QList<result_node*>* list2=current_node->getResultChildren(); for(int i=0;i<list2->count();i++) print_tree_helper(list2->at(i),level+1); }
extern void print_tree_helper(rbtree_node n, int indent) { int i; if (n == NULL) { fputs("<empty tree>", stdout); return; } if (n->right != NULL) { print_tree_helper(n->right, indent + INDENT_STEP); } for(i=0; i<indent; i++) fputs(" ", stdout); if (n->color == BLACK) printf("%d\n", (int)n->key); else printf("<%d>\n", (int)n->key); if (n->left != NULL) { print_tree_helper(n->left, indent + INDENT_STEP); } }
static void print_tree_helper(FILE *fp, node *n, l_int32 keytype, l_int32 indent) { l_int32 i; if (n == NULL) { fprintf(fp, "<empty tree>"); return; } if (n->right != NULL) { print_tree_helper(fp, n->right, keytype, indent + INDENT_STEP); } for (i = 0; i < indent; i++) fprintf(fp, " "); if (n->color == L_BLACK_NODE) { if (keytype == L_INT_TYPE) fprintf(fp, "%lld\n", n->key.itype); else if (keytype == L_UINT_TYPE) fprintf(fp, "%llx\n", n->key.utype); else if (keytype == L_FLOAT_TYPE) fprintf(fp, "%f\n", n->key.ftype); } else { if (keytype == L_INT_TYPE) fprintf(fp, "<%lld>\n", n->key.itype); else if (keytype == L_UINT_TYPE) fprintf(fp, "<%llx>\n", n->key.utype); else if (keytype == L_FLOAT_TYPE) fprintf(fp, "<%f>\n", n->key.ftype); } if (n->left != NULL) { print_tree_helper(fp, n->left, keytype, indent + INDENT_STEP); } }
/* * l_rbtreePrint() * * Input: stream * t (rbtree) * Return: null */ void l_rbtreePrint(FILE *fp, L_RBTREE *t) { PROCNAME("l_rbtreePrint"); if (!fp) { L_ERROR("stream not defined\n", procName); return; } if (!t) { L_ERROR("tree not defined\n", procName); return; } print_tree_helper(fp, t->root, t->keytype, 0); fprintf(fp, "\n"); }
/* * Print a tree from a given root */ static void print_tree(syn_tree &tree, std::string &str) { print_tree_helper(tree.get_root(), str); }
extern void print_tree(rbtree t) { print_tree_helper(t->root, 0); puts(""); }
void print_tree(rbtree t) { print_tree_helper(t->root, 0); }