try harder to avoid 64-bit complaints

This commit is contained in:
David Rose 2008-03-21 22:29:03 +00:00
parent 3c2f78e72c
commit 7ccbc378f4
2 changed files with 22 additions and 1 deletions

View File

@ -124,6 +124,17 @@ is_equal(const Key &a, const Key &b) const {
template<class Key, class Compare>
INLINE size_t integer_hash<Key, Compare>::
add_hash(size_t hash, const Key &key) {
PN_uint32 key32 = (PN_uint32)(key);
return AddHash::add_hash(hash, &key32, 1);
}
////////////////////////////////////////////////////////////////////
// Function: pointer_hash::add_hash
// Access: Public, Static
// Description: Adds the indicated key into a running hash.
////////////////////////////////////////////////////////////////////
INLINE size_t pointer_hash::
add_hash(size_t hash, void *key) {
// We don't mind if this loses precision.
PN_uint32 key32 = (PN_uint32)reinterpret_cast<unsigned long>(key);
return AddHash::add_hash(hash, &key32, 1);

View File

@ -144,6 +144,17 @@ public:
INLINE static size_t add_hash(size_t start, const Key &key);
};
////////////////////////////////////////////////////////////////////
// Class : pointer_hash
// Description : This is the default hash_compare class, which assumes
// the Key is a pointer value. It is the same as the
// system-provided hash_compare.
////////////////////////////////////////////////////////////////////
class pointer_hash : public stl_hash_compare<void *, less<void *> > {
public:
INLINE static size_t add_hash(size_t start, void *key);
};
////////////////////////////////////////////////////////////////////
// Class : floating_point_hash
// Description : This hash_compare class hashes a float or a double.
@ -209,7 +220,6 @@ public:
typedef floating_point_hash<float> float_hash;
typedef floating_point_hash<double> double_hash;
typedef integer_hash<const void *> pointer_hash;
typedef integer_hash<int> int_hash;
typedef integer_hash<size_t> size_t_hash;
typedef sequence_hash<string> string_hash;