Lucas De Marchi | 529148e | 2011-12-27 12:26:51 -0200 | [diff] [blame] | 1 | #ifndef _LIBKMOD_HASH_H_ |
| 2 | #define _LIBKMOD_HASH_H_ |
| 3 | |
Lucas De Marchi | 8d1278d | 2011-12-27 13:27:01 -0200 | [diff] [blame] | 4 | #include <stdbool.h> |
| 5 | |
Lucas De Marchi | 529148e | 2011-12-27 12:26:51 -0200 | [diff] [blame] | 6 | struct hash; |
Lucas De Marchi | 8d1278d | 2011-12-27 13:27:01 -0200 | [diff] [blame] | 7 | |
| 8 | struct hash_iter { |
| 9 | const struct hash *hash; |
| 10 | unsigned int bucket; |
| 11 | unsigned int entry; |
| 12 | }; |
| 13 | |
Lucas De Marchi | 529148e | 2011-12-27 12:26:51 -0200 | [diff] [blame] | 14 | struct hash *hash_new(unsigned int n_buckets, void (*free_value)(void *value)); |
| 15 | void hash_free(struct hash *hash); |
| 16 | int hash_add(struct hash *hash, const char *key, const void *value); |
| 17 | int hash_add_unique(struct hash *hash, const char *key, const void *value); |
| 18 | int hash_del(struct hash *hash, const char *key); |
| 19 | void *hash_find(const struct hash *hash, const char *key); |
| 20 | unsigned int hash_get_count(const struct hash *hash); |
Lucas De Marchi | 8d1278d | 2011-12-27 13:27:01 -0200 | [diff] [blame] | 21 | void hash_iter_init(const struct hash *hash, struct hash_iter *iter); |
| 22 | bool hash_iter_next(struct hash_iter *iter, const char **key, |
| 23 | const void **value); |
Lucas De Marchi | 529148e | 2011-12-27 12:26:51 -0200 | [diff] [blame] | 24 | |
| 25 | #endif |