[llvm-commits] [llvm] r68239 - in /llvm/trunk/include/llvm/ADT: DenseMap.h DenseSet.h

Chris Lattner sabre at nondot.org
Wed Apr 1 12:50:49 PDT 2009


Author: lattner
Date: Wed Apr  1 14:50:49 2009
New Revision: 68239

URL: http://llvm.org/viewvc/llvm-project?rev=68239&view=rev
Log:
Add range insert method for DenseSet and define DenseMapInfo for chars.
Patch by Kevin Fan!


Modified:
    llvm/trunk/include/llvm/ADT/DenseMap.h
    llvm/trunk/include/llvm/ADT/DenseSet.h

Modified: llvm/trunk/include/llvm/ADT/DenseMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=68239&r1=68238&r2=68239&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseMap.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseMap.h Wed Apr  1 14:50:49 2009
@@ -51,6 +51,17 @@
   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; }

Modified: llvm/trunk/include/llvm/ADT/DenseSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseSet.h?rev=68239&r1=68238&r2=68239&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseSet.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseSet.h Wed Apr  1 14:50:49 2009
@@ -90,6 +90,13 @@
   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





More information about the llvm-commits mailing list