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>
67#include "private/private_array_tree_map.h"
68#include "types.h"
69
81
91
142#define CCC_array_tree_map_storage_for( \
143 user_type_compound_literal_array, optional_storage_specifier... \
144) \
145 CCC_private_array_tree_map_storage_for( \
146 user_type_compound_literal_array, optional_storage_specifier \
147 )
148
154#define CCC_array_tree_map_default(type_name, type_key_field, comparator...) \
155 CCC_private_array_tree_map_default(type_name, type_key_field, comparator)
156
165#define CCC_array_tree_map_for( \
166 type_name, type_key_field, comparator, capacity, memory_pointer \
167) \
168 CCC_private_array_tree_map_for( \
169 type_name, type_key_field, comparator, capacity, memory_pointer \
170 )
171
223#define CCC_array_tree_map_from( \
224 type_key_field, \
225 comparator, \
226 allocator, \
227 optional_capacity, \
228 type_compound_literal_array... \
229) \
230 CCC_private_array_tree_map_from( \
231 type_key_field, \
232 comparator, \
233 allocator, \
234 optional_capacity, \
235 type_compound_literal_array \
236 )
237
281#define CCC_array_tree_map_with_capacity( \
282 type_name, type_key_field, comparator, allocator, capacity \
283) \
284 CCC_private_array_tree_map_with_capacity( \
285 type_name, type_key_field, comparator, allocator, capacity \
286 )
287
317#define CCC_array_tree_map_with_storage( \
318 type_key_field, \
319 comparator, \
320 compound_literal, \
321 optional_storage_specifier... \
322) \
323 CCC_private_array_tree_map_with_storage( \
324 type_key_field, \
325 comparator, \
326 compound_literal, \
327 optional_storage_specifier \
328 )
329
400 CCC_Array_tree_map *destination,
401 CCC_Array_tree_map const *source,
402 CCC_Allocator const *allocator
403);
404
412 CCC_Array_tree_map *map, size_t to_add, CCC_Allocator const *allocator
413);
414
431[[nodiscard]] void *
433
440#define CCC_array_tree_map_as( \
441 array_tree_map_pointer, type_name, array_index... \
442) \
443 CCC_private_array_tree_map_as( \
444 array_tree_map_pointer, type_name, array_index \
445 )
446
452[[nodiscard]] CCC_Tribool
454
460 CCC_Array_tree_map const *map, void const *key
461);
462
481 CCC_Array_tree_map *map, void *type_output, CCC_Allocator const *allocator
482);
483
495#define CCC_array_tree_map_swap_handle_wrap( \
496 array_tree_map_pointer, type_output_pointer, allocator_pointer... \
497) \
498 &(struct { CCC_Handle private; }){ \
499 CCC_array_tree_map_swap_handle( \
500 (array_tree_map_pointer), (type_output_pointer), allocator_pointer \
501 )} \
502 .private
503
513 CCC_Array_tree_map *map, void const *type, CCC_Allocator const *allocator
514);
515
524#define CCC_array_tree_map_try_insert_wrap( \
525 array_tree_map_pointer, type_pointer, allocator_pointer... \
526) \
527 &(struct { CCC_Handle private; }){ \
528 CCC_array_tree_map_try_insert( \
529 (array_tree_map_pointer), (type_pointer), allocator_pointer \
530 )} \
531 .private
532
547#define CCC_array_tree_map_try_insert_with( \
548 array_tree_map_pointer, key, allocator_pointer, type_compound_literal... \
549) \
550 &(struct { CCC_Handle private; }){ \
551 CCC_private_array_tree_map_try_insert_with( \
552 array_tree_map_pointer, \
553 key, \
554 allocator_pointer, \
555 type_compound_literal \
556 )} \
557 .private
558
569 CCC_Array_tree_map *map, void const *type, CCC_Allocator const *allocator
570);
571
581#define CCC_array_tree_map_insert_or_assign_wrap( \
582 map_pointer, type_pointer, allocator_pointer... \
583) \
584 &(struct { CCC_Handle private; }){ \
585 CCC_array_tree_map_insert_or_assign( \
586 map_pointer, type_pointer, allocator_pointer \
587 )} \
588 .private
589
603#define CCC_array_tree_map_insert_or_assign_with( \
604 array_tree_map_pointer, key, allocator_pointer, type_compound_literal... \
605) \
606 &(struct { CCC_Handle private; }){ \
607 CCC_private_array_tree_map_insert_or_assign_with( \
608 array_tree_map_pointer, \
609 key, \
610 allocator_pointer, \
611 type_compound_literal \
612 )} \
613 .private
614
624[[nodiscard]] CCC_Handle
626
637#define CCC_array_tree_map_remove_key_value_wrap( \
638 array_tree_map_pointer, type_output_pointer \
639) \
640 &(struct { CCC_Handle private; }){ \
641 CCC_array_tree_map_remove_key_value( \
642 (array_tree_map_pointer), (type_output_pointer) \
643 )} \
644 .private
645
661[[nodiscard]] CCC_Array_tree_map_handle
663
680#define CCC_array_tree_map_handle_wrap(array_tree_map_pointer, key_pointer) \
681 &(struct { CCC_Array_tree_map_handle private; }){ \
682 CCC_array_tree_map_handle((array_tree_map_pointer), (key_pointer))} \
683 .private
684
690 CCC_Array_tree_map_handle *handle, CCC_Modifier const *modifier
691);
692
728#define CCC_array_tree_map_and_modify_with( \
729 map_array_pointer, closure_parameter, closure_over_closure_parameter... \
730) \
731 &( \
732 struct { CCC_Array_tree_map_handle private; } \
733 ){CCC_private_array_tree_map_and_modify_with( \
734 map_array_pointer, closure_parameter, closure_over_closure_parameter \
735 )} \
736 .private
737
751 CCC_Array_tree_map_handle const *handle,
752 void const *type,
753 CCC_Allocator const *allocator
754);
755
768#define CCC_array_tree_map_or_insert_with( \
769 map_array_pointer, allocator_pointer, type_compound_literal... \
770) \
771 CCC_private_array_tree_map_or_insert_with( \
772 map_array_pointer, allocator_pointer, type_compound_literal \
773 )
774
784 CCC_Array_tree_map_handle const *handle,
785 void const *type,
786 CCC_Allocator const *allocator
787);
788
796#define CCC_array_tree_map_insert_handle_with( \
797 map_array_pointer, allocator_pointer, type_compound_literal... \
798) \
799 CCC_private_array_tree_map_insert_handle_with( \
800 map_array_pointer, allocator_pointer, type_compound_literal \
801 )
802
812
821#define CCC_array_tree_map_remove_handle_wrap(map_array_pointer) \
822 &(struct { CCC_Handle private; }){ \
823 CCC_array_tree_map_remove_handle((map_array_pointer))} \
824 .private
825
829[[nodiscard]] CCC_Handle_index
831
836[[nodiscard]] CCC_Tribool
838
844[[nodiscard]] CCC_Tribool
846
856[[nodiscard]] CCC_Handle_status
858
874 CCC_Array_tree_map *map, CCC_Destructor const *destructor
875);
876
891 CCC_Destructor const *destructor,
892 CCC_Allocator const *allocator
893);
894
921 CCC_Array_tree_map const *map, void const *begin_key, void const *end_key
922);
923
930#define CCC_array_tree_map_equal_range_wrap( \
931 array_tree_map_pointer, begin_and_end_key_pointers... \
932) \
933 &(struct { CCC_Handle_range private; }){ \
934 CCC_array_tree_map_equal_range( \
935 (array_tree_map_pointer), begin_and_end_key_pointers \
936 )} \
937 .private
938
963 CCC_Array_tree_map const *map,
964 void const *reverse_begin_key,
965 void const *reverse_end_key
966);
967
975#define CCC_array_tree_map_equal_range_reverse_wrap( \
976 array_tree_map_pointer, reverse_begin_and_reverse_end_key_pointers... \
977) \
978 &( \
979 struct { CCC_Handle_range_reverse private; } \
980 ){CCC_array_tree_map_equal_range_reverse( \
981 (array_tree_map_pointer), reverse_begin_and_reverse_end_key_pointers \
982 )} \
983 .private
984
988[[nodiscard]] CCC_Handle_index
990
994[[nodiscard]] CCC_Handle_index
996
1004 CCC_Array_tree_map const *map, CCC_Handle_index iterator
1005);
1006
1015 CCC_Array_tree_map const *map, CCC_Handle_index iterator
1016);
1017
1021[[nodiscard]] CCC_Handle_index
1023
1028[[nodiscard]] CCC_Handle_index
1030
1041[[nodiscard]] CCC_Tribool
1043
1049
1054[[nodiscard]] CCC_Count
1056
1061[[nodiscard]] CCC_Tribool
1063
1068#ifdef ARRAY_TREE_MAP_USING_NAMESPACE_CCC
1069/* NOLINTBEGIN(readability-identifier-naming) */
1070typedef CCC_Array_tree_map Array_tree_map;
1071typedef CCC_Array_tree_map_handle Array_tree_map_handle;
1072# define array_tree_map_storage_for(arguments...) \
1073 CCC_array_tree_map_storage_for(arguments)
1074# define array_tree_map_default(arguments...) \
1075 CCC_array_tree_map_default(arguments)
1076# define array_tree_map_for(arguments...) CCC_array_tree_map_for(arguments)
1077# define array_tree_map_from(arguments...) CCC_array_tree_map_from(arguments)
1078# define array_tree_map_with_capacity(arguments...) \
1079 CCC_array_tree_map_with_capacity(arguments)
1080# define array_tree_map_with_storage(arguments...) \
1081 CCC_array_tree_map_with_storage(arguments)
1082# define array_tree_map_copy(arguments...) CCC_array_tree_map_copy(arguments)
1083# define array_tree_map_reserve(arguments...) \
1084 CCC_array_tree_map_reserve(arguments)
1085# define array_tree_map_at(arguments...) CCC_array_tree_map_at(arguments)
1086# define array_tree_map_as(arguments...) CCC_array_tree_map_as(arguments)
1087# define array_tree_map_and_modify(arguments...) \
1088 CCC_array_tree_map_and_modify(arguments)
1089# define array_tree_map_and_modify_with(arguments...) \
1090 CCC_array_tree_map_and_modify_with(arguments)
1091# define array_tree_map_or_insert(arguments...) \
1092 CCC_array_tree_map_or_insert(arguments)
1093# define array_tree_map_or_insert_with(arguments...) \
1094 CCC_array_tree_map_or_insert_with(arguments)
1095# define array_tree_map_insert_handle_with(arguments...) \
1096 CCC_array_tree_map_insert_handle_with(arguments)
1097# define array_tree_map_insert_handle(arguments...) \
1098 CCC_array_tree_map_insert_handle(arguments)
1099# define array_tree_map_try_insert(arguments...) \
1100 CCC_array_tree_map_try_insert(arguments)
1101# define array_tree_map_try_insert_wrap(arguments...) \
1102 CCC_array_tree_map_try_insert_wrap(arguments)
1103# define array_tree_map_try_insert_with(arguments...) \
1104 CCC_array_tree_map_try_insert_with(arguments)
1105# define array_tree_map_insert_or_assign(arguments...) \
1106 CCC_array_tree_map_insert_or_assign(arguments)
1107# define array_tree_map_insert_or_assign_wrap(arguments...) \
1108 CCC_array_tree_map_insert_or_assign_wrap(arguments)
1109# define array_tree_map_insert_or_assign_with(arguments...) \
1110 CCC_array_tree_map_insert_or_assign_with(arguments)
1111# define array_tree_map_contains(arguments...) \
1112 CCC_array_tree_map_contains(arguments)
1113# define array_tree_map_get_key_value(arguments...) \
1114 CCC_array_tree_map_get_key_value(arguments)
1115# define array_tree_map_handle(arguments...) \
1116 CCC_array_tree_map_handle(arguments)
1117# define array_tree_map_handle_wrap(arguments...) \
1118 CCC_array_tree_map_handle_wrap(arguments)
1119# define array_tree_map_remove_handle(arguments...) \
1120 CCC_array_tree_map_remove_handle(arguments)
1121# define array_tree_map_remove_handle_wrap(arguments...) \
1122 CCC_array_tree_map_remove_handle_wrap(arguments)
1123# define array_tree_map_remove_key_value(arguments...) \
1124 CCC_array_tree_map_remove_key_value(arguments)
1125# define array_tree_map_remove_key_value_wrap(arguments...) \
1126 CCC_array_tree_map_remove_key_value_wrap(arguments)
1127# define array_tree_map_swap_handle(arguments...) \
1128 CCC_array_tree_map_swap_handle(arguments)
1129# define array_tree_map_swap_handle_wrap(arguments...) \
1130 CCC_array_tree_map_swap_handle_wrap(arguments)
1131# define array_tree_map_begin(arguments...) \
1132 CCC_array_tree_map_begin(arguments)
1133# define array_tree_map_reverse_begin(arguments...) \
1134 CCC_array_tree_map_reverse_begin(arguments)
1135# define array_tree_map_next(arguments...) CCC_array_tree_map_next(arguments)
1136# define array_tree_map_reverse_next(arguments...) \
1137 CCC_array_tree_map_reverse_next(arguments)
1138# define array_tree_map_end(arguments...) CCC_array_tree_map_end(arguments)
1139# define array_tree_map_reverse_end(arguments...) \
1140 CCC_array_tree_map_reverse_end(arguments)
1141# define array_tree_map_equal_range(arguments...) \
1142 CCC_array_tree_map_equal_range(arguments)
1143# define array_tree_map_equal_range_wrap(arguments...) \
1144 CCC_array_tree_map_equal_range_wrap(arguments)
1145# define array_tree_map_equal_range_reverse(arguments...) \
1146 CCC_array_tree_map_equal_range_reverse(arguments)
1147# define array_tree_map_equal_range_reverse_wrap(arguments...) \
1148 CCC_array_tree_map_equal_range_reverse_wrap(arguments)
1149# define array_tree_map_is_empty(arguments...) \
1150 CCC_array_tree_map_is_empty(arguments)
1151# define array_tree_map_count(arguments...) \
1152 CCC_array_tree_map_count(arguments)
1153# define array_tree_map_capacity(arguments...) \
1154 CCC_array_tree_map_capacity(arguments)
1155# define array_tree_map_clear(arguments...) \
1156 CCC_array_tree_map_clear(arguments)
1157# define array_tree_map_clear_and_free(arguments...) \
1158 CCC_array_tree_map_clear_and_free(arguments)
1159# define array_tree_map_validate(arguments...) \
1160 CCC_array_tree_map_validate(arguments)
1161# define array_tree_map_unwrap(arguments...) \
1162 CCC_array_tree_map_unwrap(arguments)
1163# define array_tree_map_insert_error(arguments...) \
1164 CCC_array_tree_map_insert_error(arguments)
1165# define array_tree_map_occupied(arguments...) \
1166 CCC_array_tree_map_occupied(arguments)
1167# define array_tree_map_handle_status(arguments...) \
1168 CCC_array_tree_map_handle_status(arguments)
1169/* NOLINTEND(readability-identifier-naming) */
1170#endif /* ARRAY_TREE_MAP_USING_NAMESPACE_CCC */
1171
1172#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...
void * CCC_array_tree_map_at(CCC_Array_tree_map const *handle, CCC_Handle_index index)
Returns a reference to the user data at the provided handle.
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.
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 type passed by reference to any container function that may need to allocate memory....
Definition: types.h:369
Definition: private_array_tree_map.h:157
size_t index
Definition: private_array_tree_map.h:161
struct CCC_Array_tree_map * map
Definition: private_array_tree_map.h:159
Definition: private_array_tree_map.h:133
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:457
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:429
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