C Collections

chashmap · Section 3

chashmap_reset

chashmap_reset - clear all elements from the hash map

C Collections (libccollections, -lccollections)

#include <ccollections/chashmap.h>
 
ccol_retval chashmap_reset(chmap chm, size_t new_bucket_array_size);

Removes every key-value pair from the hash map, destroys all internal
data and, if asked, resizes the bucket/slot array. The map is usable
after the reset whether the resize succeeded or not.

chm                      Hash map to reset
new_bucket_array_size    New bucket count (0 = keep current size;
                         values < 16 are raised to 16; otherwise
                         rounded up to the next power of two)

ccol_success           - Every element was cleared (and the resize, if
                         asked for, succeeded)
ccol_not_enough_memory - The resize failed, but the elements are cleared
                         anyway

O(n) complexity, where n is the number of elements
Every element is destroyed whatever the return value is
Asserts if chm is NULL

chmap_destroy(3), chashmap_remove_elem(3)