From 327b4bf823a8077930bdc9bf4ae7903087ee06ba Mon Sep 17 00:00:00 2001 From: Morgan Deters Date: Wed, 7 Jul 2010 05:39:04 +0000 Subject: [PATCH] minor changes to cdmap/cdset interface for detection of duplicate inserts --- src/context/cdmap.h | 4 +++- src/context/cdset.h | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/context/cdmap.h b/src/context/cdmap.h index 45ff68a23..5e5a07f2f 100644 --- a/src/context/cdmap.h +++ b/src/context/cdmap.h @@ -363,7 +363,7 @@ public: return *obj; } - void insert(const Key& k, const Data& d) { + bool insert(const Key& k, const Data& d) { emptyTrash(); typename table_type::iterator i = d_map.find(k); @@ -371,8 +371,10 @@ public: if(i == d_map.end()) {// create new object Element* obj = new(true) Element(d_context, this, k, d); d_map[k] = obj; + return true; } else { (*i).second->set(d); + return false; } } diff --git a/src/context/cdset.h b/src/context/cdset.h index 40d504cad..7032f76ba 100644 --- a/src/context/cdset.h +++ b/src/context/cdset.h @@ -22,6 +22,7 @@ #define __CVC4__CONTEXT__CDSET_H #include "context/context.h" +#include "context/cdmap.h" #include "util/Assert.h" namespace CVC4 { @@ -45,8 +46,12 @@ public: return super::count(v); } - void insert(const V& v) { - super::insert(v, v); + bool insert(const V& v) { + return super::insert(v, v); + } + + bool contains(const V& v) { + return find(v) != end(); } // FIXME: no erase(), too much hassle to implement efficiently... -- 2.30.2