Add DenseMap::lookup:
authorDaniel Dunbar <daniel@zuster.org>
Fri, 29 Aug 2008 00:48:44 +0000 (00:48 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 29 Aug 2008 00:48:44 +0000 (00:48 +0000)
  /// lookup - Return the entry for the specified key, or a default
  /// constructed value if no such entry exists.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55523 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/DenseMap.h

index df8f464adafd5b968bc1e9aec5142256402c4256..70d09a6617d78fa2e3da2029e32658903fad913c 100644 (file)
@@ -189,6 +189,15 @@ public:
     return end();
   }
   
+  /// lookup - Return the entry for the specified key, or a default
+  /// constructed value if no such entry exists.
+  ValueT lookup(const KeyT &Val) const {
+    BucketT *TheBucket;
+    if (LookupBucketFor(Val, TheBucket))
+      return TheBucket->second;
+    return ValueT();
+  }
+
   std::pair<iterator, bool> insert(const std::pair<KeyT, ValueT> &KV) {
     BucketT *TheBucket;
     if (LookupBucketFor(KV.first, TheBucket))