40#ifndef CCC_FLAT_HASH_MAP_H
41#define CCC_FLAT_HASH_MAP_H
47#include "impl/impl_flat_hash_map.h"
139#define ccc_fhm_declare_fixed_map(fixed_map_type_name, key_val_type_name, \
141 ccc_impl_fhm_declare_fixed_map(fixed_map_type_name, key_val_type_name, \
148#define ccc_fhm_fixed_capacity(fixed_map_type_name) \
149 ccc_impl_fhm_fixed_capacity(fixed_map_type_name)
213#define ccc_fhm_init(map_ptr, any_type_name, key_field, hash_fn, key_eq_fn, \
214 alloc_fn, aux_data, capacity) \
215 ccc_impl_fhm_init(map_ptr, any_type_name, key_field, hash_fn, key_eq_fn, \
216 alloc_fn, aux_data, capacity)
429#define ccc_fhm_entry_r(map_ptr, key_ptr) \
432 ccc_fhm_entry(map_ptr, key_ptr).impl \
483#define ccc_fhm_and_modify_w(map_entry_ptr, type_name, closure_over_T...) \
486 ccc_impl_fhm_and_modify_w(map_entry_ptr, type_name, closure_over_T) \
499 void const *key_val_type);
512#define ccc_fhm_or_insert_w(map_entry_ptr, lazy_key_value...) \
513 ccc_impl_fhm_or_insert_w(map_entry_ptr, lazy_key_value)
527 void const *key_val_type);
534#define ccc_fhm_insert_entry_w(map_entry_ptr, lazy_key_value...) \
535 ccc_impl_fhm_insert_entry_w(map_entry_ptr, lazy_key_value)
561#define ccc_fhm_swap_entry_r(map_ptr, key_val_type_ptr) \
564 ccc_fhm_swap_entry(map_ptr, key_val_type_ptr).impl \
578#define ccc_fhm_remove_entry_r(map_entry_ptr) \
581 ccc_fhm_remove_entry(map_entry_ptr).impl \
606#define ccc_fhm_try_insert_r(map_ptr, key_val_type_ptr) \
609 ccc_fhm_try_insert(map_ptr, key_val_type_ptr).impl \
627#define ccc_fhm_try_insert_w(map_ptr, key, lazy_value...) \
630 ccc_impl_fhm_try_insert_w(map_ptr, key, lazy_value) \
652#define ccc_fhm_insert_or_assign_r(map_ptr, key_val_type_ptr) \
655 ccc_fhm_insert_or_assign(map_ptr, key_val_type_ptr).impl \
670#define ccc_fhm_insert_or_assign_w(map_ptr, key, lazy_value...) \
673 ccc_impl_fhm_insert_or_assign_w(map_ptr, key, lazy_value) \
689 void *key_val_type_output);
704#define ccc_fhm_remove_r(map_ptr, key_val_type_output_ptr) \
707 ccc_fhm_remove(map_ptr, key_val_type_output_ptr).impl \
828 void const *key_val_type_iter);
876#ifdef FLAT_HASH_MAP_USING_NAMESPACE_CCC
879# define fhm_declare_fixed_map(args...) ccc_fhm_declare_fixed_map(args)
880# define fhm_fixed_capacity(args...) ccc_fhm_fixed_capacity(args)
881# define fhm_reserve(args...) ccc_fhm_reserve(args)
882# define fhm_init(args...) ccc_fhm_init(args)
883# define fhm_copy(args...) ccc_fhm_copy(args)
884# define fhm_and_modify_w(args...) ccc_fhm_and_modify_w(args)
885# define fhm_or_insert_w(args...) ccc_fhm_or_insert_w(args)
886# define fhm_insert_entry_w(args...) ccc_fhm_insert_entry_w(args)
887# define fhm_try_insert_w(args...) ccc_fhm_try_insert_w(args)
888# define fhm_insert_or_assign_w(args...) ccc_fhm_insert_or_assign_w(args)
889# define fhm_contains(args...) ccc_fhm_contains(args)
890# define fhm_get_key_val(args...) ccc_fhm_get_key_val(args)
891# define fhm_remove_r(args...) ccc_fhm_remove_r(args)
892# define fhm_swap_entry_r(args...) ccc_fhm_swap_entry_r(args)
893# define fhm_try_insert_r(args...) ccc_fhm_try_insert_r(args)
894# define fhm_insert_or_assign_r(args...) ccc_fhm_insert_or_assign_r(args)
895# define fhm_remove_entry_r(args...) ccc_fhm_remove_entry_r(args)
896# define fhm_remove(args...) ccc_fhm_remove(args)
897# define fhm_swap_entry(args...) ccc_fhm_swap_entry(args)
898# define fhm_try_insert(args...) ccc_fhm_try_insert(args)
899# define fhm_insert_or_assign(args...) ccc_fhm_insert_or_assign(args)
900# define fhm_remove_entry(args...) ccc_fhm_remove_entry(args)
901# define fhm_entry_r(args...) ccc_fhm_entry_r(args)
902# define fhm_entry(args...) ccc_fhm_entry(args)
903# define fhm_and_modify(args...) ccc_fhm_and_modify(args)
904# define fhm_and_modify_aux(args...) ccc_fhm_and_modify_aux(args)
905# define fhm_or_insert(args...) ccc_fhm_or_insert(args)
906# define fhm_insert_entry(args...) ccc_fhm_insert_entry(args)
907# define fhm_unwrap(args...) ccc_fhm_unwrap(args)
908# define fhm_occupied(args...) ccc_fhm_occupied(args)
909# define fhm_insert_error(args...) ccc_fhm_insert_error(args)
910# define fhm_begin(args...) ccc_fhm_begin(args)
911# define fhm_next(args...) ccc_fhm_next(args)
912# define fhm_end(args...) ccc_fhm_end(args)
913# define fhm_data(args...) ccc_fhm_data(args)
914# define fhm_is_empty(args...) ccc_fhm_is_empty(args)
915# define fhm_size(args...) ccc_fhm_size(args)
916# define fhm_clear(args...) ccc_fhm_clear(args)
917# define fhm_clear_and_free(args...) ccc_fhm_clear_and_free(args)
918# define fhm_clear_and_free_reserve(args...) \
919 ccc_fhm_clear_and_free_reserve(args)
920# define fhm_capacity(args...) ccc_fhm_capacity(args)
921# define fhm_validate(args...) ccc_fhm_validate(args)
ccc_entry ccc_fhm_try_insert(ccc_flat_hash_map *h, void *key_val_type)
Attempts to insert the key value wrapping key_val_handle.
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:59
void * ccc_fhm_begin(ccc_flat_hash_map const *h)
Obtains a pointer to the first element in the table.
ccc_fhmap_entry * ccc_fhm_and_modify(ccc_fhmap_entry *e, ccc_any_type_update_fn *fn)
Modifies the provided entry if it is Occupied.
union ccc_fhmap_entry ccc_fhmap_entry
A container specific entry used to implement the Entry Interface.
Definition: flat_hash_map.h:65
ccc_fhmap_entry * ccc_fhm_and_modify_aux(ccc_fhmap_entry *e, ccc_any_type_update_fn *fn, void *aux)
Modifies the provided entry if it is Occupied.
void * ccc_fhm_get_key_val(ccc_flat_hash_map const *h, void const *key)
Returns a reference into the table at entry key.
ccc_tribool ccc_fhm_is_empty(ccc_flat_hash_map const *h)
Returns the size status of the table.
ccc_tribool ccc_fhm_contains(ccc_flat_hash_map const *h, void const *key)
Searches the table for the presence of key.
void * ccc_fhm_next(ccc_flat_hash_map const *h, void const *key_val_type_iter)
Advances the iterator to the next occupied table slot.
ccc_entry_status ccc_fhm_entry_status(ccc_fhmap_entry const *e)
Obtain the entry status from a container entry.
void * ccc_fhm_or_insert(ccc_fhmap_entry const *e, void const *key_val_type)
Inserts the struct with handle elem if the entry is Vacant.
ccc_entry ccc_fhm_insert_or_assign(ccc_flat_hash_map *h, void *key_val_type)
Invariantly inserts or overwrites a user struct into the table.
ccc_result ccc_fhm_copy(ccc_flat_hash_map *dst, ccc_flat_hash_map const *src, ccc_any_alloc_fn *fn)
Copy the map at source to destination.
ccc_ucount ccc_fhm_size(ccc_flat_hash_map const *h)
Returns the size of the table representing active slots.
ccc_entry ccc_fhm_swap_entry(ccc_flat_hash_map *h, void *key_val_type_output)
Invariantly inserts the key value wrapping out_handle.
ccc_result ccc_fhm_clear(ccc_flat_hash_map *h, ccc_any_type_destructor_fn *fn)
Frees all slots in the table for use without affecting capacity.
ccc_tribool ccc_fhm_insert_error(ccc_fhmap_entry const *e)
Provides the status of the entry should an insertion follow.
ccc_tribool ccc_fhm_validate(ccc_flat_hash_map const *h)
Validation of invariants for the hash table.
ccc_entry ccc_fhm_remove(ccc_flat_hash_map *h, void *key_val_type_output)
Removes the key value in the map storing the old value, if present, in the struct containing out_hand...
ccc_result ccc_fhm_clear_and_free(ccc_flat_hash_map *h, ccc_any_type_destructor_fn *fn)
Frees all slots in the table and frees the underlying buffer.
ccc_ucount ccc_fhm_capacity(ccc_flat_hash_map const *h)
Return the full capacity of the backing storage.
ccc_tribool ccc_fhm_occupied(ccc_fhmap_entry const *e)
Returns the Vacant or Occupied status of the entry.
void * ccc_fhm_insert_entry(ccc_fhmap_entry const *e, void const *key_val_type)
Inserts the provided entry invariantly.
ccc_entry ccc_fhm_remove_entry(ccc_fhmap_entry const *e)
Remove the entry from the table if Occupied.
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_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.
void * ccc_fhm_data(ccc_flat_hash_map const *h)
Return a reference to the base of backing array. O(1).
ccc_result ccc_fhm_clear_and_free_reserve(ccc_flat_hash_map *h, ccc_any_type_destructor_fn *destructor, ccc_any_alloc_fn *alloc)
Frees all slots in the table and frees the underlying buffer that was previously dynamically reserved...
ccc_result ccc_fhm_reserve(ccc_flat_hash_map *h, size_t to_add, ccc_any_alloc_fn *fn)
Reserve space required to add a specified number of elements to the map. If the current capacity is s...
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:187
#define ccc_entry(container_ptr, key_ptr...)
Obtain a container specific entry for the Entry Interface.
Definition: traits.h:141
The C Container Collection Fundamental Types.
void * ccc_any_alloc_fn(void *ptr, size_t size, void *aux)
An allocation function at the core of all containers.
Definition: types.h:312
ccc_result
A result of actions on containers.
Definition: types.h:132
ccc_tribool
A three state boolean to allow for an error state. Error is -1, False is 0, and True is 1.
Definition: types.h:117
void ccc_any_type_destructor_fn(ccc_any_type)
A callback function for destroying an element in the container.
Definition: types.h:347
void ccc_any_type_update_fn(ccc_any_type)
A callback function for modifying an element in the container.
Definition: types.h:329