Added function to delete contents of AVL tree
This commit is contained in:
@@ -39,3 +39,11 @@ struct avltree_t *avl_remove(struct avltree_t *tree, int key);
|
||||
* @return void*
|
||||
*/
|
||||
void *avl_get(struct avltree_t *tree, int key);
|
||||
|
||||
/**
|
||||
* @brief Removes every node present on the given tree.
|
||||
*
|
||||
* @param tree
|
||||
* @return NULL
|
||||
*/
|
||||
void *avl_clear(struct avltree_t *tree);
|
||||
@@ -199,3 +199,12 @@ void *avl_get(struct avltree_t *tree, int key)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *avl_clear(struct avltree_t *tree)
|
||||
{
|
||||
while(tree != NULL)
|
||||
{
|
||||
tree = avl_remove(tree, tree->key);
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
Reference in New Issue
Block a user