From e0cf8fd2f61a34b65a0baf3585fd2bfdd0165b2b Mon Sep 17 00:00:00 2001 From: Tim King Date: Sat, 24 Nov 2012 23:32:04 +0000 Subject: [PATCH] Adds ensureConstraint(...) to ConstraintDatabase. This is a slightly optimized way of doing getConstraint() if the user already has a ValueCollection&. --- src/theory/arith/constraint.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/theory/arith/constraint.h b/src/theory/arith/constraint.h index 7295b17e0..8bf5447e3 100644 --- a/src/theory/arith/constraint.h +++ b/src/theory/arith/constraint.h @@ -841,6 +841,21 @@ public: */ Constraint getConstraint(ArithVar v, ConstraintType t, const DeltaRational& r); + /** + * Returns a constraint of the given type for the value and variable + * for the given ValueCollection, vc. + * This is made if there is no such constraint. + * Weirdly enough vc may be altered despite this signature! + */ + Constraint ensureConstraint(ValueCollection& vc, ConstraintType t){ + if(vc.hasConstraintOfType(t)){ + return vc.getConstraintOfType(t); + }else{ + return getConstraint(vc.getVariable(), t, vc.getValue()); + } + } + + /** * Outputs a minimal set of unate implications onto the vector for the variable. * This outputs lemmas of the general forms -- 2.30.2