Replaced add variants with single variadic template

release/4.3a0
Frank Dellaert 2021-12-26 23:14:35 -05:00
parent 5882847604
commit 34c3d6af5e
1 changed files with 5 additions and 22 deletions

View File

@ -101,27 +101,10 @@ public:
/// @} /// @}
// Add single key decision-tree factor. /** Add a decision-tree factor */
template <class SOURCE> template <typename... Args>
void add(const DiscreteKey& j, SOURCE table) { void add(Args&&... args) {
DiscreteKeys keys; emplace_shared<DecisionTreeFactor>(std::forward<Args>(args)...);
keys.push_back(j);
emplace_shared<DecisionTreeFactor>(keys, table);
}
// Add binary key decision-tree factor.
template <class SOURCE>
void add(const DiscreteKey& j1, const DiscreteKey& j2, SOURCE table) {
DiscreteKeys keys;
keys.push_back(j1);
keys.push_back(j2);
emplace_shared<DecisionTreeFactor>(keys, table);
}
// Add shared discreteFactor immediately from arguments.
template <class SOURCE>
void add(const DiscreteKeys& keys, SOURCE table) {
emplace_shared<DecisionTreeFactor>(keys, table);
} }
/** Return the set of variables involved in the factors (set union) */ /** Return the set of variables involved in the factors (set union) */