rcutils
master
C API providing common utilities and data structures.
|
Go to the documentation of this file.
17 #ifndef RCUTILS__TYPES__HASH_MAP_H_
18 #define RCUTILS__TYPES__HASH_MAP_H_
32 struct rcutils_hash_map_impl_t;
38 struct rcutils_hash_map_impl_t *
impl;
69 #define HASH_MAP_VALIDATE_HASH_MAP(map) \
70 RCUTILS_CHECK_ARGUMENT_FOR_NULL(map, RCUTILS_RET_INVALID_ARGUMENT); \
71 if (NULL == map->impl) { \
72 RCUTILS_SET_ERROR_MSG("map is not initialized"); \
73 return RCUTILS_RET_NOT_INITIALIZED; \
176 size_t initial_capacity,
417 const void * previous_key,
426 #endif // RCUTILS__TYPES__HASH_MAP_H_
rcutils_ret_t rcutils_hash_map_get_capacity(const rcutils_hash_map_t *hash_map, size_t *capacity)
Get the current capacity of the hash_map.
struct rcutils_hash_map_t rcutils_hash_map_t
The structure holding the metadata for a hash map.
rcutils_ret_t rcutils_hash_map_get_size(const rcutils_hash_map_t *hash_map, size_t *size)
Get the current size of the hash_map.
bool rcutils_hash_map_key_exists(const rcutils_hash_map_t *hash_map, const void *key)
Get whether or not a key exists.
rcutils_ret_t rcutils_hash_map_set(rcutils_hash_map_t *hash_map, const void *key, const void *value)
Set a key value pair in the hash_map, increasing capacity if necessary.
int(* rcutils_hash_map_key_cmp_t)(const void *, const void *)
The function signature for a key comparison function.
Definition: hash_map.h:58
rcutils_ret_t rcutils_hash_map_get(const rcutils_hash_map_t *hash_map, const void *key, void *data)
Get value given a key.
rcutils_hash_map_t rcutils_get_zero_initialized_hash_map()
Return an empty hash_map struct.
#define RCUTILS_PUBLIC_TYPE
Definition: visibility_control.h:29
rcutils_ret_t rcutils_hash_map_get_next_key_and_data(const rcutils_hash_map_t *hash_map, const void *previous_key, void *key, void *data)
Get the next key in the hash_map, unless NULL is given, then get the first key.
int rcutils_ret_t
The type that holds a return value for an rcutils operation.
Definition: rcutils_ret.h:26
#define RCUTILS_WARN_UNUSED
A macro to make the compiler warn when the return value of a function is not used.
Definition: macros.h:27
Encapsulation of an allocator.
Definition: allocator.h:47
size_t rcutils_hash_map_string_hash_func(const void *key_str)
A hashing function for a null terminated c string.
#define RCUTILS_PUBLIC
Definition: visibility_control.h:23
struct rcutils_hash_map_impl_t * impl
A pointer to the PIMPL implementation type.
Definition: hash_map.h:38
rcutils_ret_t rcutils_hash_map_fini(rcutils_hash_map_t *hash_map)
Finalize the previously initialized hash_map struct.
size_t(* rcutils_hash_map_key_hasher_t)(const void *)
The function signature for a key hashing function.
Definition: hash_map.h:46
int rcutils_hash_map_string_cmp_func(const void *val1, const void *val2)
A comparison function for a null terminated c string.
rcutils_ret_t rcutils_hash_map_init(rcutils_hash_map_t *hash_map, size_t initial_capacity, size_t key_size, size_t data_size, rcutils_hash_map_key_hasher_t key_hashing_func, rcutils_hash_map_key_cmp_t key_cmp_func, const rcutils_allocator_t *allocator)
Initialize a rcutils_hash_map_t, allocating space for given capacity.
rcutils_ret_t rcutils_hash_map_unset(rcutils_hash_map_t *hash_map, const void *key)
Unset a key value pair in the hash_map.
The structure holding the metadata for a hash map.
Definition: hash_map.h:35