chashmap · Section 3
chmap_remove
NAME
chmap_remove - remove a key-value pair (type-inferred)
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/chashmap.h> ccol_retval chmap_remove(hm_name, key);
DESCRIPTION
Type-inferred wrapper for chashmap_remove_elem() that returns the result code, so a key_not_found does not stop the program. The lookup key is converted through the DECLARED key type of the map, the same way chmap_insert(3) converts it, so a key stored through that conversion is only found again by a lookup that makes the same conversion. A literal and a computed expression both work.
PARAMETERS
hm_name Hash map to remove from key Key to remove
RETURN VALUE
ccol_success when the key was removed ccol_key_not_found when the map does not hold the key ccol_invalid_args when key is a NULL character pointer, since that is not a string
NOTES
Does not stop the program for key_not_found Frees the memory of the key and of the value
EXAMPLES
int key = 42; ccol_retval r = chmap_remove(map, key); if (r == ccol_key_not_found) { printf("Key not found\n"); }