[GIT] ppl/ppl(devel): Provide a common, correct implementation for the methods

Module: ppl/ppl Branch: devel Commit: e7cc925274945a76599d9601a24e001adfc534a1 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=e7cc925274945...
Author: Enea Zaffanella zaffanella@cs.unipr.it Date: Thu Nov 19 12:36:02 2015 +0100
Provide a common, correct implementation for the methods Pointset_Powerset<PSET>::relation_with() working on Constraint and Congruence objects.
---
src/Pointset_Powerset_defs.hh | 7 ++++ src/Pointset_Powerset_inlines.hh | 12 ++++++++ src/Pointset_Powerset_templates.hh | 56 +---------------------------------- 3 files changed, 21 insertions(+), 54 deletions(-)
diff --git a/src/Pointset_Powerset_defs.hh b/src/Pointset_Powerset_defs.hh index 32615fb..6d4e321 100644 --- a/src/Pointset_Powerset_defs.hh +++ b/src/Pointset_Powerset_defs.hh @@ -1294,6 +1294,13 @@ private: typename Cert::Compare>& y_cert_ms) const;
+ /*! \brief + Template helper: common implementation for constraints + and congruences. + */ + template <typename Cons_or_Congr> + Poly_Con_Relation relation_with_aux(const Cons_or_Congr& c) const; + // FIXME: here it should be enough to befriend the template constructor // template <typename QH> // Pointset_Powerset(const Pointset_Powerset<QH>&), diff --git a/src/Pointset_Powerset_inlines.hh b/src/Pointset_Powerset_inlines.hh index 460999e..54b03da 100644 --- a/src/Pointset_Powerset_inlines.hh +++ b/src/Pointset_Powerset_inlines.hh @@ -233,6 +233,18 @@ Pointset_Powerset<PSET>::time_elapse_assign(const Pointset_Powerset& y) { }
template <typename PSET> +inline Poly_Con_Relation +Pointset_Powerset<PSET>::relation_with(const Constraint& c) const { + return relation_with_aux(c); +} + +template <typename PSET> +inline Poly_Con_Relation +Pointset_Powerset<PSET>::relation_with(const Congruence& cg) const { + return relation_with_aux(cg); +} + +template <typename PSET> inline bool Pointset_Powerset<PSET> ::geometrically_covers(const Pointset_Powerset& y) const { diff --git a/src/Pointset_Powerset_templates.hh b/src/Pointset_Powerset_templates.hh index f2858c1..0f160a3 100644 --- a/src/Pointset_Powerset_templates.hh +++ b/src/Pointset_Powerset_templates.hh @@ -829,61 +829,9 @@ Pointset_Powerset<PSET>::strictly_contains(const Pointset_Powerset& y) const { }
template <typename PSET> +template <typename Cons_or_Congr> Poly_Con_Relation -Pointset_Powerset<PSET>::relation_with(const Congruence& cg) const { - const Pointset_Powerset& x = *this; - - /* *this is included in cg if every disjunct is included in cg */ - bool is_included = true; - /* *this is disjoint with cg if every disjunct is disjoint with cg */ - bool is_disjoint = true; - /* *this strictly_intersects with cg if some disjunct strictly - intersects with cg */ - bool is_strictly_intersecting = false; - /* *this saturates cg if some disjunct saturates cg and - every disjunct is either disjoint from cg or saturates cg */ - bool saturates_once = false; - bool may_saturate = true; - for (Sequence_const_iterator si = x.sequence.begin(), - s_end = x.sequence.end(); si != s_end; ++si) { - Poly_Con_Relation relation_i = si->pointset().relation_with(cg); - if (!relation_i.implies(Poly_Con_Relation::is_included())) { - is_included = false; - } - if (!relation_i.implies(Poly_Con_Relation::is_disjoint())) { - is_disjoint = false; - } - if (relation_i.implies(Poly_Con_Relation::strictly_intersects())) { - is_strictly_intersecting = true; - } - if (relation_i.implies(Poly_Con_Relation::saturates())) { - saturates_once = true; - } - else if (!relation_i.implies(Poly_Con_Relation::is_disjoint())) { - may_saturate = false; - } - } - - Poly_Con_Relation result = Poly_Con_Relation::nothing(); - if (is_included) { - result = result && Poly_Con_Relation::is_included(); - } - if (is_disjoint) { - result = result && Poly_Con_Relation::is_disjoint(); - } - if (is_strictly_intersecting) { - result = result && Poly_Con_Relation::strictly_intersects(); - } - if (saturates_once && may_saturate) { - result = result && Poly_Con_Relation::saturates(); - } - - return result; -} - -template <typename PSET> -Poly_Con_Relation -Pointset_Powerset<PSET>::relation_with(const Constraint& c) const { +Pointset_Powerset<PSET>::relation_with_aux(const Cons_or_Congr& c) const { const Pointset_Powerset& x = *this;
/* *this is included in c if every disjunct is included in c */
participants (1)
-
Enea Zaffanella