1 //////////////////////////////////////////////////////////////////////////////// 2 // 3 // HashKey.hh 4 // produced: 01/09/97 jr 5 // last change: 24/01/99 jr 6 // 7 //////////////////////////////////////////////////////////////////////////////// 8 #ifndef HASHKEY_HH 9 #define HASHKEY_HH 10 11 #include <Global.hh> 12 13 template<class Key> 14 class HashKeySize { 15 public: operator ()(const Key & key)16 inline size_type operator()(const Key& key) { return key.keysize(); } 17 }; 18 19 template<class Key> 20 class HashKey { 21 public: operator ()(const Key & key,const size_type n)22 inline size_type operator()(const Key& key, const size_type n) { return key.key(n); } 23 }; 24 25 ////////////////////////////////////////////////////////////////////////////// 26 // some specializations: 27 ////////////////////////////////////////////////////////////////////////////// 28 29 // size_type: 30 31 template<> 32 class HashKeySize<size_type> { 33 public: operator ()(const size_type & key)34 size_type operator()(const size_type& key) { return 1; } 35 }; 36 37 template<> 38 class HashKey<size_type> { 39 public: operator ()(const size_type & key,const size_type n)40 size_type operator()(const size_type& key, const size_type n) { return key; } 41 }; 42 43 #include <Field.hh> 44 45 template<> 46 class HashKeySize<Field> { 47 public: operator ()(const Field & key)48 inline size_type operator()(const Field& key) { return 1; } 49 }; 50 51 // Field: 52 53 template<> 54 class HashKey<Field> { 55 public: operator ()(const Field & key,const size_type n)56 inline size_type operator()(const Field& key, const size_type n) { 57 static std_ext::hash<Field> hash_obj; 58 return hash_obj(key); 59 } 60 }; 61 62 #endif 63 // eof HashKey.hh 64