diff --git a/gtsam/nonlinear/Values.h b/gtsam/nonlinear/Values.h index 7d26fb4c0..293190b9a 100644 --- a/gtsam/nonlinear/Values.h +++ b/gtsam/nonlinear/Values.h @@ -188,6 +188,14 @@ namespace gtsam { template boost::optional exists(Key j) const; + /** Find an element by key, returning an iterator, or end() if the key was + * not found. */ + iterator find(Key j) { return boost::make_transform_iterator(values_.find(j), &make_deref_pair); } + + /** Find an element by key, returning an iterator, or end() if the key was + * not found. */ + const_iterator find(Key j) const { return boost::make_transform_iterator(values_.find(j), &make_const_deref_pair); } + /** The number of variables in this config */ size_t size() const { return values_.size(); }