* src/misc/hashfunc.hh (wang32_hash): New file and function,
extracted from... * src/evtgba/product.cc (evtgba_product_state::hash): ... here. * src/misc/Makefile.am (misc_HEADERS): Add hashfunc.hh.
This commit is contained in:
parent
49b871f924
commit
dfb832cf20
4 changed files with 50 additions and 15 deletions
|
|
@ -20,6 +20,7 @@
|
|||
// 02111-1307, USA.
|
||||
|
||||
#include "product.hh"
|
||||
#include "misc/hashfunc.hh"
|
||||
#include "misc/modgray.hh"
|
||||
#include <cstdlib>
|
||||
#include <set>
|
||||
|
|
@ -75,23 +76,9 @@ namespace spot
|
|||
size_t
|
||||
hash() const
|
||||
{
|
||||
// We assume that size_t has at least 32bits.
|
||||
size_t res = 0;
|
||||
for (int i = 0; i != n_; ++i)
|
||||
{
|
||||
size_t key = s_[i]->hash();
|
||||
|
||||
// Thomas Wang's 32 bit hash Function
|
||||
// http://www.concentric.net/~Ttwang/tech/inthash.htm
|
||||
key += ~(key << 15);
|
||||
key ^= (key >> 10);
|
||||
key += (key << 3);
|
||||
key ^= (key >> 6);
|
||||
key += ~(key << 11);
|
||||
key ^= (key >> 16);
|
||||
|
||||
res ^= key;
|
||||
}
|
||||
res ^= wang32_hash(s_[i]->hash());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue