(state_ptr_equal, state_ptr_hash): New functors. * src/tgba/statebdd.hh, src/tgba/statebdd.cc (state_bdd::hash): New method. * src/tgba/tgbaexplicit.hh, src/tgba/tgbaexplicit.cc (state_explicit::hash): New method. (ns_map, sn_map): Use Sgi::hash_map instead of std::map. * src/tgba/tgbaproduct.hh, src/tgba/tgbaproduct.cc (state_product::hash): New method. * src/tgba/tgbatba.cc (state_tba_proxy::hash): New method. * src/tgbaalgos/lbtt.cc (acp_seen, todo_set, seen_map): Redefine using Sgi::hash_map or Sgi::hash_set. (lbtt_reachable): Don't erase a key that is pointed to by an iterator. * src/tgbaalgos/reachiter.cc (tgba_reachable_iterator::~tgba_reachable_iterator): Likewise. * src/tgbaalgos/magic.cc (magic_search::~magic_search()): Likewise. * src/tgbaalgos/magic.hh (hash_type): Redefine using Sgi::hash_map. * src/tgbaalgos/reachiter.hh (seen_map): Redefine using Sgi::hash_map. * iface/gspn/gspn.cc (state_gspn::hash): New method. * src/misc/hash.hh (string_hash): New functor.
133 lines
2.6 KiB
C++
133 lines
2.6 KiB
C++
#include <cassert>
|
|
#include "reachiter.hh"
|
|
|
|
namespace spot
|
|
{
|
|
// tgba_reachable_iterator
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
tgba_reachable_iterator::tgba_reachable_iterator(const tgba* a)
|
|
: automata_(a)
|
|
{
|
|
}
|
|
|
|
tgba_reachable_iterator::~tgba_reachable_iterator()
|
|
{
|
|
seen_map::const_iterator s = seen.begin();
|
|
while (s != seen.end())
|
|
{
|
|
// Advance the iterator before deleting the "key" pointer.
|
|
const state* ptr = s->first;
|
|
++s;
|
|
delete ptr;
|
|
}
|
|
}
|
|
|
|
void
|
|
tgba_reachable_iterator::run()
|
|
{
|
|
int n = 0;
|
|
start();
|
|
state* i = automata_->get_init_state();
|
|
add_state(i);
|
|
seen[i] = ++n;
|
|
const state* t;
|
|
while ((t = next_state()))
|
|
{
|
|
assert(seen.find(t) != seen.end());
|
|
int tn = seen[t];
|
|
tgba_succ_iterator* si = automata_->succ_iter(t);
|
|
process_state(t, tn, si);
|
|
for (si->first(); ! si->done(); si->next())
|
|
{
|
|
const state* current = si->current_state();
|
|
seen_map::const_iterator s = seen.find(current);
|
|
if (s == seen.end())
|
|
{
|
|
seen[current] = ++n;
|
|
add_state(current);
|
|
process_link(tn, n, si);
|
|
}
|
|
else
|
|
{
|
|
process_link(tn, seen[current], si);
|
|
delete current;
|
|
}
|
|
}
|
|
delete si;
|
|
}
|
|
end();
|
|
}
|
|
|
|
void
|
|
tgba_reachable_iterator::start()
|
|
{
|
|
}
|
|
|
|
void
|
|
tgba_reachable_iterator::end()
|
|
{
|
|
}
|
|
|
|
void
|
|
tgba_reachable_iterator::process_state(const state*, int,
|
|
tgba_succ_iterator*)
|
|
{
|
|
}
|
|
|
|
void
|
|
tgba_reachable_iterator::process_link(int, int, const tgba_succ_iterator*)
|
|
{
|
|
}
|
|
|
|
// tgba_reachable_iterator_depth_first
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
tgba_reachable_iterator_depth_first::
|
|
tgba_reachable_iterator_depth_first(const tgba* a)
|
|
: tgba_reachable_iterator(a)
|
|
{
|
|
}
|
|
|
|
void
|
|
tgba_reachable_iterator_depth_first::add_state(const state* s)
|
|
{
|
|
todo.push(s);
|
|
}
|
|
|
|
const state*
|
|
tgba_reachable_iterator_depth_first::next_state()
|
|
{
|
|
if (todo.empty())
|
|
return 0;
|
|
const state* s = todo.top();
|
|
todo.pop();
|
|
return s;
|
|
}
|
|
|
|
// tgba_reachable_iterator_breadth_first
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
tgba_reachable_iterator_breadth_first::
|
|
tgba_reachable_iterator_breadth_first(const tgba* a)
|
|
: tgba_reachable_iterator(a)
|
|
{
|
|
}
|
|
|
|
void
|
|
tgba_reachable_iterator_breadth_first::add_state(const state* s)
|
|
{
|
|
todo.push_back(s);
|
|
}
|
|
|
|
const state*
|
|
tgba_reachable_iterator_breadth_first::next_state()
|
|
{
|
|
if (todo.empty())
|
|
return 0;
|
|
const state* s = todo.front();
|
|
todo.pop_front();
|
|
return s;
|
|
}
|
|
|
|
}
|