- Add THashTrait specializations for FString, double, and float.

SVN r1877 (scripting)
This commit is contained in:
Randy Heit 2009-09-25 03:43:00 +00:00
commit affed111fe
2 changed files with 23 additions and 0 deletions

View file

@ -398,11 +398,26 @@ template<class KT> struct THashTraits
{
// Returns the hash value for a key.
hash_t Hash(const KT key) { return (hash_t)(intptr_t)key; }
hash_t Hash(double key) { return ((hash_t *)&key)[0] ^ ((hash_t *)&key)[1]; }
// Compares two keys, returning zero if they are the same.
int Compare(const KT left, const KT right) { return left != right; }
};
template<> struct THashTraits<float>
{
// Use all bits when hashing singles instead of converting them to ints.
hash_t Hash(float key) { return *((hash_t *)&key); }
int Compare(float left, float right) { return left != right; }
};
template<> struct THashTraits<double>
{
// Use all bits when hashing doubles instead of converting them to ints.
hash_t Hash(double key) { return ((hash_t *)&key)[0] ^ ((hash_t *)&key)[1]; }
int Compare(double left, double right) { return left != right; }
};
template<class VT> struct TValueTraits
{
// Initializes a value for TMap. If a regular constructor isn't