summaryrefslogtreecommitdiff
path: root/src/expr/node_algorithm.cpp
diff options
context:
space:
mode:
authorAndres Noetzli <andres.noetzli@gmail.com>2020-02-27 00:08:42 -0800
committerGitHub <noreply@github.com>2020-02-27 00:08:42 -0800
commitc2e7c568f5741215ac58cb7fd47952c52876fa0f (patch)
tree1cc745df05031b4d5665e8548f786f0ad1707605 /src/expr/node_algorithm.cpp
parent6c687e2d76f16328d5a2d10ab32a582fb18e00f2 (diff)
parent87f3741db6ed41d3a776774bc1b60fd696585391 (diff)
Merge branch 'master' into fixWShadowfixWShadow
Diffstat (limited to 'src/expr/node_algorithm.cpp')
-rw-r--r--src/expr/node_algorithm.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/expr/node_algorithm.cpp b/src/expr/node_algorithm.cpp
index 9619e69d1..595adda55 100644
--- a/src/expr/node_algorithm.cpp
+++ b/src/expr/node_algorithm.cpp
@@ -129,6 +129,32 @@ bool hasSubtermMulti(TNode n, TNode t)
return false;
}
+bool hasSubtermKind(Kind k, Node n)
+{
+ std::unordered_set<TNode, TNodeHashFunction> visited;
+ std::vector<TNode> visit;
+ TNode cur;
+ visit.push_back(n);
+ do
+ {
+ cur = visit.back();
+ visit.pop_back();
+ if (visited.find(cur) == visited.end())
+ {
+ visited.insert(cur);
+ if (cur.getKind() == k)
+ {
+ return true;
+ }
+ for (const Node& cn : cur)
+ {
+ visit.push_back(cn);
+ }
+ }
+ } while (!visit.empty());
+ return false;
+}
+
bool hasSubterm(TNode n, const std::vector<Node>& t, bool strict)
{
if (t.empty())
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback