* 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
|
|
@ -1,3 +1,10 @@
|
||||||
|
2004-11-16 Alexandre Duret-Lutz <adl@src.lip6.fr>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2004-11-15 Alexandre Duret-Lutz <adl@gnu.org>
|
2004-11-15 Alexandre Duret-Lutz <adl@gnu.org>
|
||||||
|
|
||||||
* src/tgbatest/ltl2tgba.cc (main): For non-generalized emptiness
|
* src/tgbatest/ltl2tgba.cc (main): For non-generalized emptiness
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
// 02111-1307, USA.
|
// 02111-1307, USA.
|
||||||
|
|
||||||
#include "product.hh"
|
#include "product.hh"
|
||||||
|
#include "misc/hashfunc.hh"
|
||||||
#include "misc/modgray.hh"
|
#include "misc/modgray.hh"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
@ -75,23 +76,9 @@ namespace spot
|
||||||
size_t
|
size_t
|
||||||
hash() const
|
hash() const
|
||||||
{
|
{
|
||||||
// We assume that size_t has at least 32bits.
|
|
||||||
size_t res = 0;
|
size_t res = 0;
|
||||||
for (int i = 0; i != n_; ++i)
|
for (int i = 0; i != n_; ++i)
|
||||||
{
|
res ^= wang32_hash(s_[i]->hash());
|
||||||
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;
|
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ misc_HEADERS = \
|
||||||
escape.hh \
|
escape.hh \
|
||||||
freelist.hh \
|
freelist.hh \
|
||||||
hash.hh \
|
hash.hh \
|
||||||
|
hashfunc.hh \
|
||||||
minato.hh \
|
minato.hh \
|
||||||
modgray.hh \
|
modgray.hh \
|
||||||
random.hh \
|
random.hh \
|
||||||
|
|
|
||||||
40
src/misc/hashfunc.hh
Normal file
40
src/misc/hashfunc.hh
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
|
// et Marie Curie.
|
||||||
|
//
|
||||||
|
// This file is part of Spot, a model checking library.
|
||||||
|
//
|
||||||
|
// Spot is free software; you can redistribute it and/or modify it
|
||||||
|
// under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Spot is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
// License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Spot; see the file COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
// 02111-1307, USA.
|
||||||
|
|
||||||
|
namespace spot
|
||||||
|
{
|
||||||
|
/// \brief Thomas Wang's 32 bit hash function.
|
||||||
|
///
|
||||||
|
/// Hash an integer amongst the integers.
|
||||||
|
/// http://www.concentric.net/~Ttwang/tech/inthash.htm
|
||||||
|
inline size_t
|
||||||
|
wang32_hash(size_t key)
|
||||||
|
{
|
||||||
|
// We assume that size_t has at least 32bits.
|
||||||
|
key += ~(key << 15);
|
||||||
|
key ^= (key >> 10);
|
||||||
|
key += (key << 3);
|
||||||
|
key ^= (key >> 6);
|
||||||
|
key += ~(key << 11);
|
||||||
|
key ^= (key >> 16);
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue