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 | 55d1966e9afdeeb33e7611bc0ac9b4b4268d68d3 (patch) | |
tree | b8faef7c8acf95d5347e03581556fa77218d78a8 /include/llvm/ADT | |
parent | c315d58dcbdea638a42c5f939001c20b75b72b81 (diff) | |
download | external_llvm-55d1966e9afdeeb33e7611bc0ac9b4b4268d68d3.tar.gz external_llvm-55d1966e9afdeeb33e7611bc0ac9b4b4268d68d3.tar.bz2 external_llvm-55d1966e9afdeeb33e7611bc0ac9b4b4268d68d3.zip |
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/llvm/ADT')
-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 fd9edd240f..e584973e4f 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 06d0fa8e0d..eb93e6c5fe 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 |