diff --git a/gtsam/hybrid/HybridFactorGraph.cpp b/gtsam/hybrid/HybridFactorGraph.cpp index 2224c4a38..2d46ae201 100644 --- a/gtsam/hybrid/HybridFactorGraph.cpp +++ b/gtsam/hybrid/HybridFactorGraph.cpp @@ -45,9 +45,10 @@ DiscreteKeys HybridFactorGraph::discreteKeys() const { /* ************************************************************************* */ KeySet HybridFactorGraph::discreteKeySet() const { KeySet keys; - for (const DiscreteKey& k : discreteKeys()) { - keys.insert(k.first); - } + DiscreteKeys key_vector = discreteKeys(); + std::transform(key_vector.begin(), key_vector.end(), + std::inserter(keys, keys.begin()), + [](const DiscreteKey& k) { return k.first; }); return keys; } diff --git a/gtsam/hybrid/HybridFactorGraph.h b/gtsam/hybrid/HybridFactorGraph.h index a02d4a212..7d30663a3 100644 --- a/gtsam/hybrid/HybridFactorGraph.h +++ b/gtsam/hybrid/HybridFactorGraph.h @@ -65,7 +65,7 @@ class HybridFactorGraph : public FactorGraph { /// @{ /// Get all the discrete keys in the factor graph. - std::set discreteKeys() const; + DiscreteKeys discreteKeys() const; /// Get all the discrete keys in the factor graph, as a set. KeySet discreteKeySet() const;