#pragma once #include "hashmap.h" #include "utils.h" #include #include #define WAYC_HASHMAP_SEED 0 #define WAYC_HASHMAP_CAP 16 template struct hashmap_s { struct hashmap *inner; }; template static inline i32 wayc_hashmap_hash(const void *item, uint64_t seed0, uint64_t seed1) { wayc_notnull(item); return hashmap_xxhash3(item, sizeof(T), seed0, seed1); } template static inline bool wayc_hashmap_compare(const void *a, const void *b, void *udata) { (void)udata; wayc_notnull(a); wayc_notnull(b); return memcmp(a, b, sizeof(T)) == 0; } template inline hashmap_s wayc_hashmap_init(void) { struct hashmap *map = hashmap_new_with_allocator( mi_malloc, mi_realloc, mi_free, sizeof(T), WAYC_HASHMAP_CAP, WAYC_HASHMAP_SEED, WAYC_HASHMAP_SEED, wayc_hashmap_hash, wayc_hashmap_compare, nullptr, nullptr); hashmap_s result; result.inner = map; return result; } template inline void wayc_hashmap_deinit(hashmap_s *map) { hashmap_free(map->inner); map->inner = nullptr; }