diff --git a/dtool/src/dtoolbase/stl_compares.I b/dtool/src/dtoolbase/stl_compares.I index bdde4b20fa..c28395ba22 100644 --- a/dtool/src/dtoolbase/stl_compares.I +++ b/dtool/src/dtoolbase/stl_compares.I @@ -124,6 +124,17 @@ is_equal(const Key &a, const Key &b) const { template INLINE size_t integer_hash:: 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(key); return AddHash::add_hash(hash, &key32, 1); diff --git a/dtool/src/dtoolbase/stl_compares.h b/dtool/src/dtoolbase/stl_compares.h index 843b3c4637..322034e3ce 100644 --- a/dtool/src/dtoolbase/stl_compares.h +++ b/dtool/src/dtoolbase/stl_compares.h @@ -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 > { +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_hash; typedef floating_point_hash double_hash; -typedef integer_hash pointer_hash; typedef integer_hash int_hash; typedef integer_hash size_t_hash; typedef sequence_hash string_hash;