static void __print_tree(TtreeNode *tnode, int offs, void (*fn)(TtreeNode *tnode)) { int i; for (i = 0; i < offs; i++) printf(" "); if (!tnode) { printf("(nil)\n"); return; } if (tnode_get_side(tnode) == TNODE_LEFT) printf("[L] "); else if (tnode_get_side(tnode) == TNODE_RIGHT) printf("[R] "); else printf("[*] "); printf("\n"); for (i = 0; i < offs + 1; i++) printf(" "); printf("<%d> ", tnode_num_keys(tnode)); if (fn) { fn(tnode); } __print_tree(tnode->left, offs + 1, fn); __print_tree(tnode->right, offs + 1, fn); }
static void __print_tree(GString * str, int level, const struct kz_lookup_ipv6_node *node) { if (node == NULL) return; __print_node(str, level, node); __print_tree(str, level + 1, node->left); __print_tree(str, level + 1, node->right); }
static void __print_tree(const avlNode_t *node, size_t level) { size_t i; if(node == NULL)return; __print_tree(node->child[AVL_RIGHT], level + 1); for(i = 0; i < level; ++i)AR_printf(L" - "); AR_printf(L" %d \r\n", node->data); __print_tree(node->child[AVL_LEFT], level + 1); }
static void __print_tree(struct tree_node *root, int level) { int i; for (i=0; i<level; i++) printf("\t"); printf("%s\n", root->name); for (i=0; i < root->nr_children; i++) { __print_tree(root->children + i, level + 1); } }
static const char *tree_as_string(const struct kz_lookup_ipv6_node *root) { static GString *_str = NULL; if (_str == NULL) { _str = g_string_new(""); } g_string_assign(_str, ""); __print_tree(_str, 0, root); return _str->str; }
void print_tree(struct tree_node *root) { __print_tree(root, 0); }
void avl_print_tree(const avlTree_t *tree) { AR_printf(L"-------------------\r\n"); __print_tree(tree->root, 0); AR_printf(L"-------------------\r\n"); }
void ttree_print(Ttree *ttree, void (*fn)(TtreeNode *tnode)) { __print_tree(ttree->root, 0, fn); }