libyang 2.1.148
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 <stddef.h>
20#include <stdint.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include "log.h"
27
32struct ly_ht;
33
47LIBYANG_API_DECL uint32_t lyht_hash_multi(uint32_t hash, const char *key_part, size_t len);
48
61LIBYANG_API_DECL uint32_t lyht_hash(const char *key, size_t len);
62
72typedef ly_bool (*lyht_value_equal_cb)(void *val1_p, void *val2_p, ly_bool mod, void *cb_data);
73
84LIBYANG_API_DECL struct ly_ht *lyht_new(uint32_t size, uint16_t val_size, lyht_value_equal_cb val_equal, void *cb_data,
85 uint16_t resize);
86
94LIBYANG_API_DECL lyht_value_equal_cb lyht_set_cb(struct ly_ht *ht, lyht_value_equal_cb new_val_equal);
95
103LIBYANG_API_DECL void *lyht_set_cb_data(struct ly_ht *ht, void *new_cb_data);
104
111LIBYANG_API_DECL struct ly_ht *lyht_dup(const struct ly_ht *orig);
112
119LIBYANG_API_DECL void lyht_free(struct ly_ht *ht, void (*val_free)(void *val_p));
120
131LIBYANG_API_DECL LY_ERR lyht_find(const struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
132
144LIBYANG_API_DECL LY_ERR lyht_find_with_val_cb(const struct ly_ht *ht, void *val_p, uint32_t hash,
145 lyht_value_equal_cb val_equal, void **match_p);
146
157LIBYANG_API_DECL LY_ERR lyht_find_next(const struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
158
171LIBYANG_API_DECL LY_ERR lyht_find_next_with_collision_cb(const struct ly_ht *ht, void *val_p, uint32_t hash,
172 lyht_value_equal_cb collision_val_equal, void **match_p);
173
186LIBYANG_API_DECL LY_ERR lyht_insert(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
187
199LIBYANG_API_DECL LY_ERR lyht_insert_no_check(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
200
216LIBYANG_API_DECL LY_ERR lyht_insert_with_resize_cb(struct ly_ht *ht, void *val_p, uint32_t hash,
217 lyht_value_equal_cb resize_val_equal, void **match_p);
218
229LIBYANG_API_DECL LY_ERR lyht_remove(struct ly_ht *ht, void *val_p, uint32_t hash);
230
244LIBYANG_API_DECL LY_ERR lyht_remove_with_resize_cb(struct ly_ht *ht, void *val_p, uint32_t hash,
245 lyht_value_equal_cb resize_val_equal);
246
253LIBYANG_API_DECL uint32_t lyht_get_fixed_size(uint32_t item_count);
254
255#ifdef __cplusplus
256}
257#endif
258
259#endif /* LY_HASH_TABLE_H_ */
LY_ERR
libyang's error codes returned by the libyang functions.
Definition log.h:248
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_find_next_with_collision_cb(const 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 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_find(const struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p)
Find a value in a hash table.
LIBYANG_API_DECL LY_ERR lyht_find_next(const 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_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_with_val_cb(const struct ly_ht *ht, void *val_p, uint32_t hash, lyht_value_equal_cb val_equal, void **match_p)
Find a value in a hash table but use a custom val_equal callback.
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.
LIBYANG_API_DECL LY_ERR lyht_insert_no_check(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p)
Insert a value into a hash table, without checking whether the value has already been inserted.
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:72
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
libyang hash table.