From 91f9f849edd9a02eda61bbef57ffb0efe7bf5d71 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Fri, 8 Mar 2013 19:33:25 +0000 Subject: [PATCH] Added find functions to Values --- gtsam/nonlinear/Values.h | 8 ++++++++ 1 file changed, 8 insertions(+) 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(); }