Add DenseMapInfo for int.
authorEvan Cheng <evan.cheng@apple.com>
Thu, 29 Apr 2010 18:50:35 +0000 (18:50 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 29 Apr 2010 18:50:35 +0000 (18:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102652 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/DenseMapInfo.h

index 41197a1e12df951d5938060d0088b9298190fdae..529938699270d1decc88db3bd5f8c3cedf34af37 100644 (file)
@@ -92,6 +92,16 @@ template<> struct DenseMapInfo<unsigned long long> {
   }
 };
 
+// Provide DenseMapInfo for ints.
+template<> struct DenseMapInfo<int> {
+  static inline int getEmptyKey() { return 0x7fffffff; }
+  static inline int getTombstoneKey() { return -0x7fffffff - 1; }
+  static unsigned getHashValue(const int& Val) { return (unsigned)(Val * 37); }
+  static bool isEqual(const int& LHS, const int& RHS) {
+    return LHS == RHS;
+  }
+};
+
 // Provide DenseMapInfo for long longs.
 template<> struct DenseMapInfo<long long> {
   static inline long long getEmptyKey() { return 0x7fffffffffffffffLL; }