52 cmagic_map_free(
void *map_ptr);
79 cmagic_map_allocate(
void *map_ptr,
const void *key);
82 cmagic_map_insert(
void *map_ptr,
const void *key,
const void *value);
88 cmagic_map_clear(
void *map_ptr);
91 cmagic_map_size(
void *map_ptr);
94 cmagic_map_first(
void *map_ptr);
97 cmagic_map_last(
void *map_ptr);
106 cmagic_map_find(
void *map_ptr,
const void *key);
109 cmagic_map_get_alloc_packet(
void *map_ptr);
118 #define CMAGIC_MAP(key_type) key_type* 130 #define CMAGIC_MAP_NEW(key_type, value_type, key_comparator, alloc_packet) ((CMAGIC_MAP(key_type)) \ 131 cmagic_map_new(sizeof(key_type), sizeof(value_type), (key_comparator), (alloc_packet))) 138 #define CMAGIC_MAP_FREE(cmagic_map) cmagic_map_free((void*)(cmagic_map)) 151 #define CMAGIC_MAP_ALLOCATE(cmagic_map, key) \ 152 (CMAGIC_UTILS_ASSERT_SAME_TYPE(*(cmagic_map), *(key)), \ 153 cmagic_map_allocate((void*)(cmagic_map), (key))) 162 #define CMAGIC_MAP_INSERT(cmagic_map, key, value) \ 163 (CMAGIC_UTILS_ASSERT_SAME_TYPE(*(cmagic_map), *(key)), \ 164 cmagic_map_insert((void*)(cmagic_map), (key), (value))) 175 #define CMAGIC_MAP_ERASE_EXT(cmagic_map, key, destructor) \ 176 (CMAGIC_UTILS_ASSERT_SAME_TYPE(*(cmagic_map), *(key)), \ 177 cmagic_map_erase((void*)(cmagic_map), (key), (destructor))) 186 #define CMAGIC_MAP_ERASE(cmagic_map, key) CMAGIC_MAP_ERASE_EXT(cmagic_map, key, NULL) 192 #define CMAGIC_MAP_CLEAR(cmagic_map) cmagic_map_clear((void*)(cmagic_map)) 199 #define CMAGIC_MAP_SIZE(cmagic_map) cmagic_map_size((void*)(cmagic_map)) 208 #define CMAGIC_MAP_FIRST(cmagic_map) cmagic_map_first((void*)(cmagic_map)) 217 #define CMAGIC_MAP_LAST(cmagic_map) cmagic_map_last((void*)(cmagic_map)) 224 #define CMAGIC_MAP_ITERATOR_NEXT(iterator) cmagic_map_iterator_next(iterator) 232 #define CMAGIC_MAP_ITERATOR_PREV(iterator) cmagic_map_iterator_prev(iterator) 240 #define CMAGIC_MAP_FIND(cmagic_map, key) (CMAGIC_UTILS_ASSERT_SAME_TYPE(*(cmagic_map), *(key)), \ 241 cmagic_map_find((void*)(cmagic_map), (key))) 250 #define CMAGIC_MAP_GET_KEY(key_type, iterator) \ 251 (assert(iterator), assert((iterator)->key), *((const key_type*)(iterator)->key)) 260 #define CMAGIC_MAP_GET_VALUE(value_type, iterator) \ 261 (assert(iterator), assert((iterator)->value), *((value_type*)(iterator)->value)) 268 #define CMAGIC_MAP_GET_ALLOC_PACKET(cmagic_map) \ 269 cmagic_map_get_alloc_packet((void*)(cmagic_map)) int(* cmagic_map_key_comparator_t)(const void *key1, const void *key2)
Pointer to a function that compares two keys.
Definition: map.h:36
Portable substitutes of standard malloc() and free() functions.
Set of allocation functions. Used in some CMagic structures to specify a desired memory pool...
Definition: memory.h:187
General purpose utilities.
bool already_exists
true if the element already exists in the map and the map was not modified, false if a new element ha...
Definition: map.h:74
cmagic_map_iterator_t inserted_or_existing
iterator pointing to a new or already existing element or NULL if the allocation of a new element has...
Definition: map.h:68
Map insertion result.
Definition: map.h:62
void(* cmagic_map_erase_destructor_t)(void *key, void *value)
User defined additional tasks to be executed right before map element deletion.
Definition: map.h:45