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