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