From e42dc5cdc978ea2a386a21af5807106cbf18b7b1 Mon Sep 17 00:00:00 2001 From: Abhijit Kundu Date: Fri, 22 Jun 2012 19:51:08 +0000 Subject: [PATCH] Minor updates: cachedShortcut is now protected. DeleteCachedShortcuts() are now called on the resulting orphans in the removeTop() instead of the whole tree. --- gtsam/inference/BayesTree-inl.h | 8 +++++--- gtsam/inference/BayesTreeCliqueBase.h | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) 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 */