void *ptree_Minimum(pwr_tStatus *sts, ptree_sTable*tp) { ptree_sNode *np; pool_tRef nr; nr = minimumNode(tp, tp->g->root); if ( nr == tp->g->null) pwr_Return(NULL, sts, TREE__NOTFOUND); np = pool_Address(sts, tp->php, nr); pwr_Return((void *)np, sts, TREE__FOUND); }
static tree_sNode * successorNode(tree_sTable *tp, tree_sNode *np) { tree_sNode *p; if (np->right != tp->null) return minimumNode(tp, np->right); for (p = np->parent; p != tp->null && np == p->right; np = p, p = p->parent) ; return p; }
void * tree_Minimum(pwr_tStatus *sts, tree_sTable*tp) { tree_sNode *np; np = minimumNode(tp, tp->root); if (np == tp->null) { pwr_Return(NULL, sts, TREE__NOTFOUND); } else { pwr_Return((void *)np, sts, TREE__FOUND); } }
static void emptyTree( pwr_tStatus *sts, ptree_sTable *tp) { pool_tRef nr; pool_tRef mr; if ( tp == NULL) return; for ( mr = minimumNode( tp, tp->g->root); mr != pool_cNRef;) { if ( mr == tp->g->null) return; nr = successorNode( tp, mr); mr = deleteNode( tp, mr); freeNode( tp, mr); mr = nr; } }
static pool_tRef successorNode(ptree_sTable* tp, pool_tRef nr) { pwr_tStatus sts; ptree_sNode* p; pool_tRef pr; ptree_sNode* np = pool_Address(&sts, tp->php, nr); if (np->right != tp->g->null) return minimumNode(tp, np->right); for (pr = np->parent, p = pool_Address(&sts, tp->php, pr); pr != tp->g->null && nr == p->right; np = p, nr = pr, pr = p->parent, p = pool_Address(&sts, tp->php, pr)) ; return pr; }
static void emptyTree(pwr_tStatus *sts, tree_sTable *tp) { tree_sNode *np; tree_sNode *mp; if (tp == NULL) return; for (mp = minimumNode(tp, tp->root); mp != NULL;) { if (mp == tp->null) return; np = successorNode(tp, mp); mp = deleteNode(tp, mp); freeNode(tp, mp); mp = np; } }