47#ifndef CCC_HANDLE_ORDERED_MAP_H
48#define CCC_HANDLE_ORDERED_MAP_H
54#include "impl/impl_handle_ordered_map.h"
145#define ccc_hom_declare_fixed_map(fixed_map_type_name, key_val_type_name, \
147 ccc_impl_hom_declare_fixed_map(fixed_map_type_name, key_val_type_name, \
153#define ccc_hom_fixed_capacity(fixed_map_type_name) \
154 ccc_impl_hom_fixed_capacity(fixed_map_type_name)
167#define ccc_hom_init(memory_ptr, any_type_name, key_elem_field, key_cmp_fn, \
168 alloc_fn, aux_data, capacity) \
169 ccc_impl_hom_init(memory_ptr, any_type_name, key_elem_field, key_cmp_fn, \
170 alloc_fn, aux_data, capacity)
315#define ccc_hom_as(handle_ordered_map_ptr, type_name, handle_i...) \
316 ccc_impl_hom_as(handle_ordered_map_ptr, type_name, handle_i)
351 void *key_val_output);
364#define ccc_hom_swap_handle_r(handle_ordered_map_ptr, key_val_output_ptr) \
367 ccc_hom_swap_handle((handle_ordered_map_ptr), (key_val_output_ptr)) \
379 void const *key_val_type);
388#define ccc_hom_try_insert_r(handle_ordered_map_ptr, key_val_type_ptr) \
391 ccc_hom_try_insert((handle_ordered_map_ptr), (key_val_type_ptr)).impl \
406#define ccc_hom_try_insert_w(handle_ordered_map_ptr, key, lazy_value...) \
409 ccc_impl_hom_try_insert_w(handle_ordered_map_ptr, key, lazy_value) \
421 void const *key_val_type);
435#define ccc_hom_insert_or_assign_w(handle_ordered_map_ptr, key, lazy_value...) \
438 ccc_impl_hom_insert_or_assign_w(handle_ordered_map_ptr, key, \
453 void *key_val_output);
465#define ccc_hom_remove_r(handle_ordered_map_ptr, key_val_output_ptr) \
468 ccc_hom_remove((handle_ordered_map_ptr), (key_val_output_ptr)).impl \
504#define ccc_hom_handle_r(handle_ordered_map_ptr, key_ptr) \
505 &(ccc_homap_handle) \
507 ccc_hom_handle((handle_ordered_map_ptr), (key_ptr)).impl \
560#define ccc_hom_and_modify_w(handle_ordered_map_handle_ptr, type_name, \
562 &(ccc_homap_handle) \
564 ccc_impl_hom_and_modify_w(handle_ordered_map_handle_ptr, type_name, \
580 void const *key_val_type);
593#define ccc_hom_or_insert_w(handle_ordered_map_handle_ptr, lazy_key_value...) \
594 ccc_impl_hom_or_insert_w(handle_ordered_map_handle_ptr, lazy_key_value)
604 void const *key_val_type);
611#define ccc_hom_insert_handle_w(handle_ordered_map_handle_ptr, \
613 ccc_impl_hom_insert_handle_w(handle_ordered_map_handle_ptr, lazy_key_value)
627#define ccc_hom_remove_handle_r(handle_ordered_map_handle_ptr) \
630 ccc_hom_remove_handle((handle_ordered_map_handle_ptr)).impl \
689 void const *begin_key,
690 void const *end_key);
698#define ccc_hom_equal_range_r(handle_ordered_map_ptr, \
699 begin_and_end_key_ptrs...) \
702 ccc_hom_equal_range(handle_ordered_map_ptr, begin_and_end_key_ptrs) \
727 void const *rbegin_key,
728 void const *rend_key);
737#define ccc_hom_equal_rrange_r(handle_ordered_map_ptr, \
738 rbegin_and_rend_key_ptrs...) \
741 ccc_hom_equal_rrange(handle_ordered_map_ptr, rbegin_and_rend_key_ptrs) \
763 void const *iter_handle);
772 void const *iter_handle);
886#ifdef HANDLE_ORDERED_MAP_USING_NAMESPACE_CCC
889# define hom_declare_fixed_map(args...) ccc_hom_declare_fixed_map(args)
890# define hom_fixed_capacity(args...) ccc_hom_fixed_capacity(args)
891# define hom_init(args...) ccc_hom_init(args)
892# define hom_at(args...) ccc_hom_at(args)
893# define hom_as(args...) ccc_hom_as(args)
894# define hom_and_modify_w(args...) ccc_hom_and_modify_w(args)
895# define hom_or_insert_w(args...) ccc_hom_or_insert_w(args)
896# define hom_insert_handle_w(args...) ccc_hom_insert_handle_w(args)
897# define hom_try_insert_w(args...) ccc_hom_try_insert_w(args)
898# define hom_insert_or_assign_w(args...) ccc_hom_insert_or_assign_w(args)
899# define hom_copy(args...) ccc_hom_copy(args)
900# define hom_reserve(args...) ccc_hom_reserve(args)
901# define hom_contains(args...) ccc_hom_contains(args)
902# define hom_get_key_val(args...) ccc_hom_get_key_val(args)
903# define hom_swap_handle_r(args...) ccc_hom_swap_handle_r(args)
904# define hom_try_insert_r(args...) ccc_hom_try_insert_r(args)
905# define hom_remove_r(args...) ccc_hom_remove_r(args)
906# define hom_remove_handle_r(args...) ccc_hom_remove_handle_r(args)
907# define hom_swap_handle(args...) ccc_hom_swap_handle(args)
908# define hom_try_insert(args...) ccc_hom_try_insert(args)
909# define hom_insert_or_assign(args...) ccc_hom_insert_or_assign(args)
910# define hom_remove(args...) ccc_hom_remove(args)
911# define hom_remove_handle(args...) ccc_hom_remove_handle(args)
912# define hom_handle_r(args...) ccc_hom_handle_r(args)
913# define hom_handle(args...) ccc_hom_handle(args)
914# define hom_and_modify(args...) ccc_hom_and_modify(args)
915# define hom_and_modify_aux(args...) ccc_hom_and_modify_aux(args)
916# define hom_or_insert(args...) ccc_hom_or_insert(args)
917# define hom_insert_handle(args...) ccc_hom_insert_handle(args)
918# define hom_unwrap(args...) ccc_hom_unwrap(args)
919# define hom_insert_error(args...) ccc_hom_insert_error(args)
920# define hom_occupied(args...) ccc_hom_occupied(args)
921# define hom_clear(args...) ccc_hom_clear(args)
922# define hom_clear_and_free(args...) ccc_hom_clear_and_free(args)
923# define hom_clear_and_free_reserve(args...) \
924 ccc_hom_clear_and_free_reserve(args)
925# define hom_begin(args...) ccc_hom_begin(args)
926# define hom_rbegin(args...) ccc_hom_rbegin(args)
927# define hom_end(args...) ccc_hom_end(args)
928# define hom_rend(args...) ccc_hom_rend(args)
929# define hom_next(args...) ccc_hom_next(args)
930# define hom_rnext(args...) ccc_hom_rnext(args)
931# define hom_data(args...) ccc_hom_data(args)
932# define hom_size(args...) ccc_hom_size(args)
933# define hom_is_empty(args...) ccc_hom_is_empty(args)
934# define hom_validate(args...) ccc_hom_validate(args)
void * ccc_hom_rnext(ccc_handle_ordered_map const *hom, void const *iter_handle)
Return the rnext element in a reverse inorder traversal of the map. O(1).
void * ccc_hom_data(ccc_handle_ordered_map const *hom)
Return a reference to the base of backing array. O(1).
ccc_tribool ccc_hom_is_empty(ccc_handle_ordered_map const *hom)
Returns the size status of the map.
ccc_handle ccc_hom_try_insert(ccc_handle_ordered_map *hom, void const *key_val_type)
Attempts to insert the key value wrapping key_val_type.
ccc_rrange ccc_hom_equal_rrange(ccc_handle_ordered_map *hom, void const *rbegin_key, void const *rend_key)
Return an iterable rrange of values from [rbegin_key, end_key). Amortized O(lg N).
void * ccc_hom_rbegin(ccc_handle_ordered_map const *hom)
Return the start of a reverse inorder traversal of the map. Amortized O(lg N).
union ccc_homap_handle ccc_homap_handle
A container specific handle used to implement the Handle Interface.
Definition: handle_ordered_map.h:73
ccc_homap_handle * ccc_hom_and_modify(ccc_homap_handle *h, ccc_any_type_update_fn *fn)
Modifies the provided handle if it is Occupied.
ccc_handle ccc_hom_insert_or_assign(ccc_handle_ordered_map *hom, void const *key_val_type)
Invariantly inserts or overwrites a user struct into the map.
ccc_handle_i ccc_hom_get_key_val(ccc_handle_ordered_map *hom, void const *key)
Returns a reference into the map at handle key.
ccc_result ccc_hom_copy(ccc_handle_ordered_map *dst, ccc_handle_ordered_map const *src, ccc_any_alloc_fn *fn)
Copy the map at source to destination.
ccc_result ccc_hom_clear_and_free_reserve(ccc_handle_ordered_map *hom, ccc_any_type_destructor_fn *destructor, ccc_any_alloc_fn *alloc)
Frees all slots in the hom and frees the underlying buffer that was previously dynamically reserved w...
ccc_handle_i ccc_hom_or_insert(ccc_homap_handle const *h, void const *key_val_type)
Inserts the struct with user type if the handle is Vacant.
ccc_ucount ccc_hom_capacity(ccc_handle_ordered_map const *hom)
Returns the capacity of the map representing total possible slots.
ccc_handle_status ccc_hom_handle_status(ccc_homap_handle const *h)
Obtain the handle status from a container handle.
void * ccc_hom_begin(ccc_handle_ordered_map const *hom)
Return the start of an inorder traversal of the map. Amortized O(lg N).
ccc_handle_i ccc_hom_unwrap(ccc_homap_handle const *h)
Unwraps the provided handle to obtain a view into the map element.
struct ccc_homap ccc_handle_ordered_map
A self-optimizing data structure offering amortized O(lg N) search, insert, and erase.
Definition: handle_ordered_map.h:67
void * ccc_hom_rend(ccc_handle_ordered_map const *hom)
Return the rend of a reverse inorder traversal of the map. O(1).
ccc_handle_i ccc_hom_insert_handle(ccc_homap_handle const *h, void const *key_val_type)
Inserts the provided handle invariantly.
ccc_tribool ccc_hom_validate(ccc_handle_ordered_map const *hom)
Validation of invariants for the map.
ccc_handle ccc_hom_remove(ccc_handle_ordered_map *hom, void *key_val_output)
Removes the key value in the map storing the old value, if present, in the struct containing key_val_...
void * ccc_hom_at(ccc_handle_ordered_map const *h, ccc_handle_i i)
Returns a reference to the user data at the provided handle.
ccc_homap_handle * ccc_hom_and_modify_aux(ccc_homap_handle *h, ccc_any_type_update_fn *fn, void *aux)
Modifies the provided handle if it is Occupied.
ccc_homap_handle ccc_hom_handle(ccc_handle_ordered_map *hom, void const *key)
Obtains a handle for the provided key in the map for future use.
void * ccc_hom_end(ccc_handle_ordered_map const *hom)
Return the end of an inorder traversal of the map. O(1).
ccc_handle ccc_hom_remove_handle(ccc_homap_handle *h)
Remove the handle from the map if Occupied.
ccc_tribool ccc_hom_insert_error(ccc_homap_handle const *h)
Provides the status of the handle should an insertion follow.
ccc_result ccc_hom_clear(ccc_handle_ordered_map *hom, ccc_any_type_destructor_fn *fn)
Frees all slots in the map for use without affecting capacity.
void * ccc_hom_next(ccc_handle_ordered_map const *hom, void const *iter_handle)
Return the next element in an inorder traversal of the map. O(1).
ccc_result ccc_hom_clear_and_free(ccc_handle_ordered_map *hom, ccc_any_type_destructor_fn *fn)
Frees all slots in the map and frees the underlying buffer.
ccc_handle ccc_hom_swap_handle(ccc_handle_ordered_map *hom, void *key_val_output)
Invariantly inserts the key value wrapping key_val_type.
ccc_range ccc_hom_equal_range(ccc_handle_ordered_map *hom, void const *begin_key, void const *end_key)
Return an iterable range of values from [begin_key, end_key). Amortized O(lg N).
ccc_result ccc_hom_reserve(ccc_handle_ordered_map *hom, size_t to_add, ccc_any_alloc_fn *fn)
Reserves space for at least to_add more elements.
ccc_ucount ccc_hom_size(ccc_handle_ordered_map const *hom)
Returns the size of the map representing active slots.
ccc_tribool ccc_hom_occupied(ccc_homap_handle const *h)
Returns the Vacant or Occupied status of the handle.
ccc_tribool ccc_hom_contains(ccc_handle_ordered_map *hom, void const *key)
Searches the map for the presence of key.
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:187
#define ccc_handle(container_ptr, key_ptr...)
Obtain a container specific handle for the handle Interface.
Definition: traits.h:150
The C Container Collection Fundamental Types.
size_t ccc_handle_i
A stable index to user data in a container that uses a flat array as the underlying storage method.
Definition: types.h:93
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
enum ccc_entry_status ccc_handle_status
The status monitoring and handle state once it is obtained.
Definition: types.h:103
ccc_result
A result of actions on containers.
Definition: types.h:132
union ccc_range ccc_range
The result of a range query on iterable containers.
Definition: types.h:44
union ccc_rrange ccc_rrange
The result of a rrange query on iterable containers.
Definition: types.h:52
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