tgba_succ_iterator: have first() and next() return a bool

The returned Boolean indicates whether there is a successor or not.
This way

|  for (i->first(); !i->done(); i->next())
|    {
|       ...
|    }

can be replaced by

| if (i->first()) do
|   {
|      ...
|   }
| while (i->next());

avoiding all the virtual calls to done().

* iface/dve2/dve2.cc, src/kripke/kripkeexplicit.cc,
src/kripke/kripkeexplicit.hh, src/ta/ta.hh, src/ta/taexplicit.cc,
src/ta/taexplicit.hh, src/ta/taproduct.cc, src/ta/taproduct.hh,
src/ta/tgtaproduct.cc, src/ta/tgtaproduct.hh, src/tgba/succiter.hh,
src/tgba/succiterconcrete.cc, src/tgba/succiterconcrete.hh,
src/tgba/taatgba.cc, src/tgba/taatgba.hh, src/tgba/tgba.hh,
src/tgba/tgbaexplicit.hh, src/tgba/tgbakvcomplement.cc,
src/tgba/tgbamask.cc, src/tgba/tgbaproduct.cc,
src/tgba/tgbasafracomplement.cc, src/tgba/tgbasgba.cc,
src/tgba/tgbatba.cc, src/tgba/tgbaunion.cc, src/tgba/tgbaunion.hh,
src/tgba/wdbacomp.cc: Implement and adjust to this new interface.
This commit is contained in:
Alexandre Duret-Lutz 2014-01-26 22:57:14 +01:00
parent 06c69f88ff
commit 1a5c0cb1f3
26 changed files with 256 additions and 206 deletions

View file

@ -104,26 +104,24 @@ namespace spot
delete right_;
}
virtual void next_non_false_() = 0;
virtual bool next_non_false_() = 0;
void first()
bool first()
{
if (!right_)
return;
return false;
left_->first();
right_->first();
// If one of the two successor sets is empty initially, we
// reset right_, so that done() can detect this situation
// easily. (We choose to reset right_ because this variable
// is already used by done().)
if (left_->done() || right_->done())
if (!(left_->first() && right_->first()))
{
delete right_;
right_ = 0;
return;
return false;
}
next_non_false_();
return next_non_false_();
}
bool done() const
@ -166,19 +164,18 @@ namespace spot
{
}
void step_()
bool step_()
{
left_->next();
if (left_->done())
{
left_->first();
right_->next();
}
if (left_->next())
return true;
left_->first();
return right_->next();
}
void next_non_false_()
bool next_non_false_()
{
while (!done())
assert(!done());
do
{
bdd l = left_->current_condition();
bdd r = right_->current_condition();
@ -187,16 +184,18 @@ namespace spot
if (current_cond != bddfalse)
{
current_cond_ = current_cond;
return;
return true;
}
step_();
}
while (step_());
return false;
}
void next()
bool next()
{
step_();
next_non_false_();
if (step_())
return next_non_false_();
return false;
}
bdd current_condition() const
@ -235,12 +234,13 @@ namespace spot
{
}
void next_non_false_()
bool next_non_false_()
{
// All the transitions of left_ iterator have the
// same label, because it is a Kripke structure.
bdd l = left_->current_condition();
while (!right_->done())
assert(!right_->done());
do
{
bdd r = right_->current_condition();
bdd current_cond = l & r;
@ -248,21 +248,21 @@ namespace spot
if (current_cond != bddfalse)
{
current_cond_ = current_cond;
return;
return true;
}
right_->next();
}
while (right_->next());
return false;
}
void next()
bool next()
{
left_->next();
if (left_->done())
{
left_->first();
right_->next();
next_non_false_();
}
if (left_->next())
return true;
left_->first();
if (right_->next())
return next_non_false_();
return false;
}
bdd current_condition() const