libyang 2.1.80
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
Loading...
Searching...
No Matches
hash_table.h
Go to the documentation of this file.
1
16#ifndef LY_HASH_TABLE_H_
17#define LY_HASH_TABLE_H_
18
19#include <pthread.h>
20#include <stddef.h>
21#include <stdint.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include "compat.h"
28#include "log.h"
29
43LIBYANG_API_DECL uint32_t lyht_hash_multi(uint32_t hash, const char *key_part, size_t len);
44
57LIBYANG_API_DECL uint32_t lyht_hash(const char *key, size_t len);
58
68typedef ly_bool (*lyht_value_equal_cb)(void *val1_p, void *val2_p, ly_bool mod, void *cb_data);
69
80LIBYANG_API_DECL struct ly_ht *lyht_new(uint32_t size, uint16_t val_size, lyht_value_equal_cb val_equal, void *cb_data,
81 uint16_t resize);
82
90LIBYANG_API_DECL lyht_value_equal_cb lyht_set_cb(struct ly_ht *ht, lyht_value_equal_cb new_val_equal);
91
99LIBYANG_API_DECL void *lyht_set_cb_data(struct ly_ht *ht, void *new_cb_data);
100
107LIBYANG_API_DECL struct ly_ht *lyht_dup(const struct ly_ht *orig);
108
115LIBYANG_API_DECL void lyht_free(struct ly_ht *ht, void (*val_free)(void *val_p));
116
127LIBYANG_API_DECL LY_ERR lyht_find(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
128
139LIBYANG_API_DECL LY_ERR lyht_find_next(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
140
153LIBYANG_API_DECL LY_ERR lyht_find_next_with_collision_cb(struct ly_ht *ht, void *val_p, uint32_t hash,
154 lyht_value_equal_cb collision_val_equal, void **match_p);
155
168LIBYANG_API_DECL LY_ERR lyht_insert(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
169
185LIBYANG_API_DECL LY_ERR lyht_insert_with_resize_cb(struct ly_ht *ht, void *val_p, uint32_t hash,
186 lyht_value_equal_cb resize_val_equal, void **match_p);
187
198LIBYANG_API_DECL LY_ERR lyht_remove(struct ly_ht *ht, void *val_p, uint32_t hash);
199
213LIBYANG_API_DECL LY_ERR lyht_remove_with_resize_cb(struct ly_ht *ht, void *val_p, uint32_t hash,
214 lyht_value_equal_cb resize_val_equal);
215
222LIBYANG_API_DECL uint32_t lyht_get_fixed_size(uint32_t item_count);
223
224#ifdef __cplusplus
225}
226#endif
227
228#endif /* LY_HASH_TABLE_H_ */
LY_ERR
libyang's error codes returned by the libyang functions.
Definition log.h:251
LIBYANG_API_DECL struct ly_ht * lyht_new(uint32_t size, uint16_t val_size, lyht_value_equal_cb val_equal, void *cb_data, uint16_t resize)
Create new hash table.
LIBYANG_API_DECL LY_ERR lyht_insert_with_resize_cb(struct ly_ht *ht, void *val_p, uint32_t hash, lyht_value_equal_cb resize_val_equal, void **match_p)
Insert a value into hash table. Same functionality as lyht_insert() but allows to specify a temporary...
LIBYANG_API_DECL uint32_t lyht_get_fixed_size(uint32_t item_count)
Get suitable size of a hash table for a fixed number of items.
LIBYANG_API_DECL LY_ERR lyht_remove(struct ly_ht *ht, void *val_p, uint32_t hash)
Remove a value from a hash table.
LIBYANG_API_DECL LY_ERR lyht_remove_with_resize_cb(struct ly_ht *ht, void *val_p, uint32_t hash, lyht_value_equal_cb resize_val_equal)
Remove a value from a hash table. Same functionality as lyht_remove() but allows to specify a tempora...
LIBYANG_API_DECL uint32_t lyht_hash(const char *key, size_t len)
Compute hash from a string.
LIBYANG_API_DECL struct ly_ht * lyht_dup(const struct ly_ht *orig)
Make a duplicate of an existing hash table.
LIBYANG_API_DECL uint32_t lyht_hash_multi(uint32_t hash, const char *key_part, size_t len)
Compute hash from (several) string(s).
LIBYANG_API_DECL void * lyht_set_cb_data(struct ly_ht *ht, void *new_cb_data)
Set hash table value equal callback user data.
LIBYANG_API_DECL LY_ERR lyht_insert(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p)
Insert a value into a hash table.
LIBYANG_API_DECL LY_ERR lyht_find_next(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p)
Find another equal value in the hash table.
LIBYANG_API_DECL LY_ERR lyht_find_next_with_collision_cb(struct ly_ht *ht, void *val_p, uint32_t hash, lyht_value_equal_cb collision_val_equal, void **match_p)
Find another equal value in the hash table. Same functionality as lyht_find_next() but allows to spec...
LIBYANG_API_DECL lyht_value_equal_cb lyht_set_cb(struct ly_ht *ht, lyht_value_equal_cb new_val_equal)
Set hash table value equal callback.
ly_bool(* lyht_value_equal_cb)(void *val1_p, void *val2_p, ly_bool mod, void *cb_data)
Callback for checking hash table values equivalence.
Definition hash_table.h:68
LIBYANG_API_DECL LY_ERR lyht_find(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p)
Find a value in a hash table.
LIBYANG_API_DECL void lyht_free(struct ly_ht *ht, void(*val_free)(void *val_p))
Free a hash table.
Logger manipulation routines and error definitions.
uint8_t ly_bool
Type to indicate boolean value.
Definition log.h:35