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