From 44ba3753ad49330daf5c6f60ef35cafa5bffbf84 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 19 Dec 2012 11:08:33 +0000 Subject: [PATCH] MapVector: Add lookup(). llvm-svn: 170527 --- llvm/include/llvm/ADT/MapVector.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llvm/include/llvm/ADT/MapVector.h b/llvm/include/llvm/ADT/MapVector.h index 42f8e55..c34e32a 100644 --- a/llvm/include/llvm/ADT/MapVector.h +++ b/llvm/include/llvm/ADT/MapVector.h @@ -79,6 +79,11 @@ public: return Vector[I].second; } + ValueT lookup(const KeyT &Key) const { + typename MapType::const_iterator Pos = Map.find(Key); + return Pos == Map.end()? ValueT() : Vector[Pos->second].second; + } + unsigned count(const KeyT &Key) const { typename MapType::const_iterator Pos = Map.find(Key); return Pos == Map.end()? 0 : 1; -- 2.7.4