21#ifndef CCC_ORDERED_MAP_H
22#define CCC_ORDERED_MAP_H
29#include "impl/impl_ordered_map.h"
75#define ccc_om_init(om_name, struct_name, om_elem_field, key_elem_field, \
76 alloc_fn, key_cmp, aux) \
77 ccc_impl_om_init(om_name, struct_name, om_elem_field, key_elem_field, \
78 alloc_fn, key_cmp, aux)
134#define ccc_om_insert_r(ordered_map_ptr, key_val_handle_ptr, tmp_ptr) \
137 ccc_om_insert((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_ \
472 void const *begin_key,
473 void const *end_key);
482#define ccc_om_equal_range_r(ordered_map_ptr, begin_and_end_key_ptrs...) \
485 ccc_om_equal_range(ordered_map_ptr, begin_and_end_key_ptrs).impl_ \
509 void const *rbegin_key,
510 void const *rend_key);
519#define ccc_om_equal_rrange_r(ordered_map_ptr, rbegin_and_rend_key_ptrs...) \
522 ccc_om_equal_rrange(ordered_map_ptr, rbegin_and_rend_key_ptrs).impl_ \
611#ifdef ORDERED_MAP_USING_NAMESPACE_CCC
615# define om_init(args...) ccc_om_init(args)
616# define om_and_modify_w(args...) ccc_om_and_modify_w(args)
617# define om_or_insert_w(args...) ccc_om_or_insert_w(args)
618# define om_insert_entry_w(args...) ccc_om_insert_entry_w(args)
619# define om_try_insert_w(args...) ccc_om_try_insert_w(args)
620# define om_insert_or_assign_w(args...) ccc_om_insert_or_assign_w(args)
621# define om_insert_r(args...) ccc_om_insert_r(args)
622# define om_remove_r(args...) ccc_om_remove_r(args)
623# define om_remove_entry_r(args...) ccc_om_remove_entry_r(args)
624# define om_entry_r(args...) ccc_om_entry_r(args)
625# define om_and_modify_r(args...) ccc_om_and_modify_r(args)
626# define om_and_modify_aux_r(args...) ccc_om_and_modify_aux_r(args)
627# define om_contains(args...) ccc_om_contains(args)
628# define om_get_key_val(args...) ccc_om_get_key_val(args)
629# define om_get_mut(args...) ccc_om_get_mut(args)
630# define om_insert(args...) ccc_om_insert(args)
631# define om_remove(args...) ccc_om_remove(args)
632# define om_entry(args...) ccc_om_entry(args)
633# define om_remove_entry(args...) ccc_om_remove_entry(args)
634# define om_or_insert(args...) ccc_om_or_insert(args)
635# define om_insert_entry(args...) ccc_om_insert_entry(args)
636# define om_unwrap(args...) ccc_om_unwrap(args)
637# define om_unwrap_mut(args...) ccc_om_unwrap_mut(args)
638# define om_begin(args...) ccc_om_begin(args)
639# define om_next(args...) ccc_om_next(args)
640# define om_rbegin(args...) ccc_om_rbegin(args)
641# define om_rnext(args...) ccc_om_rnext(args)
642# define om_end(args...) ccc_om_end(args)
643# define om_rend(args...) ccc_om_rend(args)
644# define om_size(args...) ccc_om_size(args)
645# define om_is_empty(args...) ccc_om_is_empty(args)
646# define om_clear(args...) ccc_om_clear(args)
647# define om_validate(args...) ccc_om_validate(args)
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.
union ccc_omap_entry_ ccc_omap_entry
A container specific entry used to implement the Entry Interface.
Definition: ordered_map.h:57
ccc_entry ccc_om_insert(ccc_ordered_map *om, ccc_omap_elem *key_val_handle, ccc_omap_elem *tmp)
Invariantly inserts 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).
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_entry_status ccc_om_entry_status(ccc_omap_entry const *e)
Obtain the entry status from a container entry.
size_t ccc_om_size(ccc_ordered_map const *om)
Returns the size of the map.
bool ccc_om_contains(ccc_ordered_map *om, void const *key)
Searches the map for the presence of key.
bool ccc_om_occupied(ccc_omap_entry const *e)
Returns the Vacant or Occupied status of the entry.
void * ccc_om_rbegin(ccc_ordered_map const *om)
Return the start of a reverse inorder traversal of the map. Amortized O(lg N).
bool ccc_om_insert_error(ccc_omap_entry const *e)
Provides the status of the entry should an insertion follow.
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).
union ccc_omap_elem_ ccc_omap_elem
The intrusive element for the user defined struct being stored in the map.
Definition: ordered_map.h:51
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.
union ccc_ordered_map_ ccc_ordered_map
A self-optimizing data structure offering amortized O(lg N) search, insert, and erase and pointer sta...
Definition: ordered_map.h:42
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.
bool ccc_om_is_empty(ccc_ordered_map const *om)
Returns the size status of the map.
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).
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).
bool ccc_om_validate(ccc_ordered_map const *om)
Validation of invariants for the map.
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.
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_range_ ccc_range
The result of a range query on iterable containers.
Definition: types.h:30
union ccc_entry_ ccc_entry
An Occupied or Vacant position in a searchable container.
Definition: types.h:47
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
union ccc_rrange_ ccc_rrange
The result of a rrange query on iterable containers.
Definition: types.h:38