From f71f15ebf15b60fa03804d8ff636e2470054f08f Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 4 Jan 2012 17:07:22 +1100 Subject: [PATCH] Add convenience typed hash functions --- hash.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hash.hpp b/hash.hpp index d207e2a9..0b592dbb 100644 --- a/hash.hpp +++ b/hash.hpp @@ -34,8 +34,12 @@ namespace util { uint64_t fnv1a64 (const void *, size_t); // General hashes for when you really just don't care about implementation - inline uint32_t hash (uint32_t key) { return wang32 (key); } - inline uint64_t hash (uint64_t key) { return wang64 (key); } + inline uint32_t hash (uint32_t key) { return wang32 (key); } + inline int32_t hash ( int32_t key) { return (int32_t) hash ((uint32_t)key); } + + inline uint64_t hash (uint64_t key) { return wang64 (key); } + inline int64_t hash ( int64_t key) { return (int64_t) hash ((uint64_t)key); } + inline uintptr_t hash (const void *key) { return sizeof (uintptr_t) == 32 ? wang32 (reinterpret_cast (key)) : wang64 (reinterpret_cast (key));