remove method to set factor to NULL

release/4.3a0
Frank Dellaert 2009-12-20 21:21:01 +00:00
parent 3158a5c7c1
commit d0b757da48
2 changed files with 9 additions and 6 deletions

View File

@ -245,7 +245,7 @@ FactorGraph<Factor>::findAndRemoveFactors(const string& key) {
BOOST_FOREACH(int i, *indices_ptr) { BOOST_FOREACH(int i, *indices_ptr) {
if(factors_[i] == NULL) continue; // skip NULL factors if(factors_[i] == NULL) continue; // skip NULL factors
found.push_back(factors_[i]); // add to found found.push_back(factors_[i]); // add to found
factors_[i].reset(); // set factor to NULL. remove(i); // set factor to NULL.
} }
return found; return found;
} }

View File

@ -67,11 +67,14 @@ namespace gtsam {
/** Get a specific factor by index */ /** Get a specific factor by index */
inline sharedFactor operator[](size_t i) const {return factors_[i];} inline sharedFactor operator[](size_t i) const {return factors_[i];}
/** delete factor without re-arranging indexes by inserting a NULL pointer */
inline void remove(size_t i) { factors_[i].reset();}
/** return the number of factors and NULLS */ /** return the number of factors and NULLS */
inline size_t size() const { return factors_.size();} inline size_t size() const { return factors_.size();}
/** return the number valid factors */ /** return the number valid factors */
size_t nrFactors() const; size_t nrFactors() const;
/** Add a factor */ /** Add a factor */
void push_back(sharedFactor factor); void push_back(sharedFactor factor);
@ -95,9 +98,9 @@ namespace gtsam {
*/ */
Ordering getOrdering() const; Ordering getOrdering() const;
/** /**
* shared pointer versions for MATLAB * shared pointer versions for MATLAB
*/ */
boost::shared_ptr<Ordering> getOrdering_() const; boost::shared_ptr<Ordering> getOrdering_() const;
/** /**