31#ifndef CCC_FLAT_ORDERED_MAP_H
32#define CCC_FLAT_ORDERED_MAP_H
39#include "impl/impl_flat_ordered_map.h"
85#define ccc_fom_init(mem_ptr, capacity, om_elem_field, key_elem_field, \
86 alloc_fn, key_cmp, aux) \
87 ccc_impl_fom_init(mem_ptr, capacity, om_elem_field, key_elem_field, \
88 alloc_fn, key_cmp, aux)
225#define ccc_fom_insert_r(flat_ordered_map_ptr, out_handle_ptr) \
228 ccc_fom_insert((flat_ordered_map_ptr), (out_handle_ptr)).impl_ \
248#define ccc_fom_try_insert_r(flat_ordered_map_ptr, key_val_handle_ptr) \
251 ccc_fom_try_insert((flat_ordered_map_ptr), (key_val_handle_ptr)).impl_ \
266#define ccc_fom_try_insert_w(flat_ordered_map_ptr, key, lazy_value...) \
269 ccc_impl_fom_try_insert_w(flat_ordered_map_ptr, key, lazy_value) \
296#define ccc_fom_insert_or_assign_w(flat_ordered_map_ptr, key, lazy_value...) \
299 ccc_impl_fom_insert_or_assign_w(flat_ordered_map_ptr, key, lazy_value) \
325#define ccc_fom_remove_r(flat_ordered_map_ptr, out_handle_ptr) \
328 ccc_fom_remove((flat_ordered_map_ptr), (out_handle_ptr)).impl_ \
363#define ccc_fom_entry_r(flat_ordered_map_ptr, key_ptr) \
366 ccc_fom_entry((flat_ordered_map_ptr), (key_ptr)).impl_ \
417#define ccc_fom_and_modify_w(flat_ordered_map_entry_ptr, type_name, \
421 ccc_impl_fom_and_modify_w(flat_ordered_map_entry_ptr, type_name, \
450#define ccc_fom_or_insert_w(flat_ordered_map_entry_ptr, lazy_key_value...) \
451 ccc_impl_fom_or_insert_w(flat_ordered_map_entry_ptr, lazy_key_value)
468#define ccc_fom_insert_entry_w(flat_ordered_map_entry_ptr, lazy_key_value...) \
469 ccc_impl_fom_insert_entry_w(flat_ordered_map_entry_ptr, lazy_key_value)
489#define ccc_fom_remove_entry_r(flat_ordered_map_entry_ptr) \
492 ccc_fom_remove_entry((flat_ordered_map_entry_ptr)).impl_ \
549 void const *begin_key,
550 void const *end_key);
558#define ccc_fom_equal_range_r(flat_ordered_map_ptr, begin_and_end_key_ptrs...) \
561 ccc_fom_equal_range(flat_ordered_map_ptr, begin_and_end_key_ptrs) \
586 void const *rbegin_key,
587 void const *rend_key);
596#define ccc_fom_equal_rrange_r(flat_ordered_map_ptr, \
597 rbegin_and_rend_key_ptrs...) \
600 ccc_fom_equal_rrange(flat_ordered_map_ptr, rbegin_and_rend_key_ptrs) \
712#ifdef FLAT_ORDERED_MAP_USING_NAMESPACE_CCC
716# define fom_and_modify_w(args...) ccc_fom_and_modify_w(args)
717# define fom_or_insert_w(args...) ccc_fom_or_insert_w(args)
718# define fom_insert_entry_w(args...) ccc_fom_insert_entry_w(args)
719# define fom_try_insert_w(args...) ccc_fom_try_insert_w(args)
720# define fom_insert_or_assign_w(args...) ccc_fom_insert_or_assign_w(args)
721# define fom_init(args...) ccc_fom_init(args)
722# define fom_copy(args...) ccc_fom_copy(args)
723# define fom_contains(args...) ccc_fom_contains(args)
724# define fom_get_key_val(args...) ccc_fom_get_key_val(args)
725# define fom_insert_r(args...) ccc_fom_insert_r(args)
726# define fom_try_insert_r(args...) ccc_fom_try_insert_r(args)
727# define fom_remove_r(args...) ccc_fom_remove_r(args)
728# define fom_remove_entry_r(args...) ccc_fom_remove_entry_r(args)
729# define fom_insert(args...) ccc_fom_insert(args)
730# define fom_try_insert(args...) ccc_fom_try_insert(args)
731# define fom_insert_or_assign(args...) ccc_fom_insert_or_assign(args)
732# define fom_remove(args...) ccc_fom_remove(args)
733# define fom_remove_entry(args...) ccc_fom_remove_entry(args)
734# define fom_entry_r(args...) ccc_fom_entry_r(args)
735# define fom_entry(args...) ccc_fom_entry(args)
736# define fom_and_modify(args...) ccc_fom_and_modify(args)
737# define fom_and_modify_aux(args...) ccc_fom_and_modify_aux(args)
738# define fom_or_insert(args...) ccc_fom_or_insert(args)
739# define fom_insert_entry(args...) ccc_fom_insert_entry(args)
740# define fom_unwrap(args...) ccc_fom_unwrap(args)
741# define fom_insert_error(args...) ccc_fom_insert_error(args)
742# define fom_occupied(args...) ccc_fom_occupied(args)
743# define fom_clear(args...) ccc_fom_clear(args)
744# define fom_clear_and_free(args...) ccc_fom_clear_and_free(args)
745# define fom_begin(args...) ccc_fom_begin(args)
746# define fom_rbegin(args...) ccc_fom_rbegin(args)
747# define fom_end(args...) ccc_fom_end(args)
748# define fom_rend(args...) ccc_fom_rend(args)
749# define fom_next(args...) ccc_fom_next(args)
750# define fom_rnext(args...) ccc_fom_rnext(args)
751# define fom_data(args...) ccc_fom_data(args)
752# define fom_size(args...) ccc_fom_size(args)
753# define fom_is_empty(args...) ccc_fom_is_empty(args)
754# define fom_validate(args...) ccc_fom_validate(args)
ccc_fomap_entry * ccc_fom_and_modify_aux(ccc_fomap_entry *e, ccc_update_fn *fn, void *aux)
Modifies the provided entry if it is Occupied.
union ccc_fomap_entry_ ccc_fomap_entry
A container specific entry used to implement the Entry Interface.
Definition: flat_ordered_map.h:67
void * ccc_fom_rnext(ccc_flat_ordered_map const *fom, ccc_fomap_elem const *iter_handle)
Return the rnext element in a reverse inorder traversal of the map. O(1).
void * ccc_fom_end(ccc_flat_ordered_map const *fom)
Return the end of an inorder traversal of the map. O(1).
bool ccc_fom_is_empty(ccc_flat_ordered_map const *fom)
Returns the size status of the map.
bool ccc_fom_contains(ccc_flat_ordered_map *fom, void const *key)
Searches the map for the presence of key.
struct ccc_fomap_elem_ ccc_fomap_elem
The intrusive element for the user defined type being stored in the map.
Definition: flat_ordered_map.h:61
ccc_entry ccc_fom_try_insert(ccc_flat_ordered_map *fom, ccc_fomap_elem *key_val_handle)
Attempts to insert the key value wrapping key_val_handle.
ccc_entry ccc_fom_insert_or_assign(ccc_flat_ordered_map *fom, ccc_fomap_elem *key_val_handle)
Invariantly inserts or overwrites a user struct into the map.
ccc_range ccc_fom_equal_range(ccc_flat_ordered_map *fom, void const *begin_key, void const *end_key)
Return an iterable range of values from [begin_key, end_key). Amortized O(lg N).
size_t ccc_fom_capacity(ccc_flat_ordered_map const *fom)
Returns the capacity of the map.
size_t ccc_fom_size(ccc_flat_ordered_map const *fom)
Returns the size of the map.
ccc_fomap_entry ccc_fom_entry(ccc_flat_ordered_map *fom, void const *key)
Obtains an entry for the provided key in the map for future use.
ccc_entry_status ccc_fom_entry_status(ccc_fomap_entry const *e)
Obtain the entry status from a container entry.
ccc_result ccc_fom_clear(ccc_flat_ordered_map *fom, ccc_destructor_fn *fn)
Frees all slots in the map for use without affecting capacity.
ccc_fomap_entry * ccc_fom_and_modify(ccc_fomap_entry *e, ccc_update_fn *fn)
Modifies the provided entry if it is Occupied.
bool ccc_fom_occupied(ccc_fomap_entry const *e)
Returns the Vacant or Occupied status of the entry.
ccc_rrange ccc_fom_equal_rrange(ccc_flat_ordered_map *fom, 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_fom_rend(ccc_flat_ordered_map const *fom)
Return the rend of a reverse inorder traversal of the map. O(1).
ccc_result ccc_fom_clear_and_free(ccc_flat_ordered_map *fom, ccc_destructor_fn *fn)
Frees all slots in the map and frees the underlying buffer.
void * ccc_fom_get_key_val(ccc_flat_ordered_map *fom, void const *key)
Returns a reference into the map at entry key.
ccc_entry ccc_fom_insert(ccc_flat_ordered_map *fom, ccc_fomap_elem *out_handle)
Invariantly inserts the key value wrapping key_val_handle.
ccc_entry ccc_fom_remove(ccc_flat_ordered_map *fom, ccc_fomap_elem *out_handle)
Removes the key value in the map storing the old value, if present, in the struct containing out_hand...
bool ccc_fom_validate(ccc_flat_ordered_map const *fom)
Validation of invariants for the map.
ccc_entry ccc_fom_remove_entry(ccc_fomap_entry *e)
Remove the entry from the map if Occupied.
struct ccc_fomap_ ccc_flat_ordered_map
A self-optimizing data structure offering amortized O(lg N) search, insert, and erase.
Definition: flat_ordered_map.h:52
void * ccc_fom_insert_entry(ccc_fomap_entry const *e, ccc_fomap_elem *elem)
Inserts the provided entry invariantly.
void * ccc_fom_unwrap(ccc_fomap_entry const *e)
Unwraps the provided entry to obtain a view into the map element.
ccc_result ccc_fom_copy(ccc_flat_ordered_map *dst, ccc_flat_ordered_map const *src, ccc_alloc_fn *fn)
Copy the map at source to destination.
bool ccc_fom_insert_error(ccc_fomap_entry const *e)
Provides the status of the entry should an insertion follow.
void * ccc_fom_data(ccc_flat_ordered_map const *fom)
Return a reference to the base of backing array. O(1).
void * ccc_fom_or_insert(ccc_fomap_entry const *e, ccc_fomap_elem *elem)
Inserts the struct with handle elem if the entry is Vacant.
void * ccc_fom_next(ccc_flat_ordered_map const *fom, ccc_fomap_elem const *iter_handle)
Return the next element in an inorder traversal of the map. O(1).
void * ccc_fom_begin(ccc_flat_ordered_map const *fom)
Return the start of an inorder traversal of the map. Amortized O(lg N).
void * ccc_fom_rbegin(ccc_flat_ordered_map const *fom)
Return the start of a reverse inorder traversal of the map. Amortized O(lg N).
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
void * ccc_alloc_fn(void *ptr, size_t size, void *aux)
An allocation function at the core of all containers.
Definition: types.h:199
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