1
0
Fork 0
mirror of https://github.com/pygos/pkg-utils.git synced 2024-05-17 03:36:14 +02:00
pkg-utils/include/util/hashtable.h
David Oberhollenzer 6dd9ae94bd Add simple hash table implementation
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2019-03-08 00:28:41 +01:00

28 lines
621 B
C

#ifndef HASH_TABLE_H
#define HASH_TABLE_H
typedef struct hash_bucket_t {
struct hash_bucket_t *next;
char *key;
void *value;
} hash_bucket_t;
typedef struct {
hash_bucket_t **buckets;
size_t num_buckets;
size_t count;
} hash_table_t;
int hash_table_init(hash_table_t *table, size_t size);
void hash_table_cleanup(hash_table_t *table);
void *hash_table_lookup(hash_table_t *table, const char *key);
int hash_table_set(hash_table_t *table, const char *key, void *value);
void hash_table_foreach(hash_table_t *table, void *usr,
int(*fun)(void *usr, const char *key, void *value));
#endif /* HASH_TABLE_H */