C Container Collection (CCC)
Loading...
Searching...
No Matches
array_tree_map.h
Go to the documentation of this file.
1
60#ifndef CCC_ARRAY_TREE_MAP_H
61#define CCC_ARRAY_TREE_MAP_H
62
64#include <stddef.h>
68#include "types.h" /* IWYU pragma: export */
69
81
91
116#define CCC_array_tree_map_storage_for( \
117 user_type_compound_literal_array, optional_storage_specifier... \
118) \
119 CCC_private_array_tree_map_storage_for( \
120 user_type_compound_literal_array, optional_storage_specifier \
121 )
122
128#define CCC_array_tree_map_default(type_name, type_key_field, comparator...) \
129 CCC_private_array_tree_map_default(type_name, type_key_field, comparator)
130
139#define CCC_array_tree_map_for( \
140 type_name, type_key_field, comparator, capacity, memory_pointer \
141) \
142 CCC_private_array_tree_map_for( \
143 type_name, type_key_field, comparator, capacity, memory_pointer \
144 )
145
197#define CCC_array_tree_map_from( \
198 type_key_field, \
199 comparator, \
200 allocator, \
201 optional_capacity, \
202 type_compound_literal_array... \
203) \
204 CCC_private_array_tree_map_from( \
205 type_key_field, \
206 comparator, \
207 allocator, \
208 optional_capacity, \
209 type_compound_literal_array \
210 )
211
255#define CCC_array_tree_map_with_capacity( \
256 type_name, type_key_field, comparator, allocator, capacity \
257) \
258 CCC_private_array_tree_map_with_capacity( \
259 type_name, type_key_field, comparator, allocator, capacity \
260 )
261
291#define CCC_array_tree_map_with_storage( \
292 type_key_field, \
293 comparator, \
294 compound_literal, \
295 optional_storage_specifier... \
296) \
297 CCC_private_array_tree_map_with_storage( \
298 type_key_field, \
299 comparator, \
300 compound_literal, \
301 optional_storage_specifier \
302 )
303
315#define CCC_array_tree_map_with_allocator_storage( \
316 key_field, comparator, allocator, compound_literal \
317) \
318 CCC_private_array_tree_map_with_allocator_storage( \
319 key_field, comparator, allocator, compound_literal \
320 )
321
392 CCC_Array_tree_map *destination,
393 CCC_Array_tree_map const *source,
394 CCC_Allocator const *allocator
395);
396
404 CCC_Array_tree_map *map, size_t to_add, CCC_Allocator const *allocator
405);
406
423[[nodiscard]] void *
425
432#define CCC_array_tree_map_as( \
433 array_tree_map_pointer, type_name, array_index... \
434) \
435 CCC_private_array_tree_map_as( \
436 array_tree_map_pointer, type_name, array_index \
437 )
438
444[[nodiscard]] CCC_Tribool
446
452 CCC_Array_tree_map const *map, void const *key
453);
454
473 CCC_Array_tree_map *map, void *type_output, CCC_Allocator const *allocator
474);
475
487#define CCC_array_tree_map_swap_handle_wrap( \
488 array_tree_map_pointer, type_output_pointer, allocator_pointer... \
489) \
490 &(struct { CCC_Handle private; }){ \
491 CCC_array_tree_map_swap_handle( \
492 (array_tree_map_pointer), (type_output_pointer), allocator_pointer \
493 )} \
494 .private
495
505 CCC_Array_tree_map *map, void const *type, CCC_Allocator const *allocator
506);
507
516#define CCC_array_tree_map_try_insert_wrap( \
517 array_tree_map_pointer, type_pointer, allocator_pointer... \
518) \
519 &(struct { CCC_Handle private; }){ \
520 CCC_array_tree_map_try_insert( \
521 (array_tree_map_pointer), (type_pointer), allocator_pointer \
522 )} \
523 .private
524
539#define CCC_array_tree_map_try_insert_with( \
540 array_tree_map_pointer, key, allocator_pointer, type_compound_literal... \
541) \
542 &(struct { CCC_Handle private; }){ \
543 CCC_private_array_tree_map_try_insert_with( \
544 array_tree_map_pointer, \
545 key, \
546 allocator_pointer, \
547 type_compound_literal \
548 )} \
549 .private
550
561 CCC_Array_tree_map *map, void const *type, CCC_Allocator const *allocator
562);
563
573#define CCC_array_tree_map_insert_or_assign_wrap( \
574 map_pointer, type_pointer, allocator_pointer... \
575) \
576 &(struct { CCC_Handle private; }){ \
577 CCC_array_tree_map_insert_or_assign( \
578 map_pointer, type_pointer, allocator_pointer \
579 )} \
580 .private
581
595#define CCC_array_tree_map_insert_or_assign_with( \
596 array_tree_map_pointer, key, allocator_pointer, type_compound_literal... \
597) \
598 &(struct { CCC_Handle private; }){ \
599 CCC_private_array_tree_map_insert_or_assign_with( \
600 array_tree_map_pointer, \
601 key, \
602 allocator_pointer, \
603 type_compound_literal \
604 )} \
605 .private
606
616[[nodiscard]] CCC_Handle
618
629#define CCC_array_tree_map_remove_key_value_wrap( \
630 array_tree_map_pointer, type_output_pointer \
631) \
632 &(struct { CCC_Handle private; }){ \
633 CCC_array_tree_map_remove_key_value( \
634 (array_tree_map_pointer), (type_output_pointer) \
635 )} \
636 .private
637
653[[nodiscard]] CCC_Array_tree_map_handle
655
672#define CCC_array_tree_map_handle_wrap(array_tree_map_pointer, key_pointer) \
673 &(struct { CCC_Array_tree_map_handle private; }){ \
674 CCC_array_tree_map_handle((array_tree_map_pointer), (key_pointer))} \
675 .private
676
682 CCC_Array_tree_map_handle *handle, CCC_Modifier const *modifier
683);
684
720#define CCC_array_tree_map_and_modify_with( \
721 map_array_pointer, closure_parameter, closure_over_closure_parameter... \
722) \
723 &( \
724 struct { CCC_Array_tree_map_handle private; } \
725 ){CCC_private_array_tree_map_and_modify_with( \
726 map_array_pointer, closure_parameter, closure_over_closure_parameter \
727 )} \
728 .private
729
743 CCC_Array_tree_map_handle const *handle,
744 void const *type,
745 CCC_Allocator const *allocator
746);
747
760#define CCC_array_tree_map_or_insert_with( \
761 map_array_pointer, allocator_pointer, type_compound_literal... \
762) \
763 CCC_private_array_tree_map_or_insert_with( \
764 map_array_pointer, allocator_pointer, type_compound_literal \
765 )
766
776 CCC_Array_tree_map_handle const *handle,
777 void const *type,
778 CCC_Allocator const *allocator
779);
780
788#define CCC_array_tree_map_insert_handle_with( \
789 map_array_pointer, allocator_pointer, type_compound_literal... \
790) \
791 CCC_private_array_tree_map_insert_handle_with( \
792 map_array_pointer, allocator_pointer, type_compound_literal \
793 )
794
804
813#define CCC_array_tree_map_remove_handle_wrap(map_array_pointer) \
814 &(struct { CCC_Handle private; }){ \
815 CCC_array_tree_map_remove_handle((map_array_pointer))} \
816 .private
817
821[[nodiscard]] CCC_Handle_index
823
828[[nodiscard]] CCC_Tribool
830
836[[nodiscard]] CCC_Tribool
838
848[[nodiscard]] CCC_Handle_status
850
866 CCC_Array_tree_map *map, CCC_Destructor const *destructor
867);
868
883 CCC_Destructor const *destructor,
884 CCC_Allocator const *allocator
885);
886
913 CCC_Array_tree_map const *map, void const *begin_key, void const *end_key
914);
915
922#define CCC_array_tree_map_equal_range_wrap( \
923 array_tree_map_pointer, begin_and_end_key_pointers... \
924) \
925 &(struct { CCC_Handle_range private; }){ \
926 CCC_array_tree_map_equal_range( \
927 (array_tree_map_pointer), begin_and_end_key_pointers \
928 )} \
929 .private
930
955 CCC_Array_tree_map const *map,
956 void const *reverse_begin_key,
957 void const *reverse_end_key
958);
959
967#define CCC_array_tree_map_equal_range_reverse_wrap( \
968 array_tree_map_pointer, reverse_begin_and_reverse_end_key_pointers... \
969) \
970 &( \
971 struct { CCC_Handle_range_reverse private; } \
972 ){CCC_array_tree_map_equal_range_reverse( \
973 (array_tree_map_pointer), reverse_begin_and_reverse_end_key_pointers \
974 )} \
975 .private
976
980[[nodiscard]] CCC_Handle_index
982
986[[nodiscard]] CCC_Handle_index
988
997);
998
1007 CCC_Array_tree_map const *map, CCC_Handle_index iterator
1008);
1009
1013[[nodiscard]] CCC_Handle_index
1015
1020[[nodiscard]] CCC_Handle_index
1022
1033[[nodiscard]] CCC_Tribool
1035
1041
1046[[nodiscard]] CCC_Count
1048
1053[[nodiscard]] CCC_Tribool
1055
1060#ifdef ARRAY_TREE_MAP_USING_NAMESPACE_CCC
1061/* NOLINTBEGIN(readability-identifier-naming) */
1062typedef CCC_Array_tree_map Array_tree_map;
1063typedef CCC_Array_tree_map_handle Array_tree_map_handle;
1064# define array_tree_map_storage_for(arguments...) \
1065 CCC_array_tree_map_storage_for(arguments)
1066# define array_tree_map_default(arguments...) \
1067 CCC_array_tree_map_default(arguments)
1068# define array_tree_map_for(arguments...) CCC_array_tree_map_for(arguments)
1069# define array_tree_map_from(arguments...) CCC_array_tree_map_from(arguments)
1070# define array_tree_map_with_capacity(arguments...) \
1071 CCC_array_tree_map_with_capacity(arguments)
1072# define array_tree_map_with_storage(arguments...) \
1073 CCC_array_tree_map_with_storage(arguments)
1074# define array_tree_map_with_allocator_storage(arguments...) \
1075 CCC_array_tree_map_with_allocator_storage(arguments)
1076# define array_tree_map_copy(arguments...) CCC_array_tree_map_copy(arguments)
1077# define array_tree_map_reserve(arguments...) \
1078 CCC_array_tree_map_reserve(arguments)
1079# define array_tree_map_at(arguments...) CCC_array_tree_map_at(arguments)
1080# define array_tree_map_as(arguments...) CCC_array_tree_map_as(arguments)
1081# define array_tree_map_and_modify(arguments...) \
1082 CCC_array_tree_map_and_modify(arguments)
1083# define array_tree_map_and_modify_with(arguments...) \
1084 CCC_array_tree_map_and_modify_with(arguments)
1085# define array_tree_map_or_insert(arguments...) \
1086 CCC_array_tree_map_or_insert(arguments)
1087# define array_tree_map_or_insert_with(arguments...) \
1088 CCC_array_tree_map_or_insert_with(arguments)
1089# define array_tree_map_insert_handle_with(arguments...) \
1090 CCC_array_tree_map_insert_handle_with(arguments)
1091# define array_tree_map_insert_handle(arguments...) \
1092 CCC_array_tree_map_insert_handle(arguments)
1093# define array_tree_map_try_insert(arguments...) \
1094 CCC_array_tree_map_try_insert(arguments)
1095# define array_tree_map_try_insert_wrap(arguments...) \
1096 CCC_array_tree_map_try_insert_wrap(arguments)
1097# define array_tree_map_try_insert_with(arguments...) \
1098 CCC_array_tree_map_try_insert_with(arguments)
1099# define array_tree_map_insert_or_assign(arguments...) \
1100 CCC_array_tree_map_insert_or_assign(arguments)
1101# define array_tree_map_insert_or_assign_wrap(arguments...) \
1102 CCC_array_tree_map_insert_or_assign_wrap(arguments)
1103# define array_tree_map_insert_or_assign_with(arguments...) \
1104 CCC_array_tree_map_insert_or_assign_with(arguments)
1105# define array_tree_map_contains(arguments...) \
1106 CCC_array_tree_map_contains(arguments)
1107# define array_tree_map_get_key_value(arguments...) \
1108 CCC_array_tree_map_get_key_value(arguments)
1109# define array_tree_map_handle(arguments...) \
1110 CCC_array_tree_map_handle(arguments)
1111# define array_tree_map_handle_wrap(arguments...) \
1112 CCC_array_tree_map_handle_wrap(arguments)
1113# define array_tree_map_remove_handle(arguments...) \
1114 CCC_array_tree_map_remove_handle(arguments)
1115# define array_tree_map_remove_handle_wrap(arguments...) \
1116 CCC_array_tree_map_remove_handle_wrap(arguments)
1117# define array_tree_map_remove_key_value(arguments...) \
1118 CCC_array_tree_map_remove_key_value(arguments)
1119# define array_tree_map_remove_key_value_wrap(arguments...) \
1120 CCC_array_tree_map_remove_key_value_wrap(arguments)
1121# define array_tree_map_swap_handle(arguments...) \
1122 CCC_array_tree_map_swap_handle(arguments)
1123# define array_tree_map_swap_handle_wrap(arguments...) \
1124 CCC_array_tree_map_swap_handle_wrap(arguments)
1125# define array_tree_map_begin(arguments...) \
1126 CCC_array_tree_map_begin(arguments)
1127# define array_tree_map_reverse_begin(arguments...) \
1128 CCC_array_tree_map_reverse_begin(arguments)
1129# define array_tree_map_next(arguments...) CCC_array_tree_map_next(arguments)
1130# define array_tree_map_reverse_next(arguments...) \
1131 CCC_array_tree_map_reverse_next(arguments)
1132# define array_tree_map_end(arguments...) CCC_array_tree_map_end(arguments)
1133# define array_tree_map_reverse_end(arguments...) \
1134 CCC_array_tree_map_reverse_end(arguments)
1135# define array_tree_map_equal_range(arguments...) \
1136 CCC_array_tree_map_equal_range(arguments)
1137# define array_tree_map_equal_range_wrap(arguments...) \
1138 CCC_array_tree_map_equal_range_wrap(arguments)
1139# define array_tree_map_equal_range_reverse(arguments...) \
1140 CCC_array_tree_map_equal_range_reverse(arguments)
1141# define array_tree_map_equal_range_reverse_wrap(arguments...) \
1142 CCC_array_tree_map_equal_range_reverse_wrap(arguments)
1143# define array_tree_map_is_empty(arguments...) \
1144 CCC_array_tree_map_is_empty(arguments)
1145# define array_tree_map_count(arguments...) \
1146 CCC_array_tree_map_count(arguments)
1147# define array_tree_map_capacity(arguments...) \
1148 CCC_array_tree_map_capacity(arguments)
1149# define array_tree_map_clear(arguments...) \
1150 CCC_array_tree_map_clear(arguments)
1151# define array_tree_map_clear_and_free(arguments...) \
1152 CCC_array_tree_map_clear_and_free(arguments)
1153# define array_tree_map_validate(arguments...) \
1154 CCC_array_tree_map_validate(arguments)
1155# define array_tree_map_unwrap(arguments...) \
1156 CCC_array_tree_map_unwrap(arguments)
1157# define array_tree_map_insert_error(arguments...) \
1158 CCC_array_tree_map_insert_error(arguments)
1159# define array_tree_map_occupied(arguments...) \
1160 CCC_array_tree_map_occupied(arguments)
1161# define array_tree_map_handle_status(arguments...) \
1162 CCC_array_tree_map_handle_status(arguments)
1163/* NOLINTEND(readability-identifier-naming) */
1164#endif /* ARRAY_TREE_MAP_USING_NAMESPACE_CCC */
1165
1166#endif /* CCC_ARRAY_TREE_MAP_H */
CCC_Handle_index CCC_array_tree_map_insert_handle(CCC_Array_tree_map_handle const *handle, void const *type, CCC_Allocator const *allocator)
Inserts the provided user type invariantly.
CCC_Result CCC_array_tree_map_reserve(CCC_Array_tree_map *map, size_t to_add, CCC_Allocator const *allocator)
Reserves space for at least to_add more elements.
CCC_Handle_index CCC_array_tree_map_reverse_begin(CCC_Array_tree_map const *map)
Return the start of a reverse inorder traversal of the map. O(lg N).
CCC_Handle_index CCC_array_tree_map_reverse_next(CCC_Array_tree_map const *map, CCC_Handle_index iterator)
Return the reverse_next element in a reverse inorder traversal of the map. O(1).
CCC_Tribool CCC_array_tree_map_validate(CCC_Array_tree_map const *map)
Validation of invariants for the map.
CCC_Handle_range_reverse CCC_array_tree_map_equal_range_reverse(CCC_Array_tree_map const *map, void const *reverse_begin_key, void const *reverse_end_key)
Return an iterable range_reverse of values from [begin_key, end_key). O(lg N).
CCC_Count CCC_array_tree_map_count(CCC_Array_tree_map const *map)
Returns the count of map occupied slots.
CCC_Handle CCC_array_tree_map_swap_handle(CCC_Array_tree_map *map, void *type_output, CCC_Allocator const *allocator)
Invariantly inserts the key value in type_output.
CCC_Tribool CCC_array_tree_map_occupied(CCC_Array_tree_map_handle const *handle)
Returns the Vacant or Occupied status of the handle.
CCC_Handle_index CCC_array_tree_map_begin(CCC_Array_tree_map const *map)
Return the start of an inorder traversal of the map. O(lg N).
CCC_Result CCC_array_tree_map_clear_and_free(CCC_Array_tree_map *map, CCC_Destructor const *destructor, CCC_Allocator const *allocator)
Frees all slots in the map and frees the underlying buffer.
CCC_Array_tree_map_handle CCC_array_tree_map_handle(CCC_Array_tree_map const *map, void const *key)
Obtains a handle for the provided key in the map for future use.
CCC_Handle_index CCC_array_tree_map_or_insert(CCC_Array_tree_map_handle const *handle, void const *type, CCC_Allocator const *allocator)
Inserts the provided user type if the handle is Vacant.
CCC_Handle_index CCC_array_tree_map_get_key_value(CCC_Array_tree_map const *map, void const *key)
Returns a reference into the map at handle key.
CCC_Handle CCC_array_tree_map_remove_key_value(CCC_Array_tree_map *map, void *type_output)
Removes the key value in the map storing the old value, if present, in the type_output provided by th...
CCC_Handle CCC_array_tree_map_try_insert(CCC_Array_tree_map *map, void const *type, CCC_Allocator const *allocator)
Attempts to insert the key value in type.
CCC_Tribool CCC_array_tree_map_is_empty(CCC_Array_tree_map const *map)
Returns the size status of the map.
CCC_Count CCC_array_tree_map_capacity(CCC_Array_tree_map const *map)
Returns the capacity of the map representing total available slots.
CCC_Handle_index CCC_array_tree_map_next(CCC_Array_tree_map const *map, CCC_Handle_index iterator)
Return the next element in an inorder traversal of the map. O(1).
CCC_Handle CCC_array_tree_map_remove_handle(CCC_Array_tree_map_handle const *handle)
Remove the handle from the map if Occupied.
CCC_Handle_index CCC_array_tree_map_unwrap(CCC_Array_tree_map_handle const *handle)
Unwraps the provided handle to obtain a view into the map element.
CCC_Tribool CCC_array_tree_map_insert_error(CCC_Array_tree_map_handle const *handle)
Provides the status of the handle should an insertion follow.
CCC_Handle_range CCC_array_tree_map_equal_range(CCC_Array_tree_map const *map, void const *begin_key, void const *end_key)
Return an iterable range of values from [begin_key, end_key). O(lgN).
CCC_Array_tree_map_handle * CCC_array_tree_map_and_modify(CCC_Array_tree_map_handle *handle, CCC_Modifier const *modifier)
Modifies the provided handle if it is Occupied.
void * CCC_array_tree_map_at(CCC_Array_tree_map const *map, CCC_Handle_index index)
Returns a reference to the user data at the provided handle.
CCC_Handle_index CCC_array_tree_map_reverse_end(CCC_Array_tree_map const *map)
Return the reverse_end of a reverse inorder traversal of the map. O(1).
CCC_Handle_status CCC_array_tree_map_handle_status(CCC_Array_tree_map_handle const *handle)
Obtain the handle status from a container handle.
CCC_Handle_index CCC_array_tree_map_end(CCC_Array_tree_map const *map)
Return the end of an inorder traversal of the map. O(1).
CCC_Result CCC_array_tree_map_clear(CCC_Array_tree_map *map, CCC_Destructor const *destructor)
Frees all slots in the map for use without affecting capacity.
CCC_Handle CCC_array_tree_map_insert_or_assign(CCC_Array_tree_map *map, void const *type, CCC_Allocator const *allocator)
Invariantly inserts or overwrites a user struct into the map.
CCC_Tribool CCC_array_tree_map_contains(CCC_Array_tree_map const *map, void const *key)
Searches the map for the presence of key.
CCC_Result CCC_array_tree_map_copy(CCC_Array_tree_map *destination, CCC_Array_tree_map const *source, CCC_Allocator const *allocator)
Copy the map at source to destination.
The Private Array Tree Map Types and Interface.
The type passed by reference to any container function that may need to allocate memory....
Definition: types.h:384
Definition: private_array_tree_map.h:174
size_t index
Definition: private_array_tree_map.h:178
struct CCC_Array_tree_map * map
Definition: private_array_tree_map.h:176
Definition: private_array_tree_map.h:148
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:243
The type passed by reference to any container function that may need to destroy elements....
Definition: types.h:472
The result of a range_reverse query on iterable containers. Handles are stable indices into an array ...
Definition: types.h:97
The result of a range query on iterable containers. Handles are stable indices into an array until re...
Definition: types.h:82
An Occupied or Vacant handle to a flat searchable container entry.
Definition: types.h:150
The type passed by reference to any container function that may need to modify elements....
Definition: types.h:444
The C Container Collection Fundamental Types.
size_t CCC_Handle_index
A stable index to user data in a container that uses a flat array as the underlying storage method.
Definition: types.h:72
CCC_Entry_status
The status monitoring and entry state once it is obtained.
Definition: types.h:112
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:178
CCC_Result
A result of actions on containers.
Definition: types.h:192