feat(hash_map): hash_map
This commit is contained in:
parent
352c122549
commit
b7b6a6a8d5
2 changed files with 207 additions and 0 deletions
34
src/utils/hash_map/hash_map.h
Normal file
34
src/utils/hash_map/hash_map.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef HASH_MAP_H
|
||||
#define HASH_MAP_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
struct pair_list
|
||||
{
|
||||
const char *key;
|
||||
void *value;
|
||||
struct pair_list *next;
|
||||
};
|
||||
|
||||
struct hash_map
|
||||
{
|
||||
struct pair_list **data;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
struct hash_map *hash_map_init(size_t size);
|
||||
|
||||
bool hash_map_insert(struct hash_map *hash_map, const char *key, void *value,
|
||||
bool *updated);
|
||||
|
||||
void hash_map_free(struct hash_map *hash_map);
|
||||
|
||||
void hash_map_foreach(struct hash_map *hash_map,
|
||||
void (*fn)(const char *, const void *));
|
||||
|
||||
const void *hash_map_get(const struct hash_map *hash_map, const char *key);
|
||||
|
||||
bool hash_map_remove(struct hash_map *hash_map, const char *key);
|
||||
|
||||
#endif /* ! HASH_MAP_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue