1#ifndef HASHMAP_H
2# define HASHMAP_H
3
4# include <stdlib.h>
5# include <stdint.h>
6
7struct ext2fs_hashmap {
8	uint32_t size;
9	uint32_t(*hash)(const void *key, size_t len);
10	void(*free)(void*);
11	struct ext2fs_hashmap_entry *first;
12	struct ext2fs_hashmap_entry *last;
13	struct ext2fs_hashmap_entry {
14		void *data;
15		const void *key;
16		size_t key_len;
17		struct ext2fs_hashmap_entry *next;
18		struct ext2fs_hashmap_entry *list_next;
19		struct ext2fs_hashmap_entry *list_prev;
20	} *entries[0];
21};
22
23struct ext2fs_hashmap *ext2fs_hashmap_create(
24				uint32_t(*hash_fct)(const void*, size_t),
25				void(*free_fct)(void*), size_t size);
26void ext2fs_hashmap_add(struct ext2fs_hashmap *h, void *data, const void *key,
27			size_t key_len);
28void *ext2fs_hashmap_lookup(struct ext2fs_hashmap *h, const void *key,
29			    size_t key_len);
30void *ext2fs_hashmap_iter_in_order(struct ext2fs_hashmap *h,
31				   struct ext2fs_hashmap_entry **it);
32void ext2fs_hashmap_del(struct ext2fs_hashmap *h,
33			struct ext2fs_hashmap_entry *e);
34void ext2fs_hashmap_free(struct ext2fs_hashmap *h);
35
36uint32_t ext2fs_djb2_hash(const void *str, size_t size);
37
38#endif /* !HASHMAP_H */
39