17#ifndef CCC_REALTIME_ORDERED_MAP_H
18#define CCC_REALTIME_ORDERED_MAP_H
24#include "impl/impl_realtime_ordered_map.h"
73#define ccc_rom_init(rom_name, struct_name, rom_elem_field, key_elem_field, \
74 alloc_fn, key_cmp_fn, aux_data) \
75 ccc_impl_rom_init(rom_name, struct_name, rom_elem_field, key_elem_field, \
76 alloc_fn, key_cmp_fn, aux_data)
134#define ccc_rom_insert_r(realtime_ordered_map_ptr, key_val_handle_ptr, \
138 ccc_rom_insert((realtime_ordered_map_ptr), (key_val_handle_ptr), \
161#define ccc_rom_try_insert_r(realtime_ordered_map_ptr, key_val_handle_ptr) \
164 ccc_rom_try_insert((realtime_ordered_map_ptr), (key_val_handle_ptr)) \
180#define ccc_rom_try_insert_w(realtime_ordered_map_ptr, key, lazy_value...) \
183 ccc_impl_rom_try_insert_w(realtime_ordered_map_ptr, key, lazy_value) \
210#define ccc_rom_insert_or_assign_w(realtime_ordered_map_ptr, key, \
214 ccc_impl_rom_insert_or_assign_w(realtime_ordered_map_ptr, key, \
251#define ccc_rom_remove_r(realtime_ordered_map_ptr, out_handle_ptr) \
254 ccc_rom_remove((realtime_ordered_map_ptr), (out_handle_ptr)).impl_ \
289#define ccc_rom_entry_r(realtime_ordered_map_ptr, key_ptr) \
292 ccc_rom_entry((realtime_ordered_map_ptr), (key_ptr)).impl_ \
343#define ccc_rom_and_modify_w(realtime_ordered_map_entry_ptr, type_name, \
347 ccc_impl_rom_and_modify_w(realtime_ordered_map_entry_ptr, type_name, \
376#define ccc_rom_or_insert_w(realtime_ordered_map_entry_ptr, lazy_key_value...) \
377 ccc_impl_rom_or_insert_w(realtime_ordered_map_entry_ptr, lazy_key_value)
394#define ccc_rom_insert_entry_w(realtime_ordered_map_entry_ptr, \
396 ccc_impl_rom_insert_entry_w(realtime_ordered_map_entry_ptr, lazy_key_value)
420#define ccc_rom_remove_entry_r(realtime_ordered_map_entry_ptr) \
423 ccc_rom_remove_entry((realtime_ordered_map_entry_ptr)).impl_ \
501 void const *begin_key,
502 void const *end_key);
511#define ccc_rom_equal_range_r(realtime_ordered_map_ptr, \
512 begin_and_end_key_ptrs...) \
515 ccc_rom_equal_range((realtime_ordered_map_ptr), \
516 (begin_and_end_key_ptrs)) \
540 void const *rbegin_key,
void const *rend_key);
549#define ccc_rom_equal_rrange_r(realtime_ordered_map_ptr, \
550 rbegin_and_rend_key_ptrs...) \
553 ccc_rom_equal_rrange((realtime_ordered_map_ptr), \
554 (rbegin_and_rend_key_ptrs)) \
622#ifdef REALTIME_ORDERED_MAP_USING_NAMESPACE_CCC
626# define rom_init(args...) ccc_rom_init(args)
627# define rom_and_modify_w(args...) ccc_rom_and_modify_w(args)
628# define rom_or_insert_w(args...) ccc_rom_or_insert_w(args)
629# define rom_insert_entry_w(args...) ccc_rom_insert_entry_w(args)
630# define rom_try_insert_w(args...) ccc_rom_try_insert_w(args)
631# define rom_insert_or_assign_w(args...) ccc_rom_insert_or_assign_w(args)
632# define rom_insert_r(args...) ccc_rom_insert_r(args)
633# define rom_remove_r(args...) ccc_rom_remove_r(args)
634# define rom_remove_entry_r(args...) ccc_rom_remove_entry_r(args)
635# define rom_entry_r(args...) ccc_rom_entry_r(args)
636# define rom_and_modify_r(args...) ccc_rom_and_modify_r(args)
637# define rom_and_modify_aux_r(args...) ccc_rom_and_modify_aux_r(args)
638# define rom_contains(args...) ccc_rom_contains(args)
639# define rom_get_key_val(args...) ccc_rom_get_key_val(args)
640# define rom_get_mut(args...) ccc_rom_get_mut(args)
641# define rom_insert(args...) ccc_rom_insert(args)
642# define rom_remove(args...) ccc_rom_remove(args)
643# define rom_entry(args...) ccc_rom_entry(args)
644# define rom_remove_entry(args...) ccc_rom_remove_entry(args)
645# define rom_or_insert(args...) ccc_rom_or_insert(args)
646# define rom_insert_entry(args...) ccc_rom_insert_entry(args)
647# define rom_unwrap(args...) ccc_rom_unwrap(args)
648# define rom_unwrap_mut(args...) ccc_rom_unwrap_mut(args)
649# define rom_begin(args...) ccc_rom_begin(args)
650# define rom_next(args...) ccc_rom_next(args)
651# define rom_rbegin(args...) ccc_rom_rbegin(args)
652# define rom_rnext(args...) ccc_rom_rnext(args)
653# define rom_end(args...) ccc_rom_end(args)
654# define rom_rend(args...) ccc_rom_rend(args)
655# define rom_size(args...) ccc_rom_size(args)
656# define rom_is_empty(args...) ccc_rom_is_empty(args)
657# define rom_clear(args...) ccc_rom_clear(args)
658# define rom_validate(args...) ccc_rom_validate(args)
ccc_romap_entry ccc_rom_entry(ccc_realtime_ordered_map const *rom, void const *key)
Obtains an entry for the provided key in the map for future use.
bool ccc_rom_insert_error(ccc_romap_entry const *e)
Returns the Vacant or Occupied status of the entry.
ccc_entry ccc_rom_remove_entry(ccc_romap_entry const *e)
Remove the entry from the map if Occupied.
ccc_result ccc_rom_clear(ccc_realtime_ordered_map *rom, ccc_destructor_fn *destructor)
Pops every element from the map calling destructor if destructor is non-NULL. O(N).
bool ccc_rom_is_empty(ccc_realtime_ordered_map const *rom)
Returns the size status of the map.
void * ccc_rom_rbegin(ccc_realtime_ordered_map const *rom)
Return the start of a reverse inorder traversal of the map. Amortized O(lg N).
ccc_romap_entry * ccc_rom_and_modify(ccc_romap_entry *e, ccc_update_fn *fn)
Modifies the provided entry if it is Occupied.
ccc_range ccc_rom_equal_range(ccc_realtime_ordered_map const *rom, void const *begin_key, void const *end_key)
Return an iterable range of values from [begin_key, end_key). Amortized O(lg N).
ccc_romap_entry * ccc_rom_and_modify_aux(ccc_romap_entry *e, ccc_update_fn *fn, void *aux)
Modifies the provided entry if it is Occupied.
void * ccc_rom_unwrap(ccc_romap_entry const *e)
Unwraps the provided entry to obtain a view into the map element.
void * ccc_rom_rend(ccc_realtime_ordered_map const *rom)
Return the rend of a reverse inorder traversal of the map. O(1).
struct ccc_romap_elem_ ccc_romap_elem
The intrusive element of the user defined struct being stored in the map.
Definition: realtime_ordered_map.h:48
bool ccc_rom_occupied(ccc_romap_entry const *e)
Provides the status of the entry should an insertion follow.
void * ccc_rom_end(ccc_realtime_ordered_map const *rom)
Return the end of an inorder traversal of the map. O(1).
size_t ccc_rom_size(ccc_realtime_ordered_map const *rom)
Returns the size of the map.
union ccc_romap_entry_ ccc_romap_entry
A container specific entry used to implement the Entry Interface.
Definition: realtime_ordered_map.h:54
ccc_entry ccc_rom_try_insert(ccc_realtime_ordered_map *rom, ccc_romap_elem *key_val_handle)
Attempts to insert the key value wrapping key_val_handle.
void * ccc_rom_get_key_val(ccc_realtime_ordered_map const *rom, void const *key)
Returns a reference into the map at entry key.
void * ccc_rom_insert_entry(ccc_romap_entry const *e, ccc_romap_elem *elem)
Inserts the provided entry invariantly.
void * ccc_rom_begin(ccc_realtime_ordered_map const *rom)
Return the start of an inorder traversal of the map. Amortized O(lg N).
ccc_rrange ccc_rom_equal_rrange(ccc_realtime_ordered_map const *rom, 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_rom_insert_or_assign(ccc_realtime_ordered_map *rom, ccc_romap_elem *key_val_handle)
Invariantly inserts or overwrites a user struct into the map.
ccc_entry_status ccc_rom_entry_status(ccc_romap_entry const *e)
Obtain the entry status from a container entry.
ccc_entry ccc_rom_insert(ccc_realtime_ordered_map *rom, ccc_romap_elem *key_val_handle, ccc_romap_elem *tmp)
Invariantly inserts the key value wrapping key_val_handle.
void * ccc_rom_or_insert(ccc_romap_entry const *e, ccc_romap_elem *elem)
Inserts the struct with handle elem if the entry is Vacant.
void * ccc_rom_rnext(ccc_realtime_ordered_map const *rom, ccc_romap_elem const *iter_handle)
Return the rnext element in a reverse inorder traversal of the map. O(1).
bool ccc_rom_contains(ccc_realtime_ordered_map const *rom, void const *key)
Searches the map for the presence of key.
ccc_entry ccc_rom_remove(ccc_realtime_ordered_map *rom, ccc_romap_elem *out_handle)
Removes the key value in the map storing the old value, if present, in the struct containing out_hand...
void * ccc_rom_next(ccc_realtime_ordered_map const *rom, ccc_romap_elem const *iter_handle)
Return the next element in an inorder traversal of the map. O(1).
bool ccc_rom_validate(ccc_realtime_ordered_map const *rom)
Validation of invariants for the map.
struct ccc_romap_ ccc_realtime_ordered_map
A container for amortized O(lg N) search, insert, erase, ranges, and pointer stability.
Definition: realtime_ordered_map.h:37
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