blob: ca0af05724851c21fc61aa9143dd84da3af4b050 [file] [log] [blame]
Lucas De Marchie8fd8fe2012-07-18 10:19:48 -03001#pragma once
Lucas De Marchi529148e2011-12-27 12:26:51 -02002
Lucas De Marchi8d1278d2011-12-27 13:27:01 -02003#include <stdbool.h>
4
Lucas De Marchi529148e2011-12-27 12:26:51 -02005struct hash;
Lucas De Marchi8d1278d2011-12-27 13:27:01 -02006
7struct hash_iter {
8 const struct hash *hash;
9 unsigned int bucket;
10 unsigned int entry;
11};
12
Lucas De Marchi529148e2011-12-27 12:26:51 -020013struct hash *hash_new(unsigned int n_buckets, void (*free_value)(void *value));
14void hash_free(struct hash *hash);
15int hash_add(struct hash *hash, const char *key, const void *value);
16int hash_add_unique(struct hash *hash, const char *key, const void *value);
17int hash_del(struct hash *hash, const char *key);
18void *hash_find(const struct hash *hash, const char *key);
19unsigned int hash_get_count(const struct hash *hash);
Lucas De Marchi8d1278d2011-12-27 13:27:01 -020020void hash_iter_init(const struct hash *hash, struct hash_iter *iter);
21bool hash_iter_next(struct hash_iter *iter, const char **key,
22 const void **value);