hmap_s.c (819B)
1#include "hmap_s.h" 2#include "vec.h" 3#include <stdint.h> 4 5uint32_t 6vec2i_hmap_hash(struct hmap_key key) 7{ 8 const struct vec2i *v = key.p; 9 10 return (uint32_t) v->x + (uint32_t) v->y * 1337; 11} 12 13bool 14vec2i_hmap_keycmp(struct hmap_key k1, struct hmap_key k2) 15{ 16 const struct vec2i *v1 = k1.p, *v2 = k2.p; 17 18 return vec2i_eql(v1, v2); 19} 20 21uint32_t 22vec3i_hmap_hash(struct hmap_key key) 23{ 24 const struct vec3i *v = key.p; 25 26 return (uint32_t) v->x + (uint32_t) v->y * 1337 27 + (uint32_t) v->z * 1337 * 1337; 28} 29 30bool 31vec3i_hmap_keycmp(struct hmap_key k1, struct hmap_key k2) 32{ 33 const struct vec3i *v1 = k1.p, *v2 = k2.p; 34 35 return vec3i_eql(v1, v2); 36} 37 38uint32_t 39ssizet_hmap_hash(struct hmap_key key) 40{ 41 return (uint32_t) (key.s * 1737); 42} 43 44bool 45ssizet_hmap_keycmp(struct hmap_key k1, struct hmap_key k2) 46{ 47 return k1.ss == k2.ss; 48}