aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-01 19:50:49 +0000
committerChris Lattner <sabre@nondot.org>2009-04-01 19:50:49 +0000
commitdd255a62474a2016702e2985710e6e8910b3c974 (patch)
treeac701c970d3d27d312d63081c189480b2321ac09
parent9f777c64c51f45a5e0a6773d99a4fd031076db56 (diff)
Add range insert method for DenseSet and define DenseMapInfo for chars.
Patch by Kevin Fan! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68239 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ADT/DenseMap.h11
-rw-r--r--include/llvm/ADT/DenseSet.h7
2 files changed, 18 insertions, 0 deletions
diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h
index ce0c006cf2..cb951815f8 100644
--- a/include/llvm/ADT/DenseMap.h
+++ b/include/llvm/ADT/DenseMap.h
@@ -51,6 +51,17 @@ struct DenseMapInfo<T*> {
static bool isPod() { return true; }
};
+// Provide DenseMapInfo for chars.
+template<> struct DenseMapInfo<char> {
+ static inline char getEmptyKey() { return ~0; }
+ static inline char getTombstoneKey() { return ~0 - 1; }
+ static unsigned getHashValue(const char& Val) { return Val * 37; }
+ static bool isPod() { return true; }
+ static bool isEqual(const char &LHS, const char &RHS) {
+ return LHS == RHS;
+ }
+};
+
// Provide DenseMapInfo for unsigned ints.
template<> struct DenseMapInfo<unsigned> {
static inline unsigned getEmptyKey() { return ~0; }
diff --git a/include/llvm/ADT/DenseSet.h b/include/llvm/ADT/DenseSet.h
index 953c67d53e..ce7344bc1f 100644
--- a/include/llvm/ADT/DenseSet.h
+++ b/include/llvm/ADT/DenseSet.h
@@ -90,6 +90,13 @@ public:
std::pair<iterator, bool> insert(const ValueT &V) {
return TheMap.insert(std::make_pair(V, 0));
}
+
+ // Range insertion of values.
+ template<typename InputIt>
+ void insert(InputIt I, InputIt E) {
+ for (; I != E; ++I)
+ insert(*I);
+ }
};
} // end namespace llvm