File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -105,24 +105,24 @@ bool Expression::contains(const Expression& e) const {
105105 if (*this == e) {
106106 return true ;
107107 }
108- for (auto & c : children) {
109- if (c.contains (e)) {
110- return true ;
111- }
112- }
113- return false ;
108+ return std::any_of (children.begin (), children.end (),
109+ [&](const Expression& c) { return c.contains (e); });
114110}
115111
116112bool Expression::contains (Type t) const {
117113 if (type == t) {
118114 return true ;
119115 }
120- for (auto & c : children) {
121- if (c.contains (t)) {
122- return true ;
123- }
116+ return std::any_of (children.begin (), children.end (),
117+ [&](const Expression& c) { return c.contains (t); });
118+ }
119+
120+ bool Expression::contains (Type t, const std::string& name) const {
121+ if (type == t && this ->name == name) {
122+ return true ;
124123 }
125- return false ;
124+ return std::any_of (children.begin (), children.end (),
125+ [&](const Expression& c) { return c.contains (t, name); });
126126}
127127
128128size_t Expression::numTerms () const {
Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ class Expression {
4949
5050 bool contains (Type t) const ;
5151
52+ bool contains (Type t, const std::string& name) const ;
53+
5254 size_t numTerms () const ;
5355
5456 Expression& newChild (const Expression& e);
You can’t perform that action at this time.
0 commit comments