diff --git a/gtsam/inference/BayesTree-inl.h b/gtsam/inference/BayesTree-inl.h index dfefd721e..5cb2c34a9 100644 --- a/gtsam/inference/BayesTree-inl.h +++ b/gtsam/inference/BayesTree-inl.h @@ -575,9 +575,6 @@ namespace gtsam { void BayesTree::removeTop(const CONTAINER& keys, BayesNet& bn, typename BayesTree::Cliques& orphans) { - //TODO: Improve this - deleteCachedShorcuts(this->root_); - // process each key of the new factor BOOST_FOREACH(const Index& key, keys) { @@ -590,6 +587,11 @@ namespace gtsam { } } } + + // Delete cachedShorcuts for each orphan subtree + //TODO: Consider Improving + BOOST_FOREACH(sharedClique& orphan, orphans) + deleteCachedShorcuts(orphan); } /* ************************************************************************* */ diff --git a/gtsam/inference/BayesTreeCliqueBase.h b/gtsam/inference/BayesTreeCliqueBase.h index fa0992fbd..675215904 100644 --- a/gtsam/inference/BayesTreeCliqueBase.h +++ b/gtsam/inference/BayesTreeCliqueBase.h @@ -75,14 +75,14 @@ namespace gtsam { /// @} + /// This stores the Cached Shortcut value + mutable boost::optional > cachedShortcut_; + public: sharedConditional conditional_; derived_weak_ptr parent_; std::list children_; - /// This stores the Cached Shortcut value - mutable boost::optional > cachedShortcut_; - /// @name Testable /// @{ @@ -114,7 +114,7 @@ namespace gtsam { /** The arrow operator accesses the conditional */ const ConditionalType* operator->() const { return conditional_.get(); } - ///TODO: comment + /** return the const reference of children */ const std::list& children() const { return children_; } /// @} @@ -124,7 +124,7 @@ namespace gtsam { /** The arrow operator accesses the conditional */ ConditionalType* operator->() { return conditional_.get(); } - /** return the const reference of children */ + /** return the reference of children non-const version*/ std::list& children() { return children_; } /** Construct shared_ptr from a conditional, leaving parent and child pointers uninitialized */