void BinaryHeap::clear_recursive(BinaryNode *subRoot){
    if(subRoot->hasLeftChild()){
        clear_recursive(subRoot->leftChild);
        delete subRoot->leftChild;
    }
    if(subRoot->hasRightChild()){
        clear_recursive(subRoot->rightChild);
        delete subRoot->rightChild;
    }
}
예제 #2
0
void clear_recursive(RBTree *tree, RBNode *node)
{
    if (node == tree->nil)
    {
        return;
    }

    clear_recursive(tree, node->left);
    clear_recursive(tree, node->right);

    node_destroy(tree, node);
}
void BinaryHeap::clear(){
    if(!isEmpty()){
        clear_recursive(root);
        
        delete root;
        root = NULL; last = NULL;
    }
}
예제 #4
0
void rbtree_clear(RBTree *tree)
{
    assert(tree);

    clear_recursive(tree, tree->root);
}