C Container Collection (CCC)
Loading...
Searching...
No Matches
array_tree_map.h
Go to the documentation of this file.
1
55#ifndef CCC_ARRAY_TREE_MAP_H
56#define CCC_ARRAY_TREE_MAP_H
57
59#include <stddef.h>
62#include "private/private_array_tree_map.h"
63#include "types.h"
64
76
86
151#define CCC_array_tree_map_declare_fixed(fixed_map_type_name, type_name, \
152 capacity) \
153 CCC_private_array_tree_map_declare_fixed(fixed_map_type_name, type_name, \
154 capacity)
155
159#define CCC_array_tree_map_fixed_capacity(fixed_map_type_name) \
160 CCC_private_array_tree_map_fixed_capacity(fixed_map_type_name)
161
173#define CCC_array_tree_map_initialize(type_name, type_key_field, compare, \
174 allocate, context_data, capacity, \
175 memory_pointer) \
176 CCC_private_array_tree_map_initialize(type_name, type_key_field, compare, \
177 allocate, context_data, capacity, \
178 memory_pointer)
179
236#define CCC_array_tree_map_from(type_key_field, compare, allocate, \
237 context_data, optional_capacity, \
238 type_compound_literal_array...) \
239 CCC_private_array_tree_map_from(type_key_field, compare, allocate, \
240 context_data, optional_capacity, \
241 type_compound_literal_array)
242
288#define CCC_array_tree_map_with_capacity(type_name, type_key_field, compare, \
289 allocate, context_data, capacity) \
290 CCC_private_array_tree_map_with_capacity( \
291 type_name, type_key_field, compare, allocate, context_data, capacity)
292
320#define CCC_array_tree_map_with_compound_literal(type_key_field, compare, \
321 compound_literal) \
322 CCC_private_array_tree_map_with_compound_literal(type_key_field, compare, \
323 compound_literal)
324
354#define CCC_array_tree_map_with_context_compound_literal( \
355 type_key_field, compare, context, compound_literal) \
356 CCC_private_array_tree_map_with_context_compound_literal( \
357 type_key_field, compare, context, compound_literal)
358
387#define CCC_array_tree_map_with_allocator(type_name, type_key_field, compare, \
388 allocate) \
389 CCC_private_array_tree_map_with_allocator(type_name, type_key_field, \
390 compare, allocate)
391
422#define CCC_array_tree_map_with_context_allocator(type_name, type_key_field, \
423 compare, allocate, context) \
424 CCC_private_array_tree_map_with_context_allocator( \
425 type_name, type_key_field, compare, allocate, context)
426
554 CCC_Array_tree_map const *source,
555 CCC_Allocator *allocate);
556
577 CCC_Allocator *allocate);
578
595[[nodiscard]] void *CCC_array_tree_map_at(CCC_Array_tree_map const *handle,
596 CCC_Handle_index index);
597
604#define CCC_array_tree_map_as(array_tree_map_pointer, type_name, \
605 array_index...) \
606 CCC_private_array_tree_map_as(array_tree_map_pointer, type_name, \
607 array_index)
608
614[[nodiscard]] CCC_Tribool
616
621[[nodiscard]] CCC_Handle_index
623 void const *key);
624
642 void *type_output);
643
654#define CCC_array_tree_map_swap_handle_wrap(array_tree_map_pointer, \
655 type_output_pointer) \
656 &(CCC_Handle) \
657 { \
658 CCC_array_tree_map_swap_handle((array_tree_map_pointer), \
659 (type_output_pointer)) \
660 .private \
661 }
662
671 void const *type);
672
680#define CCC_array_tree_map_try_insert_wrap(array_tree_map_pointer, \
681 type_pointer) \
682 &(CCC_Handle) \
683 { \
684 CCC_array_tree_map_try_insert((array_tree_map_pointer), \
685 (type_pointer)) \
686 .private \
687 }
688
702#define CCC_array_tree_map_try_insert_with(array_tree_map_pointer, key, \
703 type_compound_literal...) \
704 &(CCC_Handle) \
705 { \
706 CCC_private_array_tree_map_try_insert_with(array_tree_map_pointer, \
707 key, type_compound_literal) \
708 }
709
718[[nodiscard]] CCC_Handle
720
734#define CCC_array_tree_map_insert_or_assign_with(array_tree_map_pointer, key, \
735 type_compound_literal...) \
736 &(CCC_Handle) \
737 { \
738 CCC_private_array_tree_map_insert_or_assign_with( \
739 array_tree_map_pointer, key, type_compound_literal) \
740 }
741
751[[nodiscard]] CCC_Handle
753
764#define CCC_array_tree_map_remove_key_value_wrap(array_tree_map_pointer, \
765 type_output_pointer) \
766 &(CCC_Handle) \
767 { \
768 CCC_array_tree_map_remove_key_value((array_tree_map_pointer), \
769 (type_output_pointer)) \
770 .private \
771 }
772
788[[nodiscard]] CCC_Array_tree_map_handle
790
807#define CCC_array_tree_map_handle_wrap(array_tree_map_pointer, key_pointer) \
808 &(CCC_Array_tree_map_handle) \
809 { \
810 CCC_array_tree_map_handle((array_tree_map_pointer), (key_pointer)) \
811 .private \
812 }
813
823[[nodiscard]] CCC_Array_tree_map_handle *
825 CCC_Type_modifier *modify);
826
835[[nodiscard]] CCC_Array_tree_map_handle *
837 CCC_Type_modifier *modify, void *context);
838
876#define CCC_array_tree_map_and_modify_with(map_array_pointer, type_name, \
877 closure_over_T...) \
878 &(CCC_Array_tree_map_handle) \
879 { \
880 CCC_private_array_tree_map_and_modify_with(map_array_pointer, \
881 type_name, closure_over_T) \
882 }
883
895[[nodiscard]] CCC_Handle_index
897 void const *type);
898
911#define CCC_array_tree_map_or_insert_with(map_array_pointer, \
912 type_compound_literal...) \
913 CCC_private_array_tree_map_or_insert_with(map_array_pointer, \
914 type_compound_literal)
915
923[[nodiscard]] CCC_Handle_index
925 void const *type);
926
934#define CCC_array_tree_map_insert_array_with(map_array_pointer, \
935 type_compound_literal...) \
936 CCC_private_array_tree_map_insert_array_with(map_array_pointer, \
937 type_compound_literal)
938
948
957#define CCC_array_tree_map_remove_handle_wrap(map_array_pointer) \
958 &(CCC_Handle) \
959 { \
960 CCC_array_tree_map_remove_handle((map_array_pointer)).private \
961 }
962
966[[nodiscard]] CCC_Handle_index
968
973[[nodiscard]] CCC_Tribool
975
981[[nodiscard]] CCC_Tribool
983
993[[nodiscard]] CCC_Handle_status
995
1010 CCC_Type_destructor *destroy);
1011
1023 CCC_Type_destructor *destroy);
1024
1060 CCC_Type_destructor *destroy,
1061 CCC_Allocator *allocate);
1062
1088[[nodiscard]] CCC_Handle_range
1090 void const *begin_key, void const *end_key);
1091
1098#define CCC_array_tree_map_equal_range_wrap(array_tree_map_pointer, \
1099 begin_and_end_key_pointers...) \
1100 &(CCC_Handle_range) \
1101 { \
1102 CCC_array_tree_map_equal_range((array_tree_map_pointer), \
1103 (begin_and_end_key_pointers)) \
1104 .private \
1105 }
1106
1130[[nodiscard]] CCC_Handle_range_reverse
1132 void const *reverse_begin_key,
1133 void const *reverse_end_key);
1134
1142#define CCC_array_tree_map_equal_range_reverse_wrap( \
1143 array_tree_map_pointer, reverse_begin_and_reverse_end_key_pointers...) \
1144 &(CCC_Handle_range_reverse) \
1145 { \
1146 CCC_array_tree_map_equal_range_reverse( \
1147 (array_tree_map_pointer), \
1148 (reverse_begin_and_reverse_end_key_pointers)) \
1149 .private \
1150 }
1151
1155[[nodiscard]] CCC_Handle_index
1157
1161[[nodiscard]] CCC_Handle_index
1163
1170[[nodiscard]] CCC_Handle_index
1172 CCC_Handle_index iterator);
1173
1181[[nodiscard]] CCC_Handle_index
1183 CCC_Handle_index iterator);
1184
1188[[nodiscard]] CCC_Handle_index
1190
1195[[nodiscard]] CCC_Handle_index
1197
1208[[nodiscard]] CCC_Tribool
1210
1216
1221[[nodiscard]] CCC_Count
1223
1228[[nodiscard]] CCC_Tribool
1230
1235#ifdef ARRAY_TREE_MAP_USING_NAMESPACE_CCC
1236typedef CCC_Array_tree_map Array_tree_map;
1237typedef CCC_Array_tree_map_handle Array_tree_map_handle;
1238# define array_tree_map_declare_fixed(arguments...) \
1239 CCC_array_tree_map_declare_fixed(arguments)
1240# define array_tree_map_initialize(arguments...) \
1241 CCC_array_tree_map_initialize(arguments)
1242# define array_tree_map_from(arguments...) CCC_array_tree_map_from(arguments)
1243# define array_tree_map_with_capacity(arguments...) \
1244 CCC_array_tree_map_with_capacity(arguments)
1245# define array_tree_map_with_compound_literal(arguments...) \
1246 CCC_array_tree_map_with_compound_literal(arguments)
1247# define array_tree_map_with_context_compound_literal(arguments...) \
1248 CCC_array_tree_map_with_context_compound_literal(arguments)
1249# define array_tree_map_with_allocator(arguments...) \
1250 CCC_array_tree_map_with_allocator(arguments)
1251# define array_tree_map_with_context_allocator(arguments...) \
1252 CCC_array_tree_map_with_context_allocator(arguments)
1253# define array_tree_map_fixed_capacity(arguments...) \
1254 CCC_array_tree_map_fixed_capacity(arguments)
1255# define array_tree_map_copy(arguments...) CCC_array_tree_map_copy(arguments)
1256# define array_tree_map_reserve(arguments...) \
1257 CCC_array_tree_map_reserve(arguments)
1258# define array_tree_map_at(arguments...) CCC_array_tree_map_at(arguments)
1259# define array_tree_map_as(arguments...) CCC_array_tree_map_as(arguments)
1260# define array_tree_map_and_modify_with(arguments...) \
1261 CCC_array_tree_map_and_modify_with(arguments)
1262# define array_tree_map_or_insert_with(arguments...) \
1263 CCC_array_tree_map_or_insert_with(arguments)
1264# define array_tree_map_insert_array_with(arguments...) \
1265 CCC_array_tree_map_insert_array_with(arguments)
1266# define array_tree_map_try_insert_with(arguments...) \
1267 CCC_array_tree_map_try_insert_with(arguments)
1268# define array_tree_map_insert_or_assign_with(arguments...) \
1269 CCC_array_tree_map_insert_or_assign_with(arguments)
1270# define array_tree_map_contains(arguments...) \
1271 CCC_array_tree_map_contains(arguments)
1272# define array_tree_map_get_key_value(arguments...) \
1273 CCC_array_tree_map_get_key_value(arguments)
1274# define array_tree_map_swap_handle(arguments...) \
1275 CCC_array_tree_map_swap_handle(arguments)
1276# define array_tree_map_swap_handle_wrap(arguments...) \
1277 CCC_array_tree_map_swap_handle_wrap(arguments)
1278# define array_tree_map_begin(arguments...) \
1279 CCC_array_tree_map_begin(arguments)
1280# define array_tree_map_reverse_begin(arguments...) \
1281 CCC_array_tree_map_reverse_begin(arguments)
1282# define array_tree_map_next(arguments...) CCC_array_tree_map_next(arguments)
1283# define array_tree_map_reverse_next(arguments...) \
1284 CCC_array_tree_map_reverse_next(arguments)
1285# define array_tree_map_end(arguments...) CCC_array_tree_map_end(arguments)
1286# define array_tree_map_reverse_end(arguments...) \
1287 CCC_array_tree_map_reverse_end(arguments)
1288# define array_tree_map_is_empty(arguments...) \
1289 CCC_array_tree_map_is_empty(arguments)
1290# define array_tree_map_count(arguments...) \
1291 CCC_array_tree_map_count(arguments)
1292# define array_tree_map_capacity(arguments...) \
1293 CCC_array_tree_map_capacity(arguments)
1294# define array_tree_map_clear(arguments...) \
1295 CCC_array_tree_map_clear(arguments)
1296# define array_tree_map_clear_and_free(arguments...) \
1297 CCC_array_tree_map_clear_and_free(arguments)
1298# define array_tree_map_clear_and_free_reserve(arguments...) \
1299 CCC_array_tree_map_clear_and_free_reserve(arguments)
1300# define array_tree_map_validate(arguments...) \
1301 CCC_array_tree_map_validate(arguments)
1302#endif /* ARRAY_TREE_MAP_USING_NAMESPACE_CCC */
1303
1304#endif /* CCC_ARRAY_TREE_MAP_H */
CCC_Handle CCC_array_tree_map_swap_handle(CCC_Array_tree_map *map, void *type_output)
Invariantly inserts the key value in type_output.
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_Result CCC_array_tree_map_copy(CCC_Array_tree_map *destination, CCC_Array_tree_map const *source, CCC_Allocator *allocate)
Copy the map at source to destination.
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_Array_tree_map_handle * CCC_array_tree_map_and_modify(CCC_Array_tree_map_handle *handle, CCC_Type_modifier *modify)
Modifies the provided handle if it is Occupied.
CCC_Result CCC_array_tree_map_clear_and_free_reserve(CCC_Array_tree_map *map, CCC_Type_destructor *destroy, CCC_Allocator *allocate)
Frees all slots in the map and frees the underlying Buffer that was previously dynamically reserved w...
CCC_Result CCC_array_tree_map_reserve(CCC_Array_tree_map *map, size_t to_add, CCC_Allocator *allocate)
Reserves space for at least to_add more elements.
CCC_Count CCC_array_tree_map_count(CCC_Array_tree_map const *map)
Returns the count of map occupied slots.
CCC_Tribool CCC_array_tree_map_occupied(CCC_Array_tree_map_handle const *handle)
Returns the Vacant or Occupied status of the handle.
CCC_Array_tree_map_handle * CCC_array_tree_map_and_modify_context(CCC_Array_tree_map_handle *handle, CCC_Type_modifier *modify, void *context)
Modifies the provided handle if it is Occupied.
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_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_Result CCC_array_tree_map_clear(CCC_Array_tree_map *map, CCC_Type_destructor *destroy)
Frees all slots in the map for use without affecting capacity.
CCC_Handle CCC_array_tree_map_try_insert(CCC_Array_tree_map *map, void const *type)
Attempts to insert the key value in type.
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 struct containing type_out...
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_insert_or_assign(CCC_Array_tree_map *map, void const *type)
Invariantly inserts or overwrites a user struct into the map.
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_or_insert(CCC_Array_tree_map_handle const *handle, void const *type)
Inserts the provided user type if the handle is Vacant.
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_Result CCC_array_tree_map_clear_and_free(CCC_Array_tree_map *map, CCC_Type_destructor *destroy)
Frees all slots in the map and frees the underlying buffer.
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_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_index CCC_array_tree_map_insert_handle(CCC_Array_tree_map_handle const *handle, void const *type)
Inserts the provided user type invariantly.
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_Tribool CCC_array_tree_map_contains(CCC_Array_tree_map const *map, void const *key)
Searches the map for the presence of key.
Definition: private_array_tree_map.h:166
Definition: private_array_tree_map.h:137
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:202
Definition: private_types.h:173
Definition: private_types.h:80
The C Container Collection Fundamental Types.
enum CCC_Entry_status CCC_Handle_status
The status monitoring and handle state once it is obtained.
Definition: types.h:119
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:109
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_Allocator(CCC_Allocator_context)
An allocation function at the core of all containers.
Definition: types.h:340
void CCC_Type_modifier(CCC_Type_context)
A callback function for modifying an element in the container.
Definition: types.h:358
Definition: private_array_tree_map.h:179
Definition: private_types.h:221