24#ifndef CCC_FLAT_HASH_MAP_H
25#define CCC_FLAT_HASH_MAP_H
31#include "impl/impl_flat_hash_map.h"
78#define ccc_fhm_init(memory_ptr, capacity, fhash_elem_field, key_field, \
79 alloc_fn, hash_fn, key_eq_fn, aux_data) \
80 ccc_impl_fhm_init(memory_ptr, capacity, fhash_elem_field, key_field, \
81 alloc_fn, hash_fn, key_eq_fn, aux_data)
219#define ccc_fhm_insert_r(flat_hash_map_ptr, out_handle_ptr) \
222 ccc_fhm_insert((flat_hash_map_ptr), (out_handle_ptr)).impl_ \
248#define ccc_fhm_remove_r(flat_hash_map_ptr, out_handle_ptr) \
251 ccc_fhm_remove((flat_hash_map_ptr), (out_handle_ptr)).impl_ \
276#define ccc_fhm_try_insert_r(flat_hash_map_ptr, key_val_handle_ptr) \
279 ccc_fhm_try_insert((flat_hash_map_ptr), (key_val_handle_ptr)).impl_ \
297#define ccc_fhm_try_insert_w(flat_hash_map_ptr, key, lazy_value...) \
300 ccc_impl_fhm_try_insert_w(flat_hash_map_ptr, key, lazy_value) \
322#define ccc_fhm_insert_or_assign_r(flat_hash_map_ptr, key_val_handle_ptr) \
325 ccc_fhm_insert_or_assign((flat_hash_map_ptr), (key_val_handle)).impl_ \
340#define ccc_fhm_insert_or_assign_w(flat_hash_map_ptr, key, lazy_value...) \
343 ccc_impl_fhm_insert_or_assign_w(flat_hash_map_ptr, key, lazy_value) \
380#define ccc_fhm_entry_r(flat_hash_map_ptr, key_ptr) \
383 ccc_fhm_entry((flat_hash_map_ptr), (key_ptr)).impl_ \
434#define ccc_fhm_and_modify_w(flat_hash_map_entry_ptr, type_name, \
438 ccc_impl_fhm_and_modify_w(flat_hash_map_entry_ptr, type_name, \
465#define ccc_fhm_or_insert_w(flat_hash_map_entry_ptr, lazy_key_value...) \
466 ccc_impl_fhm_or_insert_w(flat_hash_map_entry_ptr, lazy_key_value)
487#define ccc_fhm_insert_entry_w(flat_hash_map_entry_ptr, lazy_key_value...) \
488 ccc_impl_fhm_insert_entry_w(flat_hash_map_entry_ptr, lazy_key_value)
500#define ccc_fhm_remove_entry_r(flat_hash_map_entry_ptr) \
503 ccc_fhm_remove_entry((flat_hash_map_entry_ptr)).impl_ \
649#ifdef FLAT_HASH_MAP_USING_NAMESPACE_CCC
653# define fhm_init(args...) ccc_fhm_init(args)
654# define fhm_static_init(args...) ccc_fhm_static_init(args)
655# define fhm_zero_init(args...) ccc_fhm_zero_init(args)
656# define fhm_copy(args...) ccc_fhm_copy(args)
657# define fhm_and_modify_w(args...) ccc_fhm_and_modify_w(args)
658# define fhm_or_insert_w(args...) ccc_fhm_or_insert_w(args)
659# define fhm_insert_entry_w(args...) ccc_fhm_insert_entry_w(args)
660# define fhm_try_insert_w(args...) ccc_fhm_try_insert_w(args)
661# define fhm_insert_or_assign_w(args...) ccc_fhm_insert_or_assign_w(args)
662# define fhm_contains(args...) ccc_fhm_contains(args)
663# define fhm_get_key_val(args...) ccc_fhm_get_key_val(args)
664# define fhm_remove_r(args...) ccc_fhm_remove_r(args)
665# define fhm_insert_r(args...) ccc_fhm_insert_r(args)
666# define fhm_try_insert_r(args...) ccc_fhm_try_insert_r(args)
667# define fhm_insert_or_assign_r(args...) ccc_fhm_insert_or_assign_r(args)
668# define fhm_remove_entry_r(args...) ccc_fhm_remove_entry_r(args)
669# define fhm_remove(args...) ccc_fhm_remove(args)
670# define fhm_insert(args...) ccc_fhm_insert(args)
671# define fhm_try_insert(args...) ccc_fhm_try_insert(args)
672# define fhm_insert_or_assign(args...) ccc_fhm_insert_or_assign(args)
673# define fhm_remove_entry(args...) ccc_fhm_remove_entry(args)
674# define fhm_entry_r(args...) ccc_fhm_entry_r(args)
675# define fhm_entry(args...) ccc_fhm_entry(args)
676# define fhm_and_modify(args...) ccc_fhm_and_modify(args)
677# define fhm_and_modify_aux(args...) ccc_fhm_and_modify_aux(args)
678# define fhm_or_insert(args...) ccc_fhm_or_insert(args)
679# define fhm_insert_entry(args...) ccc_fhm_insert_entry(args)
680# define fhm_unwrap(args...) ccc_fhm_unwrap(args)
681# define fhm_occupied(args...) ccc_fhm_occupied(args)
682# define fhm_insert_error(args...) ccc_fhm_insert_error(args)
683# define fhm_begin(args...) ccc_fhm_begin(args)
684# define fhm_next(args...) ccc_fhm_next(args)
685# define fhm_end(args...) ccc_fhm_end(args)
686# define fhm_data(args...) ccc_fhm_data(args)
687# define fhm_is_empty(args...) ccc_fhm_is_empty(args)
688# define fhm_size(args...) ccc_fhm_size(args)
689# define fhm_clear(args...) ccc_fhm_clear(args)
690# define fhm_clear_and_free(args...) ccc_fhm_clear_and_free(args)
691# define fhm_next_prime(args...) ccc_fhm_next_prime(args)
692# define fhm_capacity(args...) ccc_fhm_capacity(args)
693# define fhm_validate(args...) ccc_fhm_validate(args)
void * ccc_fhm_next(ccc_flat_hash_map const *h, ccc_fhmap_elem const *iter)
Advances the iterator to the next occupied table slot.
size_t ccc_fhm_next_prime(size_t n)
Helper to find a prime number if needed.
ccc_entry ccc_fhm_insert_or_assign(ccc_flat_hash_map *h, ccc_fhmap_elem *key_val_handle)
Invariantly inserts or overwrites a user struct into the table.
bool ccc_fhm_contains(ccc_flat_hash_map *h, void const *key)
Searches the table for the presence of key.
ccc_fhmap_entry * ccc_fhm_and_modify_aux(ccc_fhmap_entry *e, ccc_update_fn *fn, void *aux)
Modifies the provided entry if it is Occupied.
void * ccc_fhm_begin(ccc_flat_hash_map const *h)
Obtains a pointer to the first element in the table.
ccc_entry ccc_fhm_insert(ccc_flat_hash_map *h, ccc_fhmap_elem *out_handle)
Invariantly inserts the key value wrapping out_handle.
bool ccc_fhm_occupied(ccc_fhmap_entry const *e)
Returns the Vacant or Occupied status of the entry.
size_t ccc_fhm_size(ccc_flat_hash_map const *h)
Returns the size of the table.
ccc_result ccc_fhm_clear_and_free(ccc_flat_hash_map *h, ccc_destructor_fn *fn)
Frees all slots in the table and frees the underlying buffer.
void * ccc_fhm_insert_entry(ccc_fhmap_entry const *e, ccc_fhmap_elem *elem)
Inserts the provided entry invariantly.
ccc_entry_status ccc_fhm_entry_status(ccc_fhmap_entry const *e)
Obtain the entry status from a container entry.
ccc_fhmap_entry * ccc_fhm_and_modify(ccc_fhmap_entry *e, ccc_update_fn *fn)
Modifies the provided entry if it is Occupied.
bool ccc_fhm_is_empty(ccc_flat_hash_map const *h)
Returns the size status of the table.
ccc_result ccc_fhm_copy(ccc_flat_hash_map *dst, ccc_flat_hash_map const *src, ccc_alloc_fn *fn)
Copy the map at source to destination.
ccc_result ccc_fhm_clear(ccc_flat_hash_map *h, ccc_destructor_fn *fn)
Frees all slots in the table for use without affecting capacity.
void * ccc_fhm_get_key_val(ccc_flat_hash_map *h, void const *key)
Returns a reference into the table at entry key.
ccc_entry ccc_fhm_try_insert(ccc_flat_hash_map *h, ccc_fhmap_elem *key_val_handle)
Attempts to insert the key value wrapping key_val_handle.
bool ccc_fhm_insert_error(ccc_fhmap_entry const *e)
Provides the status of the entry should an insertion follow.
ccc_entry ccc_fhm_remove_entry(ccc_fhmap_entry const *e)
Remove the entry from the table if Occupied.
struct ccc_fhmap_elem_ ccc_fhmap_elem
An intrusive element for a user provided type.
Definition: flat_hash_map.h:49
ccc_fhmap_entry ccc_fhm_entry(ccc_flat_hash_map *h, void const *key)
Obtains an entry for the provided key in the table for future use.
void * ccc_fhm_or_insert(ccc_fhmap_entry const *e, ccc_fhmap_elem *elem)
Inserts the struct with handle elem if the entry is Vacant.
void * ccc_fhm_end(ccc_flat_hash_map const *h)
Check the current iterator against the end for loop termination.
void * ccc_fhm_unwrap(ccc_fhmap_entry const *e)
Unwraps the provided entry to obtain a view into the table element.
bool ccc_fhm_validate(ccc_flat_hash_map const *h)
Validation of invariants for the hash table.
union ccc_fhmap_entry_ ccc_fhmap_entry
A container specific entry used to implement the Entry Interface.
Definition: flat_hash_map.h:55
size_t ccc_fhm_capacity(ccc_flat_hash_map const *h)
Return the full capacity of the backing storage.
struct ccc_fhmap_ ccc_flat_hash_map
A container for storing key-value structures defined by the user in a contiguous buffer.
Definition: flat_hash_map.h:43
void * ccc_fhm_data(ccc_flat_hash_map const *h)
Return a reference to the base of backing array. O(1).
ccc_entry ccc_fhm_remove(ccc_flat_hash_map *h, ccc_fhmap_elem *out_handle)
Removes the key value in the map storing the old value, if present, in the struct containing out_hand...
The C Container Collection Fundamental Types.
ccc_result
A result of actions on containers.
Definition: types.h:65
void ccc_update_fn(ccc_user_type)
A callback function for modifying an element in the container.
Definition: types.h:216
union ccc_entry_ ccc_entry
An Occupied or Vacant position in a searchable container.
Definition: types.h:47
void * ccc_alloc_fn(void *ptr, size_t size, void *aux)
An allocation function at the core of all containers.
Definition: types.h:199
enum ccc_entry_status_ ccc_entry_status
The status monitoring and entry state once it is obtained.
Definition: types.h:57
void ccc_destructor_fn(ccc_user_type)
A callback function for destroying an element in the container.
Definition: types.h:234