fix visitWith operator() to be more functional
parent
5e9020237f
commit
13c60990f7
|
|
@ -33,6 +33,8 @@ namespace gtsam {
|
||||||
template <class L>
|
template <class L>
|
||||||
class Assignment : public std::map<L, size_t> {
|
class Assignment : public std::map<L, size_t> {
|
||||||
public:
|
public:
|
||||||
|
using std::map<L, size_t>::operator=;
|
||||||
|
|
||||||
void print(const std::string& s = "Assignment: ") const {
|
void print(const std::string& s = "Assignment: ") const {
|
||||||
std::cout << s << ": ";
|
std::cout << s << ": ";
|
||||||
for (const typename Assignment::value_type& keyValue : *this)
|
for (const typename Assignment::value_type& keyValue : *this)
|
||||||
|
|
|
||||||
|
|
@ -666,8 +666,11 @@ namespace gtsam {
|
||||||
if (!choice)
|
if (!choice)
|
||||||
throw std::invalid_argument("DecisionTree::VisitWith: Invalid NodePtr");
|
throw std::invalid_argument("DecisionTree::VisitWith: Invalid NodePtr");
|
||||||
for (size_t i = 0; i < choice->nrChoices(); i++) {
|
for (size_t i = 0; i < choice->nrChoices(); i++) {
|
||||||
choices[choice->label()] = i; // Set assignment for label to i
|
choices[choice->label()] = i; // Set assignment for label to i
|
||||||
(*this)(choice->branches()[i]); // recurse!
|
|
||||||
|
VisitWith<L, Y> visit(f);
|
||||||
|
visit.choices = choices;
|
||||||
|
visit(choice->branches()[i]); // recurse!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue