| 1 | // -*- C++ -*- |
| 2 | |
| 3 | #ifndef HL_HASH_H |
| 4 | #define HL_HASH_H |
| 5 | |
| 6 | #include <cstdlib> |
| 7 | #include <stdlib.h> |
| 8 | |
| 9 | namespace HL { |
| 10 | |
| 11 | template <class Key> |
| 12 | class Hash { |
| 13 | public: |
| 14 | static size_t hash (Key k); |
| 15 | }; |
| 16 | |
| 17 | template <> |
| 18 | class Hash<size_t> { |
| 19 | public: |
| 20 | static inline size_t hash (void * v) { |
| 21 | return (size_t) v; |
| 22 | } |
| 23 | }; |
| 24 | |
| 25 | template <> |
| 26 | class Hash<void *> { |
| 27 | public: |
| 28 | static inline size_t hash (void * v) { |
| 29 | return (size_t) ((size_t) v); |
| 30 | } |
| 31 | }; |
| 32 | |
| 33 | template <> |
| 34 | class Hash<int> { |
| 35 | public: |
| 36 | static inline size_t hash (int v) { |
| 37 | return (size_t) v; |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | } |
| 42 | |
| 43 | #endif |