diff options
author | Dan Gohman <gohman@apple.com> | 2008-07-07 17:46:23 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-07-07 17:46:23 +0000 |
commit | 6b345ee9b2833cf1b2f79dc16d06d4060bec36ef (patch) | |
tree | b8faef7c8acf95d5347e03581556fa77218d78a8 /include | |
parent | aa5044d3ce80a2759a6084911db77dec385a47fc (diff) | |
download | external_llvm-6b345ee9b2833cf1b2f79dc16d06d4060bec36ef.zip external_llvm-6b345ee9b2833cf1b2f79dc16d06d4060bec36ef.tar.gz external_llvm-6b345ee9b2833cf1b2f79dc16d06d4060bec36ef.tar.bz2 |
Make DenseMap's insert return a pair, to more closely resemble std::map.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53177 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/DenseMap.h | 10 | ||||
-rw-r--r-- | include/llvm/ADT/DenseSet.h | 8 |
2 files changed, 10 insertions, 8 deletions
diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h index fd9edd2..e584973 100644 --- a/include/llvm/ADT/DenseMap.h +++ b/include/llvm/ADT/DenseMap.h @@ -147,14 +147,16 @@ public: return end(); } - bool insert(const std::pair<KeyT, ValueT> &KV) { + std::pair<iterator, bool> insert(const std::pair<KeyT, ValueT> &KV) { BucketT *TheBucket; if (LookupBucketFor(KV.first, TheBucket)) - return false; // Already in map. + return std::make_pair(iterator(TheBucket, Buckets+NumBuckets), + false); // Already in map. // Otherwise, insert the new element. - InsertIntoBucket(KV.first, KV.second, TheBucket); - return true; + TheBucket = InsertIntoBucket(KV.first, KV.second, TheBucket); + return std::make_pair(iterator(TheBucket, Buckets+NumBuckets), + true); } bool erase(const KeyT &Val) { diff --git a/include/llvm/ADT/DenseSet.h b/include/llvm/ADT/DenseSet.h index 06d0fa8..eb93e6c 100644 --- a/include/llvm/ADT/DenseSet.h +++ b/include/llvm/ADT/DenseSet.h @@ -41,10 +41,6 @@ public: return TheMap.count(V); } - bool insert(const ValueT &V) { - return TheMap.insert(std::make_pair(V, 0)); - } - void erase(const ValueT &V) { TheMap.erase(V); } @@ -90,6 +86,10 @@ public: const_iterator begin() const { return ConstIterator(TheMap.begin()); } const_iterator end() const { return ConstIterator(TheMap.end()); } + + std::pair<iterator, bool> insert(const ValueT &V) { + return TheMap.insert(std::make_pair(V, 0)); + } }; } // end namespace llvm |