findAndRemovefactors throws no more exception if key not found

release/4.3a0
Frank Dellaert 2010-07-15 01:41:01 +00:00
parent b5c0f3cee8
commit 65661d20ad
1 changed files with 4 additions and 6 deletions

View File

@ -430,18 +430,16 @@ namespace gtsam {
// find all factor indices associated with the key
Indices::const_iterator it = indices_.find(key);
if (it == indices_.end()) throw std::invalid_argument(
"FactorGraph::findAndRemoveFactors: key " + (string) key + " not found");
const list<size_t>& factorsAssociatedWithKey = it->second;
vector<sharedFactor> found;
BOOST_FOREACH(const size_t& i, factorsAssociatedWithKey) {
if (it != indices_.end()) {
const list<size_t>& factorsAssociatedWithKey = it->second;
BOOST_FOREACH(const size_t& i, factorsAssociatedWithKey) {
sharedFactor& fi = factors_.at(i); // throws exception !
if (fi == NULL) continue; // skip NULL factors
found.push_back(fi); // add to found
fi.reset(); // set factor to NULL == remove(i)
}
}
indices_.erase(key);
return found;