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
144#define CCC_array_tree_map_storage_for( \
145 user_type_compound_literal_array, optional_storage_specifier... \
146) \
147 CCC_private_array_tree_map_storage_for( \
148 user_type_compound_literal_array, optional_storage_specifier \
149 )
150
156#define CCC_array_tree_map_default(type_name, type_key_field, comparator...) \
157 CCC_private_array_tree_map_default(type_name, type_key_field, comparator)
158
167#define CCC_array_tree_map_for( \
168 type_name, type_key_field, comparator, capacity, memory_pointer \
169) \
170 CCC_private_array_tree_map_for( \
171 type_name, type_key_field, comparator, capacity, memory_pointer \
172 )
173
225#define CCC_array_tree_map_from( \
226 type_key_field, \
227 comparator, \
228 allocator, \
229 optional_capacity, \
230 type_compound_literal_array... \
231) \
232 CCC_private_array_tree_map_from( \
233 type_key_field, \
234 comparator, \
235 allocator, \
236 optional_capacity, \
237 type_compound_literal_array \
238 )
239
283#define CCC_array_tree_map_with_capacity( \
284 type_name, type_key_field, comparator, allocator, capacity \
285) \
286 CCC_private_array_tree_map_with_capacity( \
287 type_name, type_key_field, comparator, allocator, capacity \
288 )
289
319#define CCC_array_tree_map_with_storage( \
320 type_key_field, \
321 comparator, \
322 compound_literal, \
323 optional_storage_specifier... \
324) \
325 CCC_private_array_tree_map_with_storage( \
326 type_key_field, \
327 comparator, \
328 compound_literal, \
329 optional_storage_specifier \
330 )
331
402 CCC_Array_tree_map *destination,
403 CCC_Array_tree_map const *source,
404 CCC_Allocator const *allocator
405);
406
414 CCC_Array_tree_map *map, size_t to_add, CCC_Allocator const *allocator
415);
416
433[[nodiscard]] void *
435
442#define CCC_array_tree_map_as( \
443 array_tree_map_pointer, type_name, array_index... \
444) \
445 CCC_private_array_tree_map_as( \
446 array_tree_map_pointer, type_name, array_index \
447 )
448
454[[nodiscard]] CCC_Tribool
456
462 CCC_Array_tree_map const *map, void const *key
463);
464
483 CCC_Array_tree_map *map, void *type_output, CCC_Allocator const *allocator
484);
485
497#define CCC_array_tree_map_swap_handle_wrap( \
498 array_tree_map_pointer, type_output_pointer, allocator_pointer... \
499) \
500 &(struct { CCC_Handle private; }){ \
501 CCC_array_tree_map_swap_handle( \
502 (array_tree_map_pointer), (type_output_pointer), allocator_pointer \
503 )} \
504 .private
505
515 CCC_Array_tree_map *map, void const *type, CCC_Allocator const *allocator
516);
517
526#define CCC_array_tree_map_try_insert_wrap( \
527 array_tree_map_pointer, type_pointer, allocator_pointer... \
528) \
529 &(struct { CCC_Handle private; }){ \
530 CCC_array_tree_map_try_insert( \
531 (array_tree_map_pointer), (type_pointer), allocator_pointer \
532 )} \
533 .private
534
549#define CCC_array_tree_map_try_insert_with( \
550 array_tree_map_pointer, key, allocator_pointer, type_compound_literal... \
551) \
552 &(struct { CCC_Handle private; }){ \
553 CCC_private_array_tree_map_try_insert_with( \
554 array_tree_map_pointer, \
555 key, \
556 allocator_pointer, \
557 type_compound_literal \
558 )} \
559 .private
560
571 CCC_Array_tree_map *map, void const *type, CCC_Allocator const *allocator
572);
573
583#define CCC_array_tree_map_insert_or_assign_wrap( \
584 map_pointer, type_pointer, allocator_pointer... \
585) \
586 &(struct { CCC_Handle private; }){ \
587 CCC_array_tree_map_insert_or_assign( \
588 map_pointer, type_pointer, allocator_pointer \
589 )} \
590 .private
591
605#define CCC_array_tree_map_insert_or_assign_with( \
606 array_tree_map_pointer, key, allocator_pointer, type_compound_literal... \
607) \
608 &(struct { CCC_Handle private; }){ \
609 CCC_private_array_tree_map_insert_or_assign_with( \
610 array_tree_map_pointer, \
611 key, \
612 allocator_pointer, \
613 type_compound_literal \
614 )} \
615 .private
616
626[[nodiscard]] CCC_Handle
628
639#define CCC_array_tree_map_remove_key_value_wrap( \
640 array_tree_map_pointer, type_output_pointer \
641) \
642 &(struct { CCC_Handle private; }){ \
643 CCC_array_tree_map_remove_key_value( \
644 (array_tree_map_pointer), (type_output_pointer) \
645 )} \
646 .private
647
663[[nodiscard]] CCC_Array_tree_map_handle
665
682#define CCC_array_tree_map_handle_wrap(array_tree_map_pointer, key_pointer) \
683 &(struct { CCC_Array_tree_map_handle private; }){ \
684 CCC_array_tree_map_handle((array_tree_map_pointer), (key_pointer))} \
685 .private
686
692 CCC_Array_tree_map_handle *handle, CCC_Modifier const *modifier
693);
694
730#define CCC_array_tree_map_and_modify_with( \
731 map_array_pointer, closure_parameter, closure_over_closure_parameter... \
732) \
733 &( \
734 struct { CCC_Array_tree_map_handle private; } \
735 ){CCC_private_array_tree_map_and_modify_with( \
736 map_array_pointer, closure_parameter, closure_over_closure_parameter \
737 )} \
738 .private
739
753 CCC_Array_tree_map_handle const *handle,
754 void const *type,
755 CCC_Allocator const *allocator
756);
757
770#define CCC_array_tree_map_or_insert_with( \
771 map_array_pointer, allocator_pointer, type_compound_literal... \
772) \
773 CCC_private_array_tree_map_or_insert_with( \
774 map_array_pointer, allocator_pointer, type_compound_literal \
775 )
776
786 CCC_Array_tree_map_handle const *handle,
787 void const *type,
788 CCC_Allocator const *allocator
789);
790
798#define CCC_array_tree_map_insert_handle_with( \
799 map_array_pointer, allocator_pointer, type_compound_literal... \
800) \
801 CCC_private_array_tree_map_insert_handle_with( \
802 map_array_pointer, allocator_pointer, type_compound_literal \
803 )
804
814
823#define CCC_array_tree_map_remove_handle_wrap(map_array_pointer) \
824 &(struct { CCC_Handle private; }){ \
825 CCC_array_tree_map_remove_handle((map_array_pointer))} \
826 .private
827
831[[nodiscard]] CCC_Handle_index
833
838[[nodiscard]] CCC_Tribool
840
846[[nodiscard]] CCC_Tribool
848
858[[nodiscard]] CCC_Handle_status
860
876 CCC_Array_tree_map *map, CCC_Destructor const *destructor
877);
878
893 CCC_Destructor const *destructor,
894 CCC_Allocator const *allocator
895);
896
923 CCC_Array_tree_map const *map, void const *begin_key, void const *end_key
924);
925
932#define CCC_array_tree_map_equal_range_wrap( \
933 array_tree_map_pointer, begin_and_end_key_pointers... \
934) \
935 &(struct { CCC_Handle_range private; }){ \
936 CCC_array_tree_map_equal_range( \
937 (array_tree_map_pointer), begin_and_end_key_pointers \
938 )} \
939 .private
940
965 CCC_Array_tree_map const *map,
966 void const *reverse_begin_key,
967 void const *reverse_end_key
968);
969
977#define CCC_array_tree_map_equal_range_reverse_wrap( \
978 array_tree_map_pointer, reverse_begin_and_reverse_end_key_pointers... \
979) \
980 &( \
981 struct { CCC_Handle_range_reverse private; } \
982 ){CCC_array_tree_map_equal_range_reverse( \
983 (array_tree_map_pointer), reverse_begin_and_reverse_end_key_pointers \
984 )} \
985 .private
986
990[[nodiscard]] CCC_Handle_index
992
996[[nodiscard]] CCC_Handle_index
998
1006 CCC_Array_tree_map const *map, CCC_Handle_index iterator
1007);
1008
1017 CCC_Array_tree_map const *map, CCC_Handle_index iterator
1018);
1019
1023[[nodiscard]] CCC_Handle_index
1025
1030[[nodiscard]] CCC_Handle_index
1032
1043[[nodiscard]] CCC_Tribool
1045
1051
1056[[nodiscard]] CCC_Count
1058
1063[[nodiscard]] CCC_Tribool
1065
1070#ifdef ARRAY_TREE_MAP_USING_NAMESPACE_CCC
1071/* NOLINTBEGIN(readability-identifier-naming) */
1072typedef CCC_Array_tree_map Array_tree_map;
1073typedef CCC_Array_tree_map_handle Array_tree_map_handle;
1074# define array_tree_map_storage_for(arguments...) \
1075 CCC_array_tree_map_storage_for(arguments)
1076# define array_tree_map_default(arguments...) \
1077 CCC_array_tree_map_default(arguments)
1078# define array_tree_map_for(arguments...) CCC_array_tree_map_for(arguments)
1079# define array_tree_map_from(arguments...) CCC_array_tree_map_from(arguments)
1080# define array_tree_map_with_capacity(arguments...) \
1081 CCC_array_tree_map_with_capacity(arguments)
1082# define array_tree_map_with_storage(arguments...) \
1083 CCC_array_tree_map_with_storage(arguments)
1084# define array_tree_map_copy(arguments...) CCC_array_tree_map_copy(arguments)
1085# define array_tree_map_reserve(arguments...) \
1086 CCC_array_tree_map_reserve(arguments)
1087# define array_tree_map_at(arguments...) CCC_array_tree_map_at(arguments)
1088# define array_tree_map_as(arguments...) CCC_array_tree_map_as(arguments)
1089# define array_tree_map_and_modify(arguments...) \
1090 CCC_array_tree_map_and_modify(arguments)
1091# define array_tree_map_and_modify_with(arguments...) \
1092 CCC_array_tree_map_and_modify_with(arguments)
1093# define array_tree_map_or_insert(arguments...) \
1094 CCC_array_tree_map_or_insert(arguments)
1095# define array_tree_map_or_insert_with(arguments...) \
1096 CCC_array_tree_map_or_insert_with(arguments)
1097# define array_tree_map_insert_handle_with(arguments...) \
1098 CCC_array_tree_map_insert_handle_with(arguments)
1099# define array_tree_map_insert_handle(arguments...) \
1100 CCC_array_tree_map_insert_handle(arguments)
1101# define array_tree_map_try_insert(arguments...) \
1102 CCC_array_tree_map_try_insert(arguments)
1103# define array_tree_map_try_insert_wrap(arguments...) \
1104 CCC_array_tree_map_try_insert_wrap(arguments)
1105# define array_tree_map_try_insert_with(arguments...) \
1106 CCC_array_tree_map_try_insert_with(arguments)
1107# define array_tree_map_insert_or_assign(arguments...) \
1108 CCC_array_tree_map_insert_or_assign(arguments)
1109# define array_tree_map_insert_or_assign_wrap(arguments...) \
1110 CCC_array_tree_map_insert_or_assign_wrap(arguments)
1111# define array_tree_map_insert_or_assign_with(arguments...) \
1112 CCC_array_tree_map_insert_or_assign_with(arguments)
1113# define array_tree_map_contains(arguments...) \
1114 CCC_array_tree_map_contains(arguments)
1115# define array_tree_map_get_key_value(arguments...) \
1116 CCC_array_tree_map_get_key_value(arguments)
1117# define array_tree_map_handle(arguments...) \
1118 CCC_array_tree_map_handle(arguments)
1119# define array_tree_map_handle_wrap(arguments...) \
1120 CCC_array_tree_map_handle_wrap(arguments)
1121# define array_tree_map_remove_handle(arguments...) \
1122 CCC_array_tree_map_remove_handle(arguments)
1123# define array_tree_map_remove_handle_wrap(arguments...) \
1124 CCC_array_tree_map_remove_handle_wrap(arguments)
1125# define array_tree_map_remove_key_value(arguments...) \
1126 CCC_array_tree_map_remove_key_value(arguments)
1127# define array_tree_map_remove_key_value_wrap(arguments...) \
1128 CCC_array_tree_map_remove_key_value_wrap(arguments)
1129# define array_tree_map_swap_handle(arguments...) \
1130 CCC_array_tree_map_swap_handle(arguments)
1131# define array_tree_map_swap_handle_wrap(arguments...) \
1132 CCC_array_tree_map_swap_handle_wrap(arguments)
1133# define array_tree_map_begin(arguments...) \
1134 CCC_array_tree_map_begin(arguments)
1135# define array_tree_map_reverse_begin(arguments...) \
1136 CCC_array_tree_map_reverse_begin(arguments)
1137# define array_tree_map_next(arguments...) CCC_array_tree_map_next(arguments)
1138# define array_tree_map_reverse_next(arguments...) \
1139 CCC_array_tree_map_reverse_next(arguments)
1140# define array_tree_map_end(arguments...) CCC_array_tree_map_end(arguments)
1141# define array_tree_map_reverse_end(arguments...) \
1142 CCC_array_tree_map_reverse_end(arguments)
1143# define array_tree_map_equal_range(arguments...) \
1144 CCC_array_tree_map_equal_range(arguments)
1145# define array_tree_map_equal_range_wrap(arguments...) \
1146 CCC_array_tree_map_equal_range_wrap(arguments)
1147# define array_tree_map_equal_range_reverse(arguments...) \
1148 CCC_array_tree_map_equal_range_reverse(arguments)
1149# define array_tree_map_equal_range_reverse_wrap(arguments...) \
1150 CCC_array_tree_map_equal_range_reverse_wrap(arguments)
1151# define array_tree_map_is_empty(arguments...) \
1152 CCC_array_tree_map_is_empty(arguments)
1153# define array_tree_map_count(arguments...) \
1154 CCC_array_tree_map_count(arguments)
1155# define array_tree_map_capacity(arguments...) \
1156 CCC_array_tree_map_capacity(arguments)
1157# define array_tree_map_clear(arguments...) \
1158 CCC_array_tree_map_clear(arguments)
1159# define array_tree_map_clear_and_free(arguments...) \
1160 CCC_array_tree_map_clear_and_free(arguments)
1161# define array_tree_map_validate(arguments...) \
1162 CCC_array_tree_map_validate(arguments)
1163# define array_tree_map_unwrap(arguments...) \
1164 CCC_array_tree_map_unwrap(arguments)
1165# define array_tree_map_insert_error(arguments...) \
1166 CCC_array_tree_map_insert_error(arguments)
1167# define array_tree_map_occupied(arguments...) \
1168 CCC_array_tree_map_occupied(arguments)
1169# define array_tree_map_handle_status(arguments...) \
1170 CCC_array_tree_map_handle_status(arguments)
1171/* NOLINTEND(readability-identifier-naming) */
1172#endif /* ARRAY_TREE_MAP_USING_NAMESPACE_CCC */
1173
1174#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:376
Definition: private_array_tree_map.h:155
size_t index
Definition: private_array_tree_map.h:159
struct CCC_Array_tree_map * map
Definition: private_array_tree_map.h:157
Definition: private_array_tree_map.h:131
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:244
The type passed by reference to any container function that may need to destroy elements....
Definition: types.h:464
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:436
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