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; } }
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; } }
void rbtree_clear(RBTree *tree) { assert(tree); clear_recursive(tree, tree->root); }