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