52#ifndef CCC_HANDLE_REALTIME_ORDERED_MAP_H
53#define CCC_HANDLE_REALTIME_ORDERED_MAP_H
59#include "impl/impl_handle_realtime_ordered_map.h"
154#define ccc_hrm_declare_fixed_map(fixed_map_type_name, key_val_type_name, \
156 ccc_impl_hrm_declare_fixed_map(fixed_map_type_name, key_val_type_name, \
162#define ccc_hrm_fixed_capacity(fixed_map_type_name) \
163 ccc_impl_hrm_fixed_capacity(fixed_map_type_name)
176#define ccc_hrm_init(memory_ptr, any_type_name, key_elem_field, key_cmp_fn, \
177 alloc_fn, aux_data, capacity) \
178 ccc_impl_hrm_init(memory_ptr, any_type_name, key_elem_field, key_cmp_fn, \
179 alloc_fn, aux_data, capacity)
324#define ccc_hrm_as(handle_realtime_ordered_map_ptr, type_name, handle_i...) \
325 ccc_impl_hrm_as(handle_realtime_ordered_map_ptr, type_name, handle_i)
361 void *key_val_type_output);
373#define ccc_hrm_swap_handle_r(handle_realtime_ordered_map_ptr, \
374 key_val_type_output_ptr) \
377 ccc_hrm_swap_handle((handle_realtime_ordered_map_ptr), \
378 (key_val_type_output_ptr)) \
391 void const *key_val_type);
400#define ccc_hrm_try_insert_r(handle_realtime_ordered_map_ptr, \
404 ccc_hrm_try_insert((handle_realtime_ordered_map_ptr), \
405 (key_val_type_ptr)) \
421#define ccc_hrm_try_insert_w(handle_realtime_ordered_map_ptr, key, \
425 ccc_impl_hrm_try_insert_w(handle_realtime_ordered_map_ptr, key, \
439 void const *key_val_type);
453#define ccc_hrm_insert_or_assign_w(handle_realtime_ordered_map_ptr, key, \
457 ccc_impl_hrm_insert_or_assign_w(handle_realtime_ordered_map_ptr, key, \
471 void *key_val_type_output);
482#define ccc_hrm_remove_r(handle_realtime_ordered_map_ptr, \
483 key_val_type_output_ptr) \
486 ccc_hrm_remove((handle_realtime_ordered_map_ptr), \
487 (key_val_type_output_ptr)) \
524#define ccc_hrm_handle_r(handle_realtime_ordered_map_ptr, key_ptr) \
525 &(ccc_hromap_handle) \
527 ccc_hrm_handle((handle_realtime_ordered_map_ptr), (key_ptr)).impl \
578#define ccc_hrm_and_modify_w(handle_realtime_ordered_map_handle_ptr, \
579 type_name, closure_over_T...) \
580 &(ccc_hromap_handle) \
582 ccc_impl_hrm_and_modify_w(handle_realtime_ordered_map_handle_ptr, \
583 type_name, closure_over_T) \
598 void const *key_val_type);
612#define ccc_hrm_or_insert_w(handle_realtime_ordered_map_handle_ptr, \
614 ccc_impl_hrm_or_insert_w(handle_realtime_ordered_map_handle_ptr, \
625 void const *key_val_type);
633#define ccc_hrm_insert_handle_w(handle_realtime_ordered_map_handle_ptr, \
635 ccc_impl_hrm_insert_handle_w(handle_realtime_ordered_map_handle_ptr, \
655#define ccc_hrm_remove_handle_r(handle_realtime_ordered_map_handle_ptr) \
658 ccc_hrm_remove_handle((handle_realtime_ordered_map_handle_ptr)).impl \
777 void const *begin_key,
void const *end_key);
785#define ccc_hrm_equal_range_r(handle_realtime_ordered_map_ptr, \
786 begin_and_end_key_ptrs...) \
789 ccc_hrm_equal_range((handle_realtime_ordered_map_ptr), \
790 (begin_and_end_key_ptrs)) \
816 void const *rbegin_key,
void const *rend_key);
825#define ccc_hrm_equal_rrange_r(handle_realtime_ordered_map_ptr, \
826 rbegin_and_rend_key_ptrs...) \
829 ccc_hrm_equal_rrange((handle_realtime_ordered_map_ptr), \
830 (rbegin_and_rend_key_ptrs)) \
850 void const *key_val_type_iter);
859 void const *key_val_type_iter);
915#ifdef HANDLE_REALTIME_ORDERED_MAP_USING_NAMESPACE_CCC
918# define hrm_declare_fixed_map(args...) ccc_hrm_declare_fixed_map(args)
919# define hrm_init(args...) ccc_hrm_init(args)
920# define hrm_fixed_capacity(args...) ccc_hrm_fixed_capacity(args)
921# define hrm_copy(args...) ccc_hrm_copy(args)
922# define hrm_reserve(args...) ccc_hrm_reserve(args)
923# define hrm_at(args...) ccc_hrm_at(args)
924# define hrm_as(args...) ccc_hrm_as(args)
925# define hrm_and_modify_w(args...) ccc_hrm_and_modify_w(args)
926# define hrm_or_insert_w(args...) ccc_hrm_or_insert_w(args)
927# define hrm_insert_handle_w(args...) ccc_hrm_insert_handle_w(args)
928# define hrm_try_insert_w(args...) ccc_hrm_try_insert_w(args)
929# define hrm_insert_or_assign_w(args...) ccc_hrm_insert_or_assign_w(args)
930# define hrm_contains(args...) ccc_hrm_contains(args)
931# define hrm_get_key_val(args...) ccc_hrm_get_key_val(args)
932# define hrm_swap_handle(args...) ccc_hrm_swap_handle(args)
933# define hrm_swap_handle_r(args...) ccc_hrm_swap_handle_r(args)
934# define hrm_begin(args...) ccc_hrm_begin(args)
935# define hrm_rbegin(args...) ccc_hrm_rbegin(args)
936# define hrm_next(args...) ccc_hrm_next(args)
937# define hrm_rnext(args...) ccc_hrm_rnext(args)
938# define hrm_end(args...) ccc_hrm_end(args)
939# define hrm_rend(args...) ccc_hrm_rend(args)
940# define hrm_data(args...) ccc_hrm_data(args)
941# define hrm_is_empty(args...) ccc_hrm_is_empty(args)
942# define hrm_count(args...) ccc_hrm_count(args)
943# define hrm_clear(args...) ccc_hrm_clear(args)
944# define hrm_clear_and_free(args...) ccc_hrm_clear_and_free(args)
945# define hrm_clear_and_free_reserve(args...) \
946 ccc_hrm_clear_and_free_reserve(args)
947# define hrm_validate(args...) ccc_hrm_validate(args)
ccc_ucount ccc_hrm_capacity(ccc_handle_realtime_ordered_map const *hrm)
Returns the capacity of the map representing total available slots.
ccc_range ccc_hrm_equal_range(ccc_handle_realtime_ordered_map const *hrm, void const *begin_key, void const *end_key)
Return an iterable range of values from [begin_key, end_key). O(lgN).
ccc_result ccc_hrm_clear_and_free(ccc_handle_realtime_ordered_map *hrm, ccc_any_type_destructor_fn *fn)
Frees all slots in the map and frees the underlying buffer.
ccc_handle_i ccc_hrm_unwrap(ccc_hromap_handle const *h)
Unwraps the provided handle to obtain a view into the map element.
ccc_result ccc_hrm_copy(ccc_handle_realtime_ordered_map *dst, ccc_handle_realtime_ordered_map const *src, ccc_any_alloc_fn *fn)
Copy the map at source to destination.
ccc_handle ccc_hrm_insert_or_assign(ccc_handle_realtime_ordered_map *hrm, void const *key_val_type)
Invariantly inserts or overwrites a user struct into the map.
void * ccc_hrm_rend(ccc_handle_realtime_ordered_map const *hrm)
Return the rend of a reverse inorder traversal of the map. O(1).
ccc_rrange ccc_hrm_equal_rrange(ccc_handle_realtime_ordered_map const *hrm, void const *rbegin_key, void const *rend_key)
Return an iterable rrange of values from [begin_key, end_key). O(lg N).
struct ccc_hromap ccc_handle_realtime_ordered_map
A handle realtime ordered map offers O(lg N) search and erase, and amortized O(lg N) insert.
Definition: handle_realtime_ordered_map.h:72
ccc_hromap_handle ccc_hrm_handle(ccc_handle_realtime_ordered_map const *hrm, void const *key)
Obtains a handle for the provided key in the map for future use.
ccc_handle_i ccc_hrm_or_insert(ccc_hromap_handle const *h, void const *key_val_type)
Inserts the provided user type if the handle is Vacant.
void * ccc_hrm_data(ccc_handle_realtime_ordered_map const *hrm)
Return a reference to the base of backing array. O(1).
void * ccc_hrm_begin(ccc_handle_realtime_ordered_map const *hrm)
Return the start of an inorder traversal of the map. O(lg N).
ccc_hromap_handle * ccc_hrm_and_modify(ccc_hromap_handle *h, ccc_any_type_update_fn *fn)
Modifies the provided handle if it is Occupied.
void * ccc_hrm_end(ccc_handle_realtime_ordered_map const *hrm)
Return the end of an inorder traversal of the map. O(1).
ccc_handle ccc_hrm_remove(ccc_handle_realtime_ordered_map *hrm, void *key_val_type_output)
Removes the key value in the map storing the old value, if present, in the struct containing key_val_...
ccc_ucount ccc_hrm_count(ccc_handle_realtime_ordered_map const *hrm)
Returns the count of map occupied slots.
void * ccc_hrm_at(ccc_handle_realtime_ordered_map const *h, ccc_handle_i i)
Returns a reference to the user data at the provided handle.
ccc_result ccc_hrm_reserve(ccc_handle_realtime_ordered_map *hrm, size_t to_add, ccc_any_alloc_fn *fn)
Reserves space for at least to_add more elements.
ccc_handle ccc_hrm_swap_handle(ccc_handle_realtime_ordered_map *hrm, void *key_val_type_output)
Invariantly inserts the key value in key_val_type_output.
void * ccc_hrm_next(ccc_handle_realtime_ordered_map const *hrm, void const *key_val_type_iter)
Return the next element in an inorder traversal of the map. O(1).
void * ccc_hrm_rbegin(ccc_handle_realtime_ordered_map const *hrm)
Return the start of a reverse inorder traversal of the map. O(lg N).
ccc_handle_i ccc_hrm_insert_handle(ccc_hromap_handle const *h, void const *key_val_type)
Inserts the provided user type invariantly.
ccc_result ccc_hrm_clear_and_free_reserve(ccc_handle_realtime_ordered_map *hrm, ccc_any_type_destructor_fn *destructor, ccc_any_alloc_fn *alloc)
Frees all slots in the hrm and frees the underlying buffer that was previously dynamically reserved w...
ccc_tribool ccc_hrm_contains(ccc_handle_realtime_ordered_map const *hrm, void const *key)
Searches the map for the presence of key.
union ccc_hromap_handle ccc_hromap_handle
A container specific handle used to implement the Handle Interface.
Definition: handle_realtime_ordered_map.h:82
ccc_result ccc_hrm_clear(ccc_handle_realtime_ordered_map *hrm, ccc_any_type_destructor_fn *fn)
Frees all slots in the map for use without affecting capacity.
void * ccc_hrm_rnext(ccc_handle_realtime_ordered_map const *hrm, void const *key_val_type_iter)
Return the rnext element in a reverse inorder traversal of the map. O(1).
ccc_handle ccc_hrm_remove_handle(ccc_hromap_handle const *h)
Remove the handle from the map if Occupied.
ccc_tribool ccc_hrm_occupied(ccc_hromap_handle const *h)
Returns the Vacant or Occupied status of the handle.
ccc_handle_status ccc_hrm_handle_status(ccc_hromap_handle const *h)
Obtain the handle status from a container handle.
ccc_tribool ccc_hrm_validate(ccc_handle_realtime_ordered_map const *hrm)
Validation of invariants for the map.
ccc_tribool ccc_hrm_is_empty(ccc_handle_realtime_ordered_map const *hrm)
Returns the size status of the map.
ccc_handle ccc_hrm_try_insert(ccc_handle_realtime_ordered_map *hrm, void const *key_val_type)
Attempts to insert the key value in key_val_type.
ccc_hromap_handle * ccc_hrm_and_modify_aux(ccc_hromap_handle *h, ccc_any_type_update_fn *fn, void *aux)
Modifies the provided handle if it is Occupied.
ccc_tribool ccc_hrm_insert_error(ccc_hromap_handle const *h)
Provides the status of the handle should an insertion follow.
ccc_handle_i ccc_hrm_get_key_val(ccc_handle_realtime_ordered_map const *hrm, void const *key)
Returns a reference into the map at handle 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