/* recursive dump */ static void dumpSubtree(stTree *root, FILE *fh, int indent) { fprintf(fh, "%*s", 4*indent, ""); struct malnComp *comp = getNodeComp(root); if (comp == NULL) { fprintf(fh, "%s", stTree_getLabel(root)); } else { malnComp_prInfo(comp, fh); } fputc('\n', fh); for (int i = 0; i < stTree_getChildNumber(root); i++) { dumpSubtree(stTree_getChild(root, i), fh, indent+1); } }
void AVL_dumpTree(const AVL_Tree *tree, void (*dumpFn)(const void*, const void*)) { dumpSubtree(tree->rootNode, 0, 0, dumpFn); printf("\n"); }
/** * Dumps an entire subtree * * @param [in] node The root node of the subtree. * @param [in] depth The depth of the node. * @param [in] dir which subtree (negative: left, positive: right) * @param [in] dumpFn Dump function first argument is the key, second is the value. */ static void dumpSubtree(const AVL_Node *node, int depth, char dir, void (*dumpFn)(const void*, const void*)) { if (node) dumpSubtree(node->left, depth + 1, -1, dumpFn); dumpNode(node, depth, dir, dumpFn); if (node) dumpSubtree(node->right, depth + 1, 1, dumpFn); }
/* dump for debugging */ void mafTree_dump(mafTree *mTree, FILE *fh) { dumpSubtree(mTree->tree, fh, 0); }