From 5b15b11261ce81eae6d3dc6cfd7f2de250fc1006 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Thu, 8 Aug 2013 21:41:23 +0000 Subject: [PATCH] Added FastSet/Map exists function --- gtsam/base/FastMap.h | 3 +++ gtsam/base/FastSet.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/gtsam/base/FastMap.h b/gtsam/base/FastMap.h index 7cea45e88..656eb74fd 100644 --- a/gtsam/base/FastMap.h +++ b/gtsam/base/FastMap.h @@ -58,6 +58,9 @@ public: return std::map(this->begin(), this->end()); } + /** Handy 'exists' function */ + bool exists(const KEY& e) const { return find(e) != end(); } + private: /** Serialization function */ friend class boost::serialization::access; diff --git a/gtsam/base/FastSet.h b/gtsam/base/FastSet.h index be2864f8f..fe4cc2c80 100644 --- a/gtsam/base/FastSet.h +++ b/gtsam/base/FastSet.h @@ -91,6 +91,9 @@ public: return std::set(this->begin(), this->end()); } + /** Handy 'exists' function */ + bool exists(const VALUE& e) const { return find(e) != end(); } + /** Print to implement Testable */ void print(const std::string& str = "") const { FastSetTestableHelper::print(*this, str); }