本文整理汇总了C++中Formula::isTrue方法的典型用法代码示例。如果您正苦于以下问题:C++ Formula::isTrue方法的具体用法?C++ Formula::isTrue怎么用?C++ Formula::isTrue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Formula
的用法示例。
在下文中一共展示了Formula::isTrue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: simplify
Formula* Conjunction::simplify() const {
std::set<Formula*> simpChildren;
typedef std::set<Formula*>::const_iterator ChildIter;
for (ChildIter c = children.begin(); c != children.end(); ++c) {
Formula* sc = (*c)->simplify();
if (sc->isFalse()) {
for (ChildIter cd = simpChildren.begin(); cd != simpChildren.end(); ++cd)
delete *cd;
return sc;
}
else if (sc->isTrue())
delete sc;
else {
//if conjunction, pull its children up, and then delete it
Conjunction* conChild = dynamic_cast<Conjunction*>(sc);
if (conChild == NULL) {
if (simpChildren.find(sc) == simpChildren.end())
simpChildren.insert(sc); //TODO memory leak if duplicate?
else
delete sc;
}
else { //TODO memory leak?
for (ChildIter cc = conChild->children.begin(); cc != conChild->children.end(); ++cc) {
if (simpChildren.find(*cc) == simpChildren.end())
simpChildren.insert(*cc);
else
delete *cc;
}
conChild->children.clear();
delete sc; //TODO does this prevent leak or is it overkill?
}
}
}
if (simpChildren.empty())
return new True();
if (simpChildren.size() == 1)
return *simpChildren.begin();
return new Conjunction(simpChildren);
}