Improve hashmap performance

This commit is contained in:
Hugo Mårdbrink 2025-04-18 00:46:05 +02:00
parent 50a450e7c3
commit 2abff63fcd
3 changed files with 131 additions and 54 deletions

View file

@ -4,15 +4,11 @@
#include <htd/primitives/primitives.h>
typedef struct {
void* key;
void* val;
} HashMapEntry;
typedef struct {
HashMapEntry* table;
void* table;
usize len;
usize capacity;
usize prime_idx;
usize key_size;
usize val_size;
} HashMap;
@ -21,8 +17,12 @@ void hmap_init(HashMap* hmap, usize key_size, usize val_size);
void hmap_put(HashMap* hmap, const void* key, const void* val);
void hmap_remove(HashMap* hmap, const void* key);
void* hmap_get(HashMap* hmap, const void* key);
bool hmap_contains(HashMap* hmap, const void* key);
void hmap_free(HashMap* hmap);
#endif // HTD_HASH_MAP_H