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) {
if(factors_[i] == NULL) continue; // skip NULL factors
found.push_back(factors_[i]); // add to found
factors_[i].reset(); // set factor to NULL.
remove(i); // set factor to NULL.
}
return found;
}

View File

@ -67,6 +67,9 @@ namespace gtsam {
/** Get a specific factor by index */
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 */
inline size_t size() const { return factors_.size();}