5 #include <ctu_std_api.h>
250 #define CTU_MAP_NEXT(iter, key, value) map_next_pair(iter, (const void **)(key), (void **)(value))
#define CT_PUREFN
mark a function as pure, always returns the same value for the same arguments
#define CT_NODISCARD
mark a function as returning a value that must be used
#define IN_NOTNULL
annotate a parameter as not being null
#define IN_DOMAIN(cmp, it)
annotate a parameter as being bounded by the expression of cmp and it
#define CT_NOALIAS
mark a function as only modifying pointers passed to it the same as CT_CONSTFN but allowed to modify/...
CT_STD_API void map_init(OUT_NOTNULL map_t *map, size_t size, hash_info_t info, arena_t *arena)
initialize a map
CT_NODISCARD CT_PUREFN CT_STD_API size_t map_count(const map_t *map)
get the number of key-value pairs in a map
CT_NODISCARD CT_PUREFN CT_STD_API void * map_get_default(const map_t *map, const void *key, void *other)
get a value from a map or a default value
CT_STD_API const map_t kEmptyMap
an empty map
CT_NODISCARD CT_STD_API typevec_t * map_entries(map_t *map)
collect all key-value pairs in a map into a vector returns a typevec_t<map_entry_t>
CT_NODISCARD CT_STD_API map_t * map_optimal(size_t size, hash_info_t info, arena_t *arena)
create a new map with an optimal size
CT_NODISCARD CT_PUREFN CT_STD_API bool map_has_next(const map_iter_t *iter)
check if a map iterator has more elements
CT_STD_API void map_reset(map_t *map)
clear all key-value pairs from a map
CT_STD_API bool map_delete(map_t *map, const void *key)
delete a key-value pair from a map
CT_NODISCARD CT_STD_API vector_t * map_values(map_t *map)
collect all the values from a map into a vector
CT_NODISCARD CT_STD_API bool map_next_pair(map_iter_t *iter, const void **key, void **value)
get the next key-value pair from a map iterator returns the values via out parameters for ease of use...
CT_NODISCARD CT_STD_API map_t map_make(size_t size, hash_info_t info, arena_t *arena)
create a new map on the stack
CT_NODISCARD CT_PUREFN CT_STD_API map_iter_t map_iter(const map_t *map)
create a new map iterator
CT_STD_API void map_set(map_t *map, const void *key, void *value)
set a key-value pair in a map
CT_NODISCARD CT_STD_API map_t * map_new(size_t size, hash_info_t info, arena_t *arena)
create a new map on the heap
CT_NODISCARD CT_PUREFN CT_STD_API bool map_contains(const map_t *map, const void *key)
check if a map contains a key
CT_NODISCARD CT_PUREFN CT_STD_API void * map_get(const map_t *map, const void *key)
get a value from a map
CT_NODISCARD CT_NOALIAS CT_STD_API map_entry_t map_next(map_iter_t *iter)
get the next key-value pair from a map iterator
information for using a type in a hashset or hashmap
a key-value pair in a map
const void * key
the key of this entry
void * value
the value of this entry
bucket_t * next
the next bucket in the chain
size_t index
current top level bucket index
bucket_t * bucket
the current bucket
const map_t * map
the map being iterated over
STA_FIELD_RANGE(>, 0) size_t size
the number of top level buckets
STA_FIELD_SIZE(size) bucket_t *data
bucket data
arena_t * arena
the arena this map allocates from
hash_info_t info
the hash function for this map
STA_FIELD_RANGE(<, size) size_t used
the number of buckets used
A vector with a fixed type size.
a generic vector of pointers