39#ifndef CCC_ADAPTIVE_MAP_H
40#define CCC_ADAPTIVE_MAP_H
91#define CCC_adaptive_map_initialize(struct_name, type_intruder_field_name, \
92 type_key_field_name, key_order, allocate, \
94 CCC_private_adaptive_map_initialize(struct_name, type_intruder_field_name, \
95 type_key_field_name, key_order, \
119#define CCC_adaptive_map_from(type_intruder_field_name, type_key_field_name, \
120 compare, allocate, destroy, context_data, \
121 compound_literal_array...) \
122 CCC_private_adaptive_map_from( \
123 type_intruder_field_name, type_key_field_name, compare, allocate, \
124 destroy, context_data, compound_literal_array)
157#define CCC_adaptive_map_with_allocator(type_name, type_intruder_field, \
158 type_key_field, compare, allocate) \
159 CCC_private_adaptive_map_with_allocator(type_name, type_intruder_field, \
160 type_key_field, compare, allocate)
195#define CCC_adaptive_map_with_context_allocator( \
196 type_name, type_intruder_field, type_key_field, compare, allocate, \
198 CCC_private_adaptive_map_with_context_allocator( \
199 type_name, type_intruder_field, type_key_field, compare, allocate, \
261#define CCC_adaptive_map_swap_entry_wrap(map_pointer, type_intruder_pointer, \
262 temp_intruder_pointer) \
265 CCC_adaptive_map_swap_entry((map_pointer), (type_intruder_pointer), \
266 (temp_intruder_pointer)) \
290#define CCC_adaptive_map_try_insert_wrap(map_pointer, type_intruder_pointer) \
293 CCC_adaptive_map_try_insert((map_pointer), (type_intruder_pointer)) \
310#define CCC_adaptive_map_try_insert_with(map_pointer, key, \
311 compound_literal_type...) \
314 CCC_private_adaptive_map_try_insert_with(map_pointer, key, \
315 compound_literal_type) \
343#define CCC_adaptive_map_insert_or_assign_with(map_pointer, key, \
344 compound_literal_type...) \
347 CCC_private_adaptive_map_insert_or_assign_with(map_pointer, key, \
348 compound_literal_type) \
386#define CCC_adaptive_map_remove_key_value_wrap(map_pointer, \
387 type_output_intruder_pointer) \
390 CCC_adaptive_map_remove_key_value((map_pointer), \
391 (type_output_intruder_pointer)) \
428#define CCC_adaptive_map_entry_wrap(map_pointer, key_pointer) \
429 &(CCC_Adaptive_map_entry) \
431 CCC_adaptive_map_entry((map_pointer), (key_pointer)).private \
495#define CCC_adaptive_map_and_modify_with(adaptive_map_entry_pointer, \
496 type_name, closure_over_T...) \
497 &(CCC_Adaptive_map_entry) \
499 CCC_private_adaptive_map_and_modify_with(adaptive_map_entry_pointer, \
500 type_name, closure_over_T) \
531#define CCC_adaptive_map_or_insert_with(adaptive_map_entry_pointer, \
532 type_compound_literal...) \
533 CCC_private_adaptive_map_or_insert_with(adaptive_map_entry_pointer, \
534 type_compound_literal)
553#define CCC_adaptive_map_insert_entry_with(adaptive_map_entry_pointer, \
554 type_compound_literal...) \
555 CCC_private_adaptive_map_insert_entry_with(adaptive_map_entry_pointer, \
556 type_compound_literal)
581#define CCC_adaptive_map_remove_entry_wrap(adaptive_map_entry_pointer) \
584 CCC_adaptive_map_remove_entry((adaptive_map_entry_pointer)).private \
616[[nodiscard]] CCC_Entry_status
646 void const *begin_key,
647 void const *end_key);
656#define CCC_adaptive_map_equal_range_wrap(map_pointer, \
657 begin_and_end_key_pointers...) \
660 CCC_adaptive_map_equal_range(map_pointer, begin_and_end_key_pointers) \
689 void const *reverse_begin_key,
690 void const *reverse_end_key);
699#define CCC_adaptive_map_equal_range_reverse_wrap( \
700 map_pointer, reverse_begin_and_reverse_end_key_pointers...) \
701 &(CCC_Range_reverse) \
703 CCC_adaptive_map_equal_range_reverse( \
704 map_pointer, reverse_begin_and_reverse_end_key_pointers) \
802#ifdef ADAPTIVE_MAP_USING_NAMESPACE_CCC
806# define adaptive_map_initialize(arguments...) \
807 CCC_adaptive_map_initialize(arguments)
808# define adaptive_map_with_allocator(arguments...) \
809 CCC_adaptive_map_with_allocator(arguments)
810# define adaptive_map_with_context_allocator(arguments...) \
811 CCC_adaptive_map_with_context_allocator(arguments)
812# define adaptive_map_from(arguments...) CCC_adaptive_map_from(arguments)
813# define adaptive_map_and_modify_with(arguments...) \
814 CCC_adaptive_map_and_modify_with(arguments)
815# define adaptive_map_or_insert_with(arguments...) \
816 CCC_adaptive_map_or_insert_with(arguments)
817# define adaptive_map_insert_entry_with(arguments...) \
818 CCC_adaptive_map_insert_entry_with(arguments)
819# define adaptive_map_try_insert_with(arguments...) \
820 CCC_adaptive_map_try_insert_with(arguments)
821# define adaptive_map_insert_or_assign_with(arguments...) \
822 CCC_adaptive_map_insert_or_assign_with(arguments)
823# define adaptive_map_swap_entry_wrap(arguments...) \
824 CCC_adaptive_map_swap_entry_wrap(arguments)
825# define adaptive_map_remove_key_value_wrap(arguments...) \
826 CCC_adaptive_map_remove_key_value_wrap(arguments)
827# define adaptive_map_remove_entry_wrap(arguments...) \
828 CCC_adaptive_map_remove_entry_wrap(arguments)
829# define adaptive_map_entry_wrap(arguments...) \
830 CCC_adaptive_map_entry_wrap(arguments)
831# define adaptive_map_and_modify_wrap(arguments...) \
832 CCC_adaptive_map_and_modify_wrap(arguments)
833# define adaptive_map_and_modify_context_wrap(arguments...) \
834 CCC_adaptive_map_and_modify_context_wrap(arguments)
835# define adaptive_map_contains(arguments...) \
836 CCC_adaptive_map_contains(arguments)
837# define adaptive_map_get_key_value(arguments...) \
838 CCC_adaptive_map_get_key_value(arguments)
839# define adaptive_map_get_mut(arguments...) \
840 CCC_adaptive_map_get_mut(arguments)
841# define adaptive_map_swap_entry(arguments...) \
842 CCC_adaptive_map_swap_entry(arguments)
843# define adaptive_map_remove_key_value(arguments...) \
844 CCC_adaptive_map_remove_key_value(arguments)
845# define adaptive_map_entry(arguments...) CCC_adaptive_map_entry(arguments)
846# define adaptive_map_remove_entry(arguments...) \
847 CCC_adaptive_map_remove_entry(arguments)
848# define adaptive_map_or_insert(arguments...) \
849 CCC_adaptive_map_or_insert(arguments)
850# define adaptive_map_insert_entry(arguments...) \
851 CCC_adaptive_map_insert_entry(arguments)
852# define adaptive_map_unwrap(arguments...) CCC_adaptive_map_unwrap(arguments)
853# define adaptive_map_unwrap_mut(arguments...) \
854 CCC_adaptive_map_unwrap_mut(arguments)
855# define adaptive_map_begin(arguments...) CCC_adaptive_map_begin(arguments)
856# define adaptive_map_next(arguments...) CCC_adaptive_map_next(arguments)
857# define adaptive_map_reverse_begin(arguments...) \
858 CCC_adaptive_map_reverse_begin(arguments)
859# define adaptive_map_reverse_next(arguments...) \
860 CCC_adaptive_map_reverse_next(arguments)
861# define adaptive_map_end(arguments...) CCC_adaptive_map_end(arguments)
862# define adaptive_map_reverse_end(arguments...) \
863 CCC_adaptive_map_reverse_end(arguments)
864# define adaptive_map_count(arguments...) CCC_adaptive_map_count(arguments)
865# define adaptive_map_is_empty(arguments...) \
866 CCC_adaptive_map_is_empty(arguments)
867# define adaptive_map_clear(arguments...) CCC_adaptive_map_clear(arguments)
868# define adaptive_map_validate(arguments...) \
869 CCC_adaptive_map_validate(arguments)
CCC_Range CCC_adaptive_map_equal_range(CCC_Adaptive_map *map, 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_adaptive_map_reverse_end(CCC_Adaptive_map const *map)
Return the reverse_end of a reverse inorder traversal of the map. O(1).
void * CCC_adaptive_map_or_insert(CCC_Adaptive_map_entry const *entry, CCC_Adaptive_map_node *type_intruder)
Inserts the struct with handle type_intruder if the entry is Vacant.
CCC_Tribool CCC_adaptive_map_validate(CCC_Adaptive_map const *map)
Validation of invariants for the map.
CCC_Entry_status CCC_adaptive_map_entry_status(CCC_Adaptive_map_entry const *entry)
Obtain the entry status from a container entry.
void * CCC_adaptive_map_next(CCC_Adaptive_map const *map, CCC_Adaptive_map_node const *iterator_intruder)
Return the next element in an inorder traversal of the map. O(1).
CCC_Entry CCC_adaptive_map_insert_or_assign(CCC_Adaptive_map *map, CCC_Adaptive_map_node *type_intruder)
Invariantly inserts or overwrites a user struct into the map.
CCC_Tribool CCC_adaptive_map_contains(CCC_Adaptive_map *map, void const *key)
Searches the map for the presence of key.
CCC_Result CCC_adaptive_map_clear(CCC_Adaptive_map *map, CCC_Type_destructor *destroy)
Pops every element from the map calling destructor if destructor is non-NULL. O(N).
CCC_Tribool CCC_adaptive_map_insert_error(CCC_Adaptive_map_entry const *entry)
Provides the status of the entry should an insertion follow.
void * CCC_adaptive_map_reverse_next(CCC_Adaptive_map const *map, CCC_Adaptive_map_node const *iterator_intruder)
Return the reverse_next element in a reverse inorder traversal of the map. O(1).
CCC_Adaptive_map_entry CCC_adaptive_map_entry(CCC_Adaptive_map *map, void const *key)
Obtains an entry for the provided key in the map for future use.
CCC_Tribool CCC_adaptive_map_is_empty(CCC_Adaptive_map const *map)
Returns the size status of the map.
void * CCC_adaptive_map_end(CCC_Adaptive_map const *map)
Return the end of an inorder traversal of the map. O(1).
CCC_Entry CCC_adaptive_map_remove_entry(CCC_Adaptive_map_entry *entry)
Remove the entry from the map if Occupied.
void * CCC_adaptive_map_begin(CCC_Adaptive_map const *map)
Return the start of an inorder traversal of the map. Amortized O(lg N).
CCC_Entry CCC_adaptive_map_swap_entry(CCC_Adaptive_map *map, CCC_Adaptive_map_node *type_intruder, CCC_Adaptive_map_node *temp_intruder)
Invariantly inserts the key value wrapping type_intruder.
void * CCC_adaptive_map_get_key_value(CCC_Adaptive_map *map, void const *key)
Returns a reference into the map at entry key.
CCC_Adaptive_map_entry * CCC_adaptive_map_and_modify_context(CCC_Adaptive_map_entry *entry, CCC_Type_modifier *modify, void *context)
Modifies the provided entry if it is Occupied.
CCC_Entry CCC_adaptive_map_try_insert(CCC_Adaptive_map *map, CCC_Adaptive_map_node *type_intruder)
Attempts to insert the key value wrapping type_intruder.
CCC_Entry CCC_adaptive_map_remove_key_value(CCC_Adaptive_map *map, CCC_Adaptive_map_node *type_output_intruder)
Removes the key value in the map storing the old value, if present, in the struct containing type_out...
void * CCC_adaptive_map_reverse_begin(CCC_Adaptive_map const *map)
Return the start of a reverse inorder traversal of the map. Amortized O(lg N).
CCC_Tribool CCC_adaptive_map_occupied(CCC_Adaptive_map_entry const *entry)
Returns the Vacant or Occupied status of the entry.
void * CCC_adaptive_map_unwrap(CCC_Adaptive_map_entry const *entry)
Unwraps the provided entry to obtain a view into the map element.
void * CCC_adaptive_map_insert_entry(CCC_Adaptive_map_entry const *entry, CCC_Adaptive_map_node *type_intruder)
Inserts the provided entry invariantly.
CCC_Adaptive_map_entry * CCC_adaptive_map_and_modify(CCC_Adaptive_map_entry *entry, CCC_Type_modifier *modify)
Modifies the provided entry if it is Occupied.
CCC_Range_reverse CCC_adaptive_map_equal_range_reverse(CCC_Adaptive_map *map, void const *reverse_begin_key, void const *reverse_end_key)
Return an iterable range_reverse of values from [begin_key, end_key). Amortized O(lg N).
CCC_Count CCC_adaptive_map_count(CCC_Adaptive_map const *map)
Returns the count of occupied map nodes.
The Adaptive Map Private Interface.
Definition: private_adaptive_map.h:93
Definition: private_adaptive_map.h:44
Definition: private_adaptive_map.h:59
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:202
Definition: private_types.h:53
Definition: private_types.h:112
The C Container Collection Fundamental Types.
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:133
void CCC_Type_destructor(CCC_Type_context)
A callback function for destroying an element in the container.
Definition: types.h:376
CCC_Result
A result of actions on containers.
Definition: types.h:148
void CCC_Type_modifier(CCC_Type_context)
A callback function for modifying an element in the container.
Definition: types.h:358
Definition: private_adaptive_map.h:105
Definition: private_types.h:160