diff --git a/gtsam/discrete/DiscreteValues.h b/gtsam/discrete/DiscreteValues.h index 7c73da681..0644e0c16 100644 --- a/gtsam/discrete/DiscreteValues.h +++ b/gtsam/discrete/DiscreteValues.h @@ -101,6 +101,14 @@ class GTSAM_EXPORT DiscreteValues : public Assignment { */ DiscreteValues& update(const DiscreteValues& values); + /** + * @brief Check if the DiscreteValues contains the given key. + * + * @param key The key to check for. + * @return True if the key is present, false otherwise. + */ + bool contains(Key key) const { return this->find(key) != this->end(); } + /** * @brief Filter values by keys. *