Added exists() as a utility for matlab to check whether a pointer is live

release/4.3a0
Alex Cunningham 2013-08-23 20:06:08 +00:00
parent e6d5c2bf73
commit 5fe46f9bad
2 changed files with 6 additions and 0 deletions

View File

@ -829,6 +829,7 @@ class SymbolicFactorGraph {
void print(string s) const;
bool equals(const gtsam::SymbolicFactorGraph& rhs, double tol) const;
size_t size() const;
bool exists(size_t idx) const;
// Standard interface
gtsam::KeySet keys() const;
@ -1246,6 +1247,7 @@ class GaussianFactorGraph {
size_t size() const;
gtsam::GaussianFactor* at(size_t idx) const;
gtsam::KeySet keys() const;
bool exists(size_t idx) const;
// Building the graph
void push_back(gtsam::GaussianFactor* factor);
@ -1520,6 +1522,7 @@ class NonlinearFactorGraph {
gtsam::NonlinearFactor* at(size_t idx) const;
void push_back(const gtsam::NonlinearFactorGraph& factors);
void push_back(gtsam::NonlinearFactor* factor);
bool exists(size_t idx) const;
// NonlinearFactorGraph
double error(const gtsam::Values& values) const;

View File

@ -352,6 +352,9 @@ namespace gtsam {
/** Potentially very slow function to return all keys involved */
FastSet<Key> keys() const;
/** MATLAB interface utility: Checks whether a factor index idx exists in the graph and is a live pointer */
inline bool exists(size_t idx) const { return idx < size() && at(idx); }
private:
/** Serialization function */