* src/tgba/tgbacomplement.cc (state_complement::hash): Improve

the hash function.
This commit is contained in:
Guillaume Sadegh 2009-06-07 18:26:26 +02:00
parent 8fe11196bd
commit 3a3e5d4bff
2 changed files with 35 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2009-06-07 Guillaume Sadegh <sadegh@lrde.epita.fr>
* src/tgba/tgbacomplement.cc (state_complement::hash): Improve
the hash function.
2009-06-09 Damien Lefortier <dam@lrde.epita.fr>
* src/eltlparse/eltlparse.yy: Fix a memory leak.

View file

@ -106,6 +106,7 @@ namespace spot
const safra_tree& operator=(const safra_tree& other);
int compare(const safra_tree* other) const;
size_t hash() const;
void add_node(const state* s);
int max_name() const;
@ -232,6 +233,24 @@ namespace spot
return 0;
}
/// \brief Hash a safra tree.
size_t
safra_tree::hash() const
{
size_t hash = 0;
hash ^= wang32_hash(name);
hash ^= wang32_hash(marked);
for (subset_t::const_iterator i = nodes.begin(); i != nodes.end(); ++i)
hash ^= (*i)->hash();
for (child_list::const_iterator i = children.begin(); i != children.end(); ++i)
hash ^= (*i)->hash();
return hash;
}
void
safra_tree::add_node(const state* s)
{
@ -912,7 +931,17 @@ namespace spot
size_t
state_complement::hash() const
{
return 0; // \todo
size_t hash = tree->hash();
hash ^= wang32_hash(use_bitset);
size_t size_bitset = L.size();
for (unsigned i = 0; i < size_bitset; ++i)
{
hash ^= wang32_hash(L[i]);
hash ^= wang32_hash(U[i]); // \todo To not apply for TGBAs
}
return hash;
}
state_complement*