diff --git a/ChangeLog b/ChangeLog index 75c7b1ca6..72f48ee66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2004-11-16 Alexandre Duret-Lutz + * src/tgba/tgbatba.cc (state_tba_proxy::hash): Use wang32_hash. + * src/tgba/tgbaproduct.cc (state_product::hash): Likewise. + * src/misc/hashfunc.hh (wang32_hash): New file and function, extracted from... * src/evtgba/product.cc (evtgba_product_state::hash): ... here. diff --git a/src/tgba/tgbaproduct.cc b/src/tgba/tgbaproduct.cc index d6f3ce0df..0c591a4ea 100644 --- a/src/tgba/tgbaproduct.cc +++ b/src/tgba/tgbaproduct.cc @@ -22,6 +22,7 @@ #include "tgbaproduct.hh" #include #include +#include "misc/hashfunc.hh" namespace spot { @@ -56,8 +57,8 @@ namespace spot size_t state_product::hash() const { - // We assume that size_t has at least 32bits. - return (left_->hash() << 16) + (right_->hash() & 0xFFFF); + // We assume that size_t is 32-bit wide. + return wang32_hash(left_->hash()) ^ wang32_hash(right_->hash()); } state_product* diff --git a/src/tgba/tgbatba.cc b/src/tgba/tgbatba.cc index 394043533..31553b6e1 100644 --- a/src/tgba/tgbatba.cc +++ b/src/tgba/tgbatba.cc @@ -23,6 +23,7 @@ #include "tgbatba.hh" #include "bddprint.hh" #include "ltlast/constant.hh" +#include "misc/hashfunc.hh" namespace spot { @@ -30,7 +31,7 @@ namespace spot { /// \brief A state for spot::tgba_tba_proxy. /// - /// This state is in fact a pair of state: the state from the tgba + /// This state is in fact a pair of states: the state from the tgba /// automaton, and a state of the "counter" (we use a pointer /// to the position in the cycle_acc_ list). class state_tba_proxy: public state @@ -88,9 +89,7 @@ namespace spot virtual size_t hash() const { - // We expect to have many more states than acceptance conditions. - // Hence we keep only 8 bits for acceptance conditions. - return (s_->hash() << 8) + (acc_->id() & 0xFF); + return wang32_hash(s_->hash()) ^ wang32_hash(acc_->id()); } virtual