Make it easy to filter states while iterating over an automaton.
* src/tgbaalgos/reachiter.hh (tgba_reachable_iterator::want_state): New method. * src/tgbaalgos/reachiter.cc (tgba_reachable_iterator::want_state): Implement it. (tgba_reachable_iterator::run): Call want_state before processing a state.
This commit is contained in:
parent
38148f87f8
commit
ac5dda1032
3 changed files with 33 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// Copyright (C) 2003, 2004, 2009 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
// et Marie Curie.
|
||||
//
|
||||
|
|
@ -50,7 +50,8 @@ namespace spot
|
|||
int n = 0;
|
||||
start();
|
||||
state* i = automata_->get_init_state();
|
||||
add_state(i);
|
||||
if (want_state(i))
|
||||
add_state(i);
|
||||
seen[i] = ++n;
|
||||
const state* t;
|
||||
while ((t = next_state()))
|
||||
|
|
@ -63,15 +64,20 @@ namespace spot
|
|||
{
|
||||
const state* current = si->current_state();
|
||||
seen_map::const_iterator s = seen.find(current);
|
||||
bool ws = want_state(current);
|
||||
if (s == seen.end())
|
||||
{
|
||||
seen[current] = ++n;
|
||||
add_state(current);
|
||||
process_link(t, tn, current, n, si);
|
||||
if (ws)
|
||||
{
|
||||
add_state(current);
|
||||
process_link(t, tn, current, n, si);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
process_link(t, tn, s->first, s->second, si);
|
||||
if (ws)
|
||||
process_link(t, tn, s->first, s->second, si);
|
||||
delete current;
|
||||
}
|
||||
}
|
||||
|
|
@ -80,6 +86,12 @@ namespace spot
|
|||
end();
|
||||
}
|
||||
|
||||
bool
|
||||
tgba_reachable_iterator::want_state(const state*) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
tgba_reachable_iterator::start()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue