blob: 8f20b8f4e2d964f6bcdfb6a53a2a686253d4c3fe [file] [log] [blame]
Lucas De Marchi529148e2011-12-27 12:26:51 -02001#ifndef _LIBKMOD_HASH_H_
2#define _LIBKMOD_HASH_H_
3
Lucas De Marchi8d1278d2011-12-27 13:27:01 -02004#include <stdbool.h>
5
Lucas De Marchi529148e2011-12-27 12:26:51 -02006struct hash;
Lucas De Marchi8d1278d2011-12-27 13:27:01 -02007
8struct hash_iter {
9 const struct hash *hash;
10 unsigned int bucket;
11 unsigned int entry;
12};
13
Lucas De Marchi529148e2011-12-27 12:26:51 -020014struct hash *hash_new(unsigned int n_buckets, void (*free_value)(void *value));
15void hash_free(struct hash *hash);
16int hash_add(struct hash *hash, const char *key, const void *value);
17int hash_add_unique(struct hash *hash, const char *key, const void *value);
18int hash_del(struct hash *hash, const char *key);
19void *hash_find(const struct hash *hash, const char *key);
20unsigned int hash_get_count(const struct hash *hash);
Lucas De Marchi8d1278d2011-12-27 13:27:01 -020021void hash_iter_init(const struct hash *hash, struct hash_iter *iter);
22bool hash_iter_next(struct hash_iter *iter, const char **key,
23 const void **value);
Lucas De Marchi529148e2011-12-27 12:26:51 -020024
25#endif