From 28db8b20ff15e3b66e5e61c72e385e46212af702 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Sat, 4 Jun 2022 11:45:42 -0400 Subject: [PATCH] use KeyVector and iterator constructor --- gtsam/hybrid/HybridBayesNet.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gtsam/hybrid/HybridBayesNet.cpp b/gtsam/hybrid/HybridBayesNet.cpp index d3c77d83e..0403ca0d3 100644 --- a/gtsam/hybrid/HybridBayesNet.cpp +++ b/gtsam/hybrid/HybridBayesNet.cpp @@ -82,14 +82,12 @@ HybridBayesNet HybridBayesNet::prune( // reverse keys to get a natural ordering std::reverse(discreteKeys.begin(), discreteKeys.end()); - // Convert from boost::iterator_range to std::vector. - std::vector frontals, parents; - for (Key key : gaussianMixture->frontals()) { - frontals.push_back(key); - } - for (Key key : gaussianMixture->parents()) { - parents.push_back(key); - } + // Convert from boost::iterator_range to KeyVector + // so we can pass it to constructor. + KeyVector frontals(gaussianMixture->frontals().begin(), + gaussianMixture->frontals().end()), + parents(gaussianMixture->parents().begin(), + gaussianMixture->parents().end()); // Create the new gaussian mixture and add it to the bayes net. auto prunedGaussianMixture = boost::make_shared(