Modify is_accepting sba's method to run in constant time.

* src/tgba/tgbaexplicit.hh: modify is_accepting method
This commit is contained in:
Pierre PARUTTO 2012-04-05 17:47:38 +02:00 committed by Alexandre Duret-Lutz
parent eec3a12f80
commit 9cfc408262

View file

@ -721,21 +721,24 @@ namespace spot
{ {
} }
/// Assume that an accepting state has only accepting output transitions
/// So we need only to check one to decide
virtual bool is_accepting(const spot::state* s) const virtual bool is_accepting(const spot::state* s) const
{ {
bdd acc = bddtrue;
bool transition = false;
tgba_explicit_succ_iterator<State>* it = this->succ_iter(s); tgba_explicit_succ_iterator<State>* it = this->succ_iter(s);
for (it->first(); !it->done() && acc != bddfalse; it->next()) it->first();
// no transition
if (it->done())
{ {
transition = true; delete it;
acc &= it->current_acceptance_conditions(); return false;
} }
bool res = it->current_acceptance_conditions() != bddfalse;
delete it; delete it;
return acc != bddfalse && transition; return res;
} }
private: private: