Removes the node with the minimum key from the tree.
bool rbtree_remove_min(RBTree* tree, value_type* out_value);
Name | Type | Description |
---|---|---|
tree | RBTree* | A pointer to the tree. |
out_value | value_type* | A pointer to be filled with the value of the minimum node. |
Returns: true
if there were any nodes in the tree, false
otherwise.
RBTREE_DEFINE_H(ISTree, is_tree, int, char*)
RBTREE_DEFINE_C(ISTree, is_tree, int, char*, int_cmp) // The definition of int_cmp can be found in the RedBlackTree main page.
ISTree* tree = is_tree_create();
is_tree_add(tree, 0, "zero");
is_tree_add(tree, 1, "one");
is_tree_add(tree, -1, "negative one");
char* value;
// Removes values until there are no more.
while(is_tree_remove_min(tree, &value)) {
printf("%s\n", value);
}
is_tree_free(tree, true);
// Output:
// negative one
// zero
// one