Commit dfb832cf authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

* 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.
parent 49b871f9
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>
* src/tgbatest/ltl2tgba.cc (main): For non-generalized emptiness
......
......@@ -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;
}
......
......@@ -31,6 +31,7 @@ misc_HEADERS = \
escape.hh \
freelist.hh \
hash.hh \
hashfunc.hh \
minato.hh \
modgray.hh \
random.hh \
......
// 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;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment