C Collections

cbstmap · Section 3

cbmap_remove

cbmap_remove - remove a key-value pair (type-inferred)

C Collections (libccollections, -lccollections)

#include <ccollections/cbstmap.h>
 
ccol_retval cbmap_remove(hm_name, key);

Type-inferred wrapper for cbstmap_remove_elem() that returns its result
code. The tree is rebalanced after the delete.
 
The lookup key is converted through the DECLARED key type of the tree,
as cbmap_insert(3) converts it, so a key stored through that conversion
is found again only by a lookup that makes the same conversion. Both a
literal and a computed expression are accepted.

hm_name  BST map to remove from
key      Key to remove

ccol_success if the key was removed.
ccol_key_not_found if the key is not in the map.
ccol_invalid_args if key is a NULL character pointer, which is not a
string.

ccol_key_not_found doesn't stop the program. The memory of the removed key
and value is freed.

cbstmap_remove_elem(3), cbmap_insert(3)