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

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.
parent 38148f87
2009-11-18 Alexandre Duret-Lutz <adl@lrde.epita.fr>
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.
2009-11-17 Alexandre Duret-Lutz <adl@lrde.epita.fr>
* src/tgbaalgos/cutscc.cc (cut_scc): Pass `s' by reference instead
......
// 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()
{
......
// Copyright (C) 2003, 2004, 2008 Laboratoire d'Informatique de Paris 6
// Copyright (C) 2003, 2004, 2008, 2009 Laboratoire d'Informatique de Paris 6
// (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
// Pierre et Marie Curie.
//
......@@ -56,6 +56,10 @@ namespace spot
virtual const state* next_state() = 0;
/// \}
/// Called by add_state or next_states implementations to filter
/// states. Default implementation always return true.
virtual bool want_state(const state* s) const;
/// Called by run() before starting its iteration.
virtual void start();
/// Called by run() once all states have been explored.
......
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