21#ifndef CCC_ORDERED_MAP_H
22#define CCC_ORDERED_MAP_H
28#include "impl/impl_ordered_map.h"
74#define ccc_om_init(om_name, struct_name, om_elem_field, key_elem_field, \
75 key_cmp, alloc_fn, aux) \
76 ccc_impl_om_init(om_name, struct_name, om_elem_field, key_elem_field, \
77 key_cmp, alloc_fn, aux)
134#define ccc_om_swap_entry_r(ordered_map_ptr, key_val_handle_ptr, tmp_ptr) \
137 ccc_om_swap_entry((ordered_map_ptr), (key_val_handle_ptr), (tmp_ptr)) \
159#define ccc_om_try_insert_r(ordered_map_ptr, key_val_handle_ptr) \
162 ccc_om_try_insert((ordered_map_ptr), (key_val_handle_ptr)).impl_ \
177#define ccc_om_try_insert_w(ordered_map_ptr, key, lazy_value...) \
180 ccc_impl_om_try_insert_w(ordered_map_ptr, key, lazy_value) \
206#define ccc_om_insert_or_assign_w(ordered_map_ptr, key, lazy_value...) \
209 ccc_impl_om_insert_or_assign_w(ordered_map_ptr, key, lazy_value) \
245#define ccc_om_remove_r(ordered_map_ptr, out_handle_ptr) \
248 ccc_om_remove((ordered_map_ptr), (out_handle_ptr)).impl_ \
282#define ccc_om_entry_r(ordered_map_ptr, key_ptr) \
285 ccc_om_entry((ordered_map_ptr), (key_ptr)).impl_ \
336#define ccc_om_and_modify_w(ordered_map_entry_ptr, type_name, \
340 ccc_impl_om_and_modify_w(ordered_map_entry_ptr, type_name, \
369#define ccc_om_or_insert_w(ordered_map_entry_ptr, lazy_key_value...) \
370 ccc_impl_om_or_insert_w(ordered_map_entry_ptr, lazy_key_value)
387#define ccc_om_insert_entry_w(ordered_map_entry_ptr, lazy_key_value...) \
388 ccc_impl_om_insert_entry_w(ordered_map_entry_ptr, lazy_key_value)
412#define ccc_om_remove_entry_r(ordered_map_entry_ptr) \
415 ccc_om_remove_entry((ordered_map_entry_ptr)).impl_ \
473 void const *begin_key,
474 void const *end_key);
483#define ccc_om_equal_range_r(ordered_map_ptr, begin_and_end_key_ptrs...) \
486 ccc_om_equal_range(ordered_map_ptr, begin_and_end_key_ptrs).impl_ \
510 void const *rbegin_key,
511 void const *rend_key);
520#define ccc_om_equal_rrange_r(ordered_map_ptr, rbegin_and_rend_key_ptrs...) \
523 ccc_om_equal_rrange(ordered_map_ptr, rbegin_and_rend_key_ptrs).impl_ \
613#ifdef ORDERED_MAP_USING_NAMESPACE_CCC
617# define om_init(args...) ccc_om_init(args)
618# define om_and_modify_w(args...) ccc_om_and_modify_w(args)
619# define om_or_insert_w(args...) ccc_om_or_insert_w(args)
620# define om_insert_entry_w(args...) ccc_om_insert_entry_w(args)
621# define om_try_insert_w(args...) ccc_om_try_insert_w(args)
622# define om_insert_or_assign_w(args...) ccc_om_insert_or_assign_w(args)
623# define om_swap_entry_r(args...) ccc_om_swap_entry_r(args)
624# define om_remove_r(args...) ccc_om_remove_r(args)
625# define om_remove_entry_r(args...) ccc_om_remove_entry_r(args)
626# define om_entry_r(args...) ccc_om_entry_r(args)
627# define om_and_modify_r(args...) ccc_om_and_modify_r(args)
628# define om_and_modify_aux_r(args...) ccc_om_and_modify_aux_r(args)
629# define om_contains(args...) ccc_om_contains(args)
630# define om_get_key_val(args...) ccc_om_get_key_val(args)
631# define om_get_mut(args...) ccc_om_get_mut(args)
632# define om_swap_entry(args...) ccc_om_swap_entry(args)
633# define om_remove(args...) ccc_om_remove(args)
634# define om_entry(args...) ccc_om_entry(args)
635# define om_remove_entry(args...) ccc_om_remove_entry(args)
636# define om_or_insert(args...) ccc_om_or_insert(args)
637# define om_insert_entry(args...) ccc_om_insert_entry(args)
638# define om_unwrap(args...) ccc_om_unwrap(args)
639# define om_unwrap_mut(args...) ccc_om_unwrap_mut(args)
640# define om_begin(args...) ccc_om_begin(args)
641# define om_next(args...) ccc_om_next(args)
642# define om_rbegin(args...) ccc_om_rbegin(args)
643# define om_rnext(args...) ccc_om_rnext(args)
644# define om_end(args...) ccc_om_end(args)
645# define om_rend(args...) ccc_om_rend(args)
646# define om_size(args...) ccc_om_size(args)
647# define om_is_empty(args...) ccc_om_is_empty(args)
648# define om_clear(args...) ccc_om_clear(args)
649# define om_validate(args...) ccc_om_validate(args)
ccc_tribool ccc_om_validate(ccc_ordered_map const *om)
Validation of invariants for the map.
ccc_entry ccc_om_try_insert(ccc_ordered_map *om, ccc_omap_elem *key_val_handle)
Attempts to insert the key value wrapping key_val_handle.
ccc_entry ccc_om_remove(ccc_ordered_map *om, ccc_omap_elem *out_handle)
Removes the key value in the map storing the old value, if present, in the struct containing out_hand...
ccc_range ccc_om_equal_range(ccc_ordered_map *om, void const *begin_key, void const *end_key)
Return an iterable range of values from [begin_key, end_key). Amortized O(lg N).
struct ccc_omap_elem_ ccc_omap_elem
The intrusive element for the user defined struct being stored in the map.
Definition: ordered_map.h:50
ccc_tribool ccc_om_insert_error(ccc_omap_entry const *e)
Provides the status of the entry should an insertion follow.
void * ccc_om_rend(ccc_ordered_map const *om)
Return the rend of a reverse inorder traversal of the map. O(1).
void * ccc_om_rnext(ccc_ordered_map const *om, ccc_omap_elem const *iter_handle)
Return the rnext element in a reverse inorder traversal of the map. O(1).
ccc_ucount ccc_om_size(ccc_ordered_map const *om)
Returns the size of the map.
ccc_entry_status ccc_om_entry_status(ccc_omap_entry const *e)
Obtain the entry status from a container entry.
ccc_tribool ccc_om_occupied(ccc_omap_entry const *e)
Returns the Vacant or Occupied status of the entry.
ccc_tribool ccc_om_contains(ccc_ordered_map *om, void const *key)
Searches the map for the presence of key.
void * ccc_om_rbegin(ccc_ordered_map const *om)
Return the start of a reverse inorder traversal of the map. Amortized O(lg N).
ccc_entry ccc_om_insert_or_assign(ccc_ordered_map *om, ccc_omap_elem *key_val_handle)
Invariantly inserts or overwrites a user struct into the map.
void * ccc_om_unwrap(ccc_omap_entry const *e)
Unwraps the provided entry to obtain a view into the map element.
void * ccc_om_begin(ccc_ordered_map const *om)
Return the start of an inorder traversal of the map. Amortized O(lg N).
ccc_omap_entry * ccc_om_and_modify(ccc_omap_entry *e, ccc_update_fn *fn)
Modifies the provided entry if it is Occupied.
void * ccc_om_or_insert(ccc_omap_entry const *e, ccc_omap_elem *elem)
Inserts the struct with handle elem if the entry is Vacant.
void * ccc_om_next(ccc_ordered_map const *om, ccc_omap_elem const *iter_handle)
Return the next element in an inorder traversal of the map. O(1).
ccc_result ccc_om_clear(ccc_ordered_map *om, ccc_destructor_fn *destructor)
Pops every element from the map calling destructor if destructor is non-NULL. O(N).
void * ccc_om_get_key_val(ccc_ordered_map *om, void const *key)
Returns a reference into the map at entry key.
struct ccc_omap_ ccc_ordered_map
A self-optimizing data structure offering amortized O(lg N) search, insert, and erase and pointer sta...
Definition: ordered_map.h:41
ccc_rrange ccc_om_equal_rrange(ccc_ordered_map *om, void const *rbegin_key, void const *rend_key)
Return an iterable rrange of values from [begin_key, end_key). Amortized O(lg N).
ccc_entry ccc_om_swap_entry(ccc_ordered_map *om, ccc_omap_elem *key_val_handle, ccc_omap_elem *tmp)
Invariantly inserts the key value wrapping key_val_handle.
ccc_tribool ccc_om_is_empty(ccc_ordered_map const *om)
Returns the size status of the map.
void * ccc_om_insert_entry(ccc_omap_entry const *e, ccc_omap_elem *elem)
Inserts the provided entry invariantly.
ccc_omap_entry * ccc_om_and_modify_aux(ccc_omap_entry *e, ccc_update_fn *fn, void *aux)
Modifies the provided entry if it is Occupied.
ccc_entry ccc_om_remove_entry(ccc_omap_entry *e)
Remove the entry from the map if Occupied.
void * ccc_om_end(ccc_ordered_map const *om)
Return the end of an inorder traversal of the map. O(1).
ccc_omap_entry ccc_om_entry(ccc_ordered_map *om, void const *key)
Obtains an entry for the provided key in the map for future use.
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:172
The C Container Collection Fundamental Types.
void ccc_update_fn(ccc_user_type)
A callback function for modifying an element in the container.
Definition: types.h:300
union ccc_range_ ccc_range
The result of a range query on iterable containers.
Definition: types.h:29
ccc_result
A result of actions on containers.
Definition: types.h:117
union ccc_entry_ ccc_entry
An Occupied or Vacant position in a searchable container.
Definition: types.h:46
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:102
enum ccc_entry_status_ ccc_entry_status
The status monitoring and entry state once it is obtained.
Definition: types.h:56
void ccc_destructor_fn(ccc_user_type)
A callback function for destroying an element in the container.
Definition: types.h:318
union ccc_rrange_ ccc_rrange
The result of a rrange query on iterable containers.
Definition: types.h:37
Definition: impl_ordered_map.h:42