From 16c28b2e9c6c6f2b043040a225563adec59fb339 Mon Sep 17 00:00:00 2001 From: dellaert Date: Sat, 31 May 2014 16:31:48 -0400 Subject: [PATCH] Formatting only --- gtsam/inference/VariableIndex-inl.h | 60 ++++++++++++++--------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/gtsam/inference/VariableIndex-inl.h b/gtsam/inference/VariableIndex-inl.h index a88ea5d57..82eb85c76 100644 --- a/gtsam/inference/VariableIndex-inl.h +++ b/gtsam/inference/VariableIndex-inl.h @@ -23,43 +23,35 @@ namespace gtsam { /* ************************************************************************* */ template -void VariableIndex::augment(const FG& factors, boost::optional&> newFactorIndices) -{ +void VariableIndex::augment(const FG& factors, + boost::optional&> newFactorIndices) { gttic(VariableIndex_augment); // Augment index for each factor - for(size_t i = 0; i < factors.size(); ++i) - { - if(factors[i]) - { + for (size_t i = 0; i < factors.size(); ++i) { + if (factors[i]) { const size_t globalI = - newFactorIndices ? - (*newFactorIndices)[i] : - nFactors_; - BOOST_FOREACH(const Key key, *factors[i]) - { + newFactorIndices ? (*newFactorIndices)[i] : nFactors_; + BOOST_FOREACH(const Key key, *factors[i]) { index_[key].push_back(globalI); - ++ nEntries_; + ++nEntries_; } } // Increment factor count even if factors are null, to keep indices consistent - if(newFactorIndices) - { - if((*newFactorIndices)[i] >= nFactors_) + if (newFactorIndices) { + if ((*newFactorIndices)[i] >= nFactors_) nFactors_ = (*newFactorIndices)[i] + 1; - } - else - { - ++ nFactors_; + } else { + ++nFactors_; } } } /* ************************************************************************* */ template -void VariableIndex::remove(ITERATOR firstFactor, ITERATOR lastFactor, const FG& factors) -{ +void VariableIndex::remove(ITERATOR firstFactor, ITERATOR lastFactor, + const FG& factors) { gttic(VariableIndex_remove); // NOTE: We intentionally do not decrement nFactors_ because the factor @@ -68,17 +60,20 @@ void VariableIndex::remove(ITERATOR firstFactor, ITERATOR lastFactor, const FG& // one greater than the highest-numbered factor referenced in a VariableIndex. ITERATOR factorIndex = firstFactor; size_t i = 0; - for( ; factorIndex != lastFactor; ++factorIndex, ++i) { - if(i >= factors.size()) - throw std::invalid_argument("Internal error, requested inconsistent number of factor indices and factors in VariableIndex::remove"); - if(factors[i]) { + for (; factorIndex != lastFactor; ++factorIndex, ++i) { + if (i >= factors.size()) + throw std::invalid_argument( + "Internal error, requested inconsistent number of factor indices and factors in VariableIndex::remove"); + if (factors[i]) { BOOST_FOREACH(Key j, *factors[i]) { Factors& factorEntries = internalAt(j); - Factors::iterator entry = std::find(factorEntries.begin(), factorEntries.end(), *factorIndex); - if(entry == factorEntries.end()) - throw std::invalid_argument("Internal error, indices and factors passed into VariableIndex::remove are not consistent with the existing variable index"); + Factors::iterator entry = std::find(factorEntries.begin(), + factorEntries.end(), *factorIndex); + if (entry == factorEntries.end()) + throw std::invalid_argument( + "Internal error, indices and factors passed into VariableIndex::remove are not consistent with the existing variable index"); factorEntries.erase(entry); - -- nEntries_; + --nEntries_; } } } @@ -87,10 +82,11 @@ void VariableIndex::remove(ITERATOR firstFactor, ITERATOR lastFactor, const FG& /* ************************************************************************* */ template void VariableIndex::removeUnusedVariables(ITERATOR firstKey, ITERATOR lastKey) { - for(ITERATOR key = firstKey; key != lastKey; ++key) { + for (ITERATOR key = firstKey; key != lastKey; ++key) { KeyMap::iterator entry = index_.find(*key); - if(!entry->second.empty()) - throw std::invalid_argument("Asking to remove variables from the variable index that are not unused"); + if (!entry->second.empty()) + throw std::invalid_argument( + "Asking to remove variables from the variable index that are not unused"); index_.erase(entry); } }