From 982e248f3111d39f5b56dd7a59e2a59eed57f242 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Tue, 24 Jan 2012 04:20:04 +0000 Subject: [PATCH] Made a group about modifying graphs. --- gtsam/inference/FactorGraph.h | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/gtsam/inference/FactorGraph.h b/gtsam/inference/FactorGraph.h index a73506f3a..458588b7b 100644 --- a/gtsam/inference/FactorGraph.h +++ b/gtsam/inference/FactorGraph.h @@ -145,6 +145,12 @@ template class BayesTree; const sharedFactor operator[](size_t i) const { assert(i class BayesTree; sharedFactor back() const { return factors_.back(); } /// @} - /// @name Advanced Interface + /// @name Modifying Factor Graphs (imperative, discouraged) /// @{ - /** return the number valid factors */ - size_t nrFactors() const; - - /** STL begin and end, so we can use BOOST_FOREACH */ - const_iterator begin() const { return factors_.begin();} - const_iterator end() const { return factors_.end(); } - - /** ----------------- Modifying Factor Graphs ---------------------------- */ - - /** STL begin and end, so we can use BOOST_FOREACH */ + /** non-const STL-style begin() */ iterator begin() { return factors_.begin();} + + /** non-const STL-style end() */ iterator end() { return factors_.end(); } - /** - * resize the factor graph - */ + /** resize the factor graph. TODO: effects? */ void resize(size_t size) { factors_.resize(size); } /** delete factor without re-arranging indexes by inserting a NULL pointer */ @@ -179,6 +176,13 @@ template class BayesTree; /** replace a factor by index */ void replace(size_t index, sharedFactor factor); + /// @} + /// @name Advanced Interface + /// @{ + + /** return the number valid factors */ + size_t nrFactors() const; + /** dynamic_cast the factor pointers down or up the class hierarchy */ template typename RELATED::shared_ptr dynamicCastFactors() const {