Loading...
Searching...
No Matches
hash_table.h
Go to the documentation of this file.
#ifndef LY_HASH_TABLE_H_
#define LY_HASH_TABLE_H_
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "log.h"
struct ly_ht;
LIBYANG_API_DECL uint32_t lyht_hash_multi(uint32_t hash, const char *key_part, size_t len);
LIBYANG_API_DECL uint32_t lyht_hash(const char *key, size_t len);
typedef ly_bool (*lyht_value_equal_cb)(void *val1_p, void *val2_p, ly_bool mod, void *cb_data);
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);
LIBYANG_API_DECL lyht_value_equal_cb lyht_set_cb(struct ly_ht *ht, lyht_value_equal_cb new_val_equal);
LIBYANG_API_DECL void *lyht_set_cb_data(struct ly_ht *ht, void *new_cb_data);
LIBYANG_API_DECL struct ly_ht *lyht_dup(const struct ly_ht *orig);
LIBYANG_API_DECL void lyht_free(struct ly_ht *ht, void (*val_free)(void *val_p));
LIBYANG_API_DECL LY_ERR lyht_find(const struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
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);
LIBYANG_API_DECL LY_ERR lyht_find_next(const struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
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 val_equal, void **match_p);
LIBYANG_API_DECL LY_ERR lyht_insert(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
LIBYANG_API_DECL LY_ERR lyht_insert_no_check(struct ly_ht *ht, void *val_p, uint32_t hash, void **match_p);
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);
LIBYANG_API_DECL LY_ERR lyht_remove(struct ly_ht *ht, void *val_p, uint32_t hash);
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);
LIBYANG_API_DECL uint32_t lyht_get_fixed_size(uint32_t item_count);
#ifdef __cplusplus
}
#endif
#endif /* LY_HASH_TABLE_H_ */
LY_ERR
LY_ERR
libyang's error codes returned by the libyang functions.
Definition log.h:237
lyht_new
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.
lyht_insert_with_resize_cb
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...
lyht_get_fixed_size
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.
lyht_remove
LIBYANG_API_DECL LY_ERR lyht_remove(struct ly_ht *ht, void *val_p, uint32_t hash)
Remove a value from a hash table.
lyht_remove_with_resize_cb
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...
lyht_hash
LIBYANG_API_DECL uint32_t lyht_hash(const char *key, size_t len)
Compute hash from a string.
lyht_dup
LIBYANG_API_DECL struct ly_ht * lyht_dup(const struct ly_ht *orig)
Make a duplicate of an existing hash table.
lyht_hash_multi
LIBYANG_API_DECL uint32_t lyht_hash_multi(uint32_t hash, const char *key_part, size_t len)
Compute hash from (several) string(s).
lyht_set_cb_data
LIBYANG_API_DECL void * lyht_set_cb_data(struct ly_ht *ht, void *new_cb_data)
Set hash table value equal callback user data.
lyht_find
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.
lyht_find_next
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.
lyht_find_next_with_collision_cb
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 val_equal, void **match_p)
Find another equal value in the hash table. Same functionality as lyht_find_next() but allows to spec...
lyht_insert
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.
lyht_find_with_val_cb
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.
lyht_set_cb
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.
lyht_insert_no_check
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.
lyht_value_equal_cb
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:74
lyht_free
LIBYANG_API_DECL void lyht_free(struct ly_ht *ht, void(*val_free)(void *val_p))
Free a hash table.
log.h
Logger manipulation routines and error definitions.
ly_bool
uint8_t ly_bool
Type to indicate boolean value.
Definition log.h:35
ly_ht
libyang hash table.