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

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2010, 2012, 2013 Laboratoire de Recherche et
// Copyright (C) 2010, 2012, 2013, 2014 Laboratoire de Recherche et
// Developpement de l Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -191,12 +191,9 @@ namespace spot
{
}
virtual void
first() = 0;
virtual void
next() = 0;
virtual bool
done() const = 0;
virtual bool first() = 0;
virtual bool next() = 0;
virtual bool done() const = 0;
virtual state*
current_state() const = 0;

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2010, 2011, 2012, 2013 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2010, 2011, 2012, 2013, 2014 Laboratoire de Recherche
// et Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -54,24 +54,26 @@ namespace spot
transitions_ = s->get_transitions(condition);
}
void
bool
ta_explicit_succ_iterator::first()
{
if (transitions_ != 0)
i_ = transitions_->begin();
if (!transitions_)
return false;
i_ = transitions_->begin();
return i_ != transitions_->end();
}
void
bool
ta_explicit_succ_iterator::next()
{
++i_;
return i_ != transitions_->end();
}
bool
ta_explicit_succ_iterator::done() const
{
return transitions_ == 0 || transitions_->empty() || i_
== transitions_->end();
return !transitions_ || i_ == transitions_->end();
}
state*

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2010, 2011, 2012, 2013 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
// Copyright (C) 2010, 2011, 2012, 2013, 2014 Laboratoire de Recherche
// et Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -248,12 +248,9 @@ namespace spot
ta_explicit_succ_iterator(const state_ta_explicit* s, bdd condition);
virtual void
first();
virtual void
next();
virtual bool
done() const;
virtual bool first();
virtual bool next();
virtual bool done() const;
virtual state*
current_state() const;

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012 Laboratoire de Recherche et Développement
// Copyright (C) 2011, 2012, 2014 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
//
@ -150,17 +150,18 @@ namespace spot
}
void
bool
ta_succ_iterator_product::first()
{
next_kripke_dest();
if (!done())
next_non_stuttering_();
return next_non_stuttering_();
return false;
}
void
bool
ta_succ_iterator_product::next()
{
delete current_state_;
@ -173,11 +174,11 @@ namespace spot
step_();
if (!done())
next_non_stuttering_();
return next_non_stuttering_();
return false;
}
void
bool
ta_succ_iterator_product::next_non_stuttering_()
{
@ -190,7 +191,7 @@ namespace spot
current_state_ = new state_ta_product(source_->get_ta_state(),
kripke_current_dest_state->clone());
current_acceptance_conditions_ = bddfalse;
return;
return true;
}
if (!ta_succ_it_->done())
@ -199,11 +200,12 @@ namespace spot
kripke_current_dest_state->clone());
current_acceptance_conditions_
= ta_succ_it_->current_acceptance_conditions();
return;
return true;
}
step_();
}
return false;
}
bool

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012, 2013 Laboratoire de Recherche et
// Copyright (C) 2011, 2012, 2013, 2014 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -83,12 +83,9 @@ namespace spot
~ta_succ_iterator_product();
// iteration
void
first();
void
next();
bool
done() const;
bool first();
bool next();
bool done() const;
// inspection
state_ta_product*
@ -106,10 +103,8 @@ namespace spot
protected:
//@{
/// Internal routines to advance to the next successor.
void
step_();
void
next_non_stuttering_();
void step_();
bool next_non_stuttering_();
/// \brief Move to the next successor in the kripke structure
void

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012 Laboratoire de Recherche et Developpement
// Copyright (C) 2012, 2014 Laboratoire de Recherche et Développement
// de l Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -173,19 +173,16 @@ namespace spot
}
void
bool
tgta_succ_iterator_product::first()
{
next_kripke_dest();
trace
<< "*** first() .... if(done()) = ***" << done() << std::endl;
if (!done())
find_next_succ_();
trace << "*** first() .... if(done()) = ***" << done() << std::endl;
return find_next_succ_();
}
void
bool
tgta_succ_iterator_product::next()
{
current_state_->destroy();
@ -193,18 +190,14 @@ namespace spot
step_();
trace
<< "*** next() .... if(done()) = ***" << done() << std::endl;
if (!done())
find_next_succ_();
trace << "*** next() .... if(done()) = ***" << done() << std::endl;
return find_next_succ_();
}
void
bool
tgta_succ_iterator_product::find_next_succ_()
{
while (!done())
{
if (!tgta_succ_it_->done())
@ -214,11 +207,12 @@ namespace spot
tgta_succ_it_->current_state(), pool_);
current_acceptance_conditions_
= tgta_succ_it_->current_acceptance_conditions();
return;
return true;
}
step_();
}
return false;
}
bool

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012, 2013 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2011, 2012, 2013, 2014 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
@ -54,12 +54,9 @@ namespace spot
~tgta_succ_iterator_product();
// iteration
void
first();
void
next();
bool
done() const;
bool first();
bool next();
bool done() const;
// inspection
state_product*
@ -75,8 +72,7 @@ namespace spot
/// Internal routines to advance to the next successor.
void
step_();
void
find_next_succ_();
bool find_next_succ_();
void
next_kripke_dest();