sort the parfactors by their parameters when printing
This commit is contained in:
parent
20fc2c8dd1
commit
52f4aa0340
@ -113,9 +113,10 @@ ParfactorList::isAllShattered (void) const
|
|||||||
void
|
void
|
||||||
ParfactorList::print (void) const
|
ParfactorList::print (void) const
|
||||||
{
|
{
|
||||||
list<Parfactor*>::const_iterator it;
|
Parfactors pfVec (pfList_.begin(), pfList_.end());
|
||||||
for (it = pfList_.begin(); it != pfList_.end(); ++it) {
|
std::sort (pfVec.begin(), pfVec.end(), sortByParams());
|
||||||
(*it)->print();
|
for (unsigned i = 0; i < pfVec.size(); i++) {
|
||||||
|
pfVec[i]->print();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +90,20 @@ class ParfactorList
|
|||||||
const ProbFormula&, ConstraintTree,
|
const ProbFormula&, ConstraintTree,
|
||||||
const ProbFormula&, ConstraintTree) const;
|
const ProbFormula&, ConstraintTree) const;
|
||||||
|
|
||||||
|
struct sortByParams
|
||||||
|
{
|
||||||
|
inline bool operator() (const Parfactor* pf1, const Parfactor* pf2)
|
||||||
|
{
|
||||||
|
if (pf1->params().size() < pf2->params().size()) {
|
||||||
|
return true;
|
||||||
|
} else if (pf1->params().size() == pf2->params().size() &&
|
||||||
|
pf1->params() < pf2->params()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
list<Parfactor*> pfList_;
|
list<Parfactor*> pfList_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user