Wrap VariableIndex.at(), .empty()
parent
198efe23c7
commit
098704ac22
|
@ -23,6 +23,24 @@ namespace gtsam {
|
|||
|
||||
using namespace std;
|
||||
|
||||
const FactorIndices& operator[](Key variable) const {
|
||||
KeyMap::const_iterator item = index_.find(variable);
|
||||
}
|
||||
|
||||
const FactorIndices& at(Key variable) const {
|
||||
KeyMap::const_iterator item = (*this)[variable];
|
||||
if(item == index_.end())
|
||||
throw std::invalid_argument("Requested non-existent variable '" +
|
||||
DefaultKeyFormatter(variable) +
|
||||
"' from VariableIndex");
|
||||
else
|
||||
return item->second;
|
||||
}
|
||||
|
||||
bool empty(Key variable) const {
|
||||
return (*this)[variable].empty();
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
bool VariableIndex::equals(const VariableIndex& other, double tol) const {
|
||||
return this->nEntries_ == other.nEntries_ && this->nFactors_ == other.nFactors_
|
||||
|
|
|
@ -84,20 +84,12 @@ class GTSAM_EXPORT VariableIndex {
|
|||
size_t nEntries() const { return nEntries_; }
|
||||
|
||||
/// Access a list of factors by variable
|
||||
const FactorIndices& operator[](Key variable) const {
|
||||
KeyMap::const_iterator item = index_.find(variable);
|
||||
if(item == index_.end())
|
||||
throw std::invalid_argument("Requested non-existent variable '" +
|
||||
DefaultKeyFormatter(variable) +
|
||||
"' from VariableIndex");
|
||||
else
|
||||
return item->second;
|
||||
}
|
||||
const FactorIndices& operator[](Key variable) const;
|
||||
|
||||
const FactorIndices& at(Key variable) const;
|
||||
|
||||
/// Return true if no factors associated with a variable
|
||||
bool empty(Key variable) const {
|
||||
return (*this)[variable].empty();
|
||||
}
|
||||
bool empty(Key variable) const;
|
||||
|
||||
/// @}
|
||||
/// @name Testable
|
||||
|
|
|
@ -199,6 +199,9 @@ class VariableIndex {
|
|||
VariableIndex(const T& factorGraph);
|
||||
VariableIndex(const gtsam::VariableIndex& other);
|
||||
|
||||
const FactorIndices& at(Key variable) const;
|
||||
bool empty(Key variable) const;
|
||||
|
||||
// Testable
|
||||
bool equals(const gtsam::VariableIndex& other, double tol) const;
|
||||
void print(string s = "VariableIndex: ",
|
||||
|
|
Loading…
Reference in New Issue