aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-07-07 17:46:23 +0000
committerDan Gohman <gohman@apple.com>2008-07-07 17:46:23 +0000
commit6b345ee9b2833cf1b2f79dc16d06d4060bec36ef (patch)
treeb8faef7c8acf95d5347e03581556fa77218d78a8 /include
parentaa5044d3ce80a2759a6084911db77dec385a47fc (diff)
downloadexternal_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.h10
-rw-r--r--include/llvm/ADT/DenseSet.h8
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