cucon_hzmap_node_t cucon_hzmap_1w_find | ( | cucon_hzmap_t | map, | |
void const * | key | |||
) |
A version of cucon_hzmap_find_node optimised for the case when it is known that map has 1 word keys.
cucon_hzmap_node_t cucon_hzmap_2w_find | ( | cucon_hzmap_t | map, | |
void const * | key | |||
) |
A version of cucon_hzmap_find_node optimised for the case when it is known that map has 2 word keys.
size_t cucon_hzmap_capacity | ( | cucon_hzmap_t | map | ) |
The current size of the underlying array.
cu_bool_t cucon_hzmap_erase | ( | cucon_hzmap_t | , | |
void const * | key | |||
) |
If map contains a node with key key, erase it and return true, else return false.
void cucon_hzmap_filter | ( | cu_clop(f, cu_bool_t, cucon_hzmap_node_t) | , | |
cucon_hzmap_t | map | |||
) |
Removes all elements from map which f maps to false.
void cucon_hzmap_filter_keys | ( | cu_clop(f, cu_bool_t, void const *key) | , | |
cucon_hzmap_t | map | |||
) |
As cucon_hzmap_filter, but pass only keys to f.
cucon_hzmap_node_t cucon_hzmap_find | ( | cucon_hzmap_t | map, | |
void const * | key | |||
) |
Returns the node in map with key key, or NULL
if no such node exists.
void cucon_hzmap_finish_erase | ( | cucon_hzmap_t | ) |
Adjusts the capacity after a sequence of cucon_hzmap_erase.
cu_bool_t cucon_hzmap_forall | ( | cu_clop(f, cu_bool_t, cucon_hzmap_node_t) | , | |
cucon_hzmap_t | map | |||
) |
True if f maps all elements of map to true, otherwise exits with false on the first element which maps to false.
cu_bool_t cucon_hzmap_forall_keys | ( | cu_clop(f, cu_bool_t, void const *key) | , | |
cucon_hzmap_t | map | |||
) |
As cucon_hzmap_forall, but pass only keys to f.
void cucon_hzmap_init | ( | cucon_hzmap_t | map, | |
cu_shortsize_t | key_size_w | |||
) |
Initialize map as an empty map to be used with elements of key size key_size_w words.
cu_bool_t cucon_hzmap_insert | ( | cucon_hzmap_t | map, | |
void const * | key, | |||
size_t | node_size, | |||
cucon_hzmap_node_t * | node_out | |||
) |
If a node with key key exists in map, assign it to *node_out and
return false, else insert a new node of size node_size, set it's key to key, assign it to *node_out,
and return true.
cu_bool_t cucon_hzmap_insert_node | ( | cucon_hzmap_t | map, | |
cucon_hzmap_node_t | node | |||
) |
Given that node is initialised with a key of suitable size for map, if they key exists in map, returns false, else links node to map and returns true. The cucon_hzmap_node base struct of node is initialised by this call if the insert takes place.
cu_bool_t cucon_hzmap_insert_void | ( | cucon_hzmap_t | , | |
void const * | key | |||
) |
If a node of key key exists in map, return false, else insert a node of key key an no othe data.
cucon_hzmap_node_t cucon_hzmap_itr_get | ( | cucon_hzmap_itr_t | itr | ) |
The next element of the sequence initialised with cucon_hzmap_itr_init, or NULL
if there are no more elements.
void cucon_hzmap_itr_init | ( | cucon_hzmap_itr_t | itr, | |
cucon_hzmap_t | map | |||
) |
Initialise an iterator over elements of map.
cucon_hzmap_t cucon_hzmap_new | ( | cu_shortsize_t | key_size_w | ) |
Return an empty map to be used for elements with key size key_size_w words.
void cucon_hzmap_prepare_insert | ( | cucon_hzmap_t | , | |
size_t | count | |||
) |
As an optimisation, this function may be called prior to a sequence of inserts to inform how many keys will be inserted. This will cause the underlying array to be resized to it's final size right away.
size_t cucon_hzmap_size | ( | cucon_hzmap_t | map | ) |
Number of elements in map.
cu_bool_t cucon_hzmap_step_erase | ( | cucon_hzmap_t | map, | |
void const * | key | |||
) |
Same as cucon_hzmap_erase, except the underlying capacity of map will be left unchanged. This is used for optimising code where many keys are erased in a row. Call cucon_hzmap_finish_erase at the end to adjust the capacity.