static void pr_node (BiNode_s *node, int indent) { if (!node) return; pr_node(node->left, indent + 1); pr_rec(node->rec, indent); pr_node(node->right, indent + 1); }
static void pr_branch (BtNode_s *branch, int indent) { int i; pr_node(branch->first, indent + 1); for (i = 0; i < branch->num; i++) { pr_indent(indent); printf("%llu\n", branch->twig[i].key); pr_node(branch->twig[i].node, indent + 1); } }
static void pr_node (BbNode_s *node, int indent) { if (!node) return; pr_node(node->right, indent + 1); pr_indent(indent); if (node->key < 26) { printf("%d %c\n", node->siblings, '@' + (u8)node->key); } else { printf("%d %lld\n", node->siblings, node->key); } pr_node(node->left, indent + 1); }
void pr_bucket (bucket_s *b, unint depth) { switch (b->b_type) { case EMPTY: pr_empty(depth); return; case NODE: pr_node(b->b_node, depth); return; case LEAF: pr_leaf(b->b_num, depth); return; } }
void pr_node_list(struct node_list *node_list) { int i; printf("local_node_id: %d\n", node_list->local_node_id); printf("ping: %d, pingtimeout: %d\n", node_list->ping, node_list->pingtimeout); printf("max_num: %d, node_num: %d\n", node_list->max_num, node_list->node_num); printf("nodes:\n"); for (i = 0; i < node_list->node_num; i++) { struct node *node; node = node_list->nodes[i]; pr_node(node); printf("\n"); } }
static void pr_node (u64 id, unint indent) { unint i; dir_s dir; dname_s *dn; int rc; rc = read_dir(id, &dir); if (rc) { printf("%8lld not found because %d\n", id, rc); return; } prmem("dir", &dir, sizeof(dir)); for (i = 0; i < DIR_SZ; i++) { dn = &dir.dr_n[i]; if (dn->dn_num) { pr_indent(indent); printf(" %8lld %.*s\n", dn->dn_num, DIR_SZ, dn->dn_name); pr_node(dn->dn_num, indent + 1); } } prmem("dir", &dir, sizeof(dir)); }
int bi_print (BiTree_s *tree) { pr_node(tree->root, 0); return 0; }
int bb_print (BbTree_s *tree) { puts("----------------\n"); pr_node(tree->root, 0); return 0; }
static int lsp (int argc, char *argv[]) { printf("<root>\n"); pr_node(ROOT, 0); return 0; }
int bt_print (BtTree_s *tree) { pr_node(tree->root, 0); return 0; }