#ifndef CUTES_HASH_MAP_H #define CUTES_HASH_MAP_H #include "list.h" #include "stdint.h" #include "typeclass_helpers.h" #define CUTES_HASH_MAP_BUCKETS 24 typedef uintptr_t (*HashFunc)(void *data); typedef struct HashMap { List buckets[CUTES_HASH_MAP_BUCKETS]; HashFunc hasher; size_t key_size; size_t value_size; } HashMap; HashMap hash_map_from_sizes(size_t key_size, size_t value_size, HashFunc hasher); void hash_map_empty(HashMap *self); void *hash_map_get_raw(HashMap *self, void *key); void hash_map_insert(HashMap *self, void *key, void *value); List hash_map_keys(HashMap *self); List hash_map_values(HashMap *self); #define hash_map_from_types(TKey, TValue, KeyHasher) (hash_map_from_sizes(sizeof(TKey), sizeof(TValue), (HashFunc)KeyHasher)); TC_FN_TYPECHECK(uintptr_t, KeyHasher, TKey*) #define hash_map_get_as(TValue, Self, Key) ((TValue*)hash_map_get_raw(Self, Key)) #endif // !CUTES_HASH_MAP_H