Fixup some more hashes

This commit is contained in:
kaetemi 2015-03-29 16:58:07 +02:00
parent 0a2d358e31
commit 63df17a63c
3 changed files with 20 additions and 4 deletions

View file

@ -580,7 +580,11 @@ struct CEntityIdHashMapTraits
size_t operator() (const NLMISC::CEntityId &id ) const
{
uint64 hash64 = id.getUniqueId();
return size_t(hash64) ^ size_t( hash64 >> 32 );
#if (HAVE_X86_64)
return (size_t)hash64;
#else
return (size_t)hash64 ^ (size_t)(hash64 >> 32);
#endif
//return size_t(id.getShortId());
}
bool operator() (const NLMISC::CEntityId &id1, const NLMISC::CEntityId &id2) const

View file

@ -363,7 +363,7 @@ struct CUCStringHashMapTraits
}
bool operator() (const ucstring &id1, const ucstring &id2) const
{
return id1.size() < id2.size();
return id1 < id2;
}
};

View file

@ -71,6 +71,19 @@ struct CContextMatcher
return memcmp(JokersValues, other.JokersValues, sizeof(uint32)*NbJoker) == 0;
}
bool operator<(const CContextMatcher &other) const
{
if (UseRandom)
if (RandomValue != other.RandomValue)
return RandomValue < other.RandomValue;
int cmp = memcmp(JokersValues, other.JokersValues, sizeof(uint32) * NbJoker);
if (cmp != 0)
return cmp < 0;
return false;
}
size_t getHashValue() const
{
return size_t(HashValue);
@ -89,10 +102,9 @@ struct CContextMatcher
}
bool operator() (const CContextMatcher &patternMatcher1, const CContextMatcher &patternMatcher2) const
{
return patternMatcher1.getHashValue() < patternMatcher2.getHashValue();
return patternMatcher1 < patternMatcher2;
}
};
};