summaryrefslogtreecommitdiff
path: root/src/theory/bv
diff options
context:
space:
mode:
authorAina Niemetz <aina.niemetz@gmail.com>2018-02-07 00:55:44 -0800
committerGitHub <noreply@github.com>2018-02-07 00:55:44 -0800
commit82066be04ce068b59b24526fbc8c9b4188503cae (patch)
tree56a0738658dfd7ad80e037ff6e191bdcc8592b0d /src/theory/bv
parentd21740e08eb7ff05485ec2faca019adde8e57a99 (diff)
Use template for bv::utils::mkAnd. (#1569)
Diffstat (limited to 'src/theory/bv')
-rw-r--r--src/theory/bv/theory_bv_utils.cpp56
-rw-r--r--src/theory/bv/theory_bv_utils.h17
2 files changed, 15 insertions, 58 deletions
diff --git a/src/theory/bv/theory_bv_utils.cpp b/src/theory/bv/theory_bv_utils.cpp
index da3822aa6..7df575ece 100644
--- a/src/theory/bv/theory_bv_utils.cpp
+++ b/src/theory/bv/theory_bv_utils.cpp
@@ -370,62 +370,6 @@ Node mkAnd(TNode node1, TNode node2)
return NodeManager::currentNM()->mkNode(kind::AND, node1, node2);
}
-Node mkAnd(const std::vector<TNode>& conjunctions)
-{
- std::set<TNode> all;
- all.insert(conjunctions.begin(), conjunctions.end());
-
- if (all.size() == 0)
- {
- return mkTrue();
- }
-
- if (all.size() == 1)
- {
- // All the same, or just one
- return conjunctions[0];
- }
-
- NodeBuilder<> conjunction(kind::AND);
- std::set<TNode>::const_iterator it = all.begin();
- std::set<TNode>::const_iterator it_end = all.end();
- while (it != it_end)
- {
- conjunction << *it;
- ++it;
- }
-
- return conjunction;
-}
-
-Node mkAnd(const std::vector<Node>& conjunctions)
-{
- std::set<TNode> all;
- all.insert(conjunctions.begin(), conjunctions.end());
-
- if (all.size() == 0)
- {
- return mkTrue();
- }
-
- if (all.size() == 1)
- {
- // All the same, or just one
- return conjunctions[0];
- }
-
- NodeBuilder<> conjunction(kind::AND);
- std::set<TNode>::const_iterator it = all.begin();
- std::set<TNode>::const_iterator it_end = all.end();
- while (it != it_end)
- {
- conjunction << *it;
- ++it;
- }
-
- return conjunction;
-}
-
Node mkOr(TNode node1, TNode node2)
{
return NodeManager::currentNM()->mkNode(kind::OR, node1, node2);
diff --git a/src/theory/bv/theory_bv_utils.h b/src/theory/bv/theory_bv_utils.h
index 6115a7e96..6e6cdcabe 100644
--- a/src/theory/bv/theory_bv_utils.h
+++ b/src/theory/bv/theory_bv_utils.h
@@ -127,8 +127,21 @@ Node mkSortedNode(Kind kind, std::vector<Node>& children);
Node mkNot(Node child);
/* Create node of kind AND. */
Node mkAnd(TNode node1, TNode node2);
-Node mkAnd(const std::vector<TNode>& conjunctions);
-Node mkAnd(const std::vector<Node>& conjunctions);
+/* Create n-ary node of kind AND. */
+template<bool ref_count>
+Node mkAnd(const std::vector<NodeTemplate<ref_count>>& conjunctions)
+{
+ std::set<TNode> all(conjunctions.begin(), conjunctions.end());
+
+ if (all.size() == 0) { return mkTrue(); }
+
+ /* All the same, or just one */
+ if (all.size() == 1) { return conjunctions[0]; }
+
+ NodeBuilder<> conjunction(kind::AND);
+ for (const Node& n : all) { conjunction << n; }
+ return conjunction;
+}
/* Create node of kind OR. */
Node mkOr(TNode node1, TNode node2);
Node mkOr(const std::vector<Node>& nodes);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback