From: Daniel Dunbar Date: Fri, 29 Aug 2008 00:48:44 +0000 (+0000) Subject: Add DenseMap::lookup: X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7b75fbf224c0a2d181c35708a27c514ae798c904;p=oota-llvm.git Add DenseMap::lookup: /// 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 --- diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h index df8f464adaf..70d09a6617d 100644 --- a/include/llvm/ADT/DenseMap.h +++ b/include/llvm/ADT/DenseMap.h @@ -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 insert(const std::pair &KV) { BucketT *TheBucket; if (LookupBucketFor(KV.first, TheBucket))