diff options
author | Andres Noetzli <andres.noetzli@gmail.com> | 2020-02-27 00:08:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-27 00:08:42 -0800 |
commit | c2e7c568f5741215ac58cb7fd47952c52876fa0f (patch) | |
tree | 1cc745df05031b4d5665e8548f786f0ad1707605 /src/expr/node_algorithm.cpp | |
parent | 6c687e2d76f16328d5a2d10ab32a582fb18e00f2 (diff) | |
parent | 87f3741db6ed41d3a776774bc1b60fd696585391 (diff) |
Merge branch 'master' into fixWShadowfixWShadow
Diffstat (limited to 'src/expr/node_algorithm.cpp')
-rw-r--r-- | src/expr/node_algorithm.cpp | 26 |
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()) |