void AVL<T>::clearHelper(Node* rt){ if(rt->right != NULL) clearHelper(rt->right); if(rt->left != NULL) clearHelper(rt->left); delete rt; }
void BinarySearchTree<Key, Value>::clearHelper( BinaryTreeNode<Key, Value>* subRoot) { if (subRoot == NULL) { return; } else { clearHelper(subRoot->leftChild()); clearHelper(subRoot->rightChild()); delete subRoot; } }
void BSTree<DataType, KeyType>::clearHelper(BSTreeNode* &parent) { if(parent == NULL) { return; } if(parent->right != NULL) { clearHelper(parent->right); } if(parent->left != NULL) { clearHelper(parent->left); } delete parent; parent = NULL; }
void HashTable::clearHelper(Node* src) { delete src->customerInfo; src->customerInfo = NULL; if(src->next != NULL) { clearHelper(src->next); } delete src; src = NULL; }
void HashTable::clear() { for(int i = 0; i <= MAX_BUCKETS ; i++) { if(table[i]->next != NULL) { clearHelper(table[i]->next); } if(table[i]->customerInfo != NULL) { delete table[i]->customerInfo; } delete table[i]; table[i] = NULL; } }
void AVL<T>::clear(){ clearHelper(root); root = NULL; numNodes = 0; }
void BSTree<DataType, KeyType>::clear() { clearHelper(root); }