Return a set of DiscreteKey, Fixes issue #1384

release/4.3a0
Frank Dellaert 2023-01-11 23:50:17 -08:00
parent 28f440a623
commit f4c3131ee2
2 changed files with 5 additions and 5 deletions

View File

@ -25,17 +25,17 @@
namespace gtsam {
/* ************************************************************************* */
DiscreteKeys HybridFactorGraph::discreteKeys() const {
DiscreteKeys keys;
std::set<DiscreteKey> HybridFactorGraph::discreteKeys() const {
std::set<DiscreteKey> keys;
for (auto& factor : factors_) {
if (auto p = boost::dynamic_pointer_cast<DecisionTreeFactor>(factor)) {
for (const DiscreteKey& key : p->discreteKeys()) {
keys.push_back(key);
keys.insert(key);
}
}
if (auto p = boost::dynamic_pointer_cast<HybridFactor>(factor)) {
for (const DiscreteKey& key : p->discreteKeys()) {
keys.push_back(key);
keys.insert(key);
}
}
}

View File

@ -65,7 +65,7 @@ class HybridFactorGraph : public FactorGraph<Factor> {
/// @{
/// Get all the discrete keys in the factor graph.
DiscreteKeys discreteKeys() const;
std::set<DiscreteKey> discreteKeys() const;
/// Get all the discrete keys in the factor graph, as a set.
KeySet discreteKeySet() const;