diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-12-19 11:08:33 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-12-19 11:08:33 +0000 |
commit | fc8657be3470e5b3b63705c9252251acba3c1606 (patch) | |
tree | 9fa0e29dfa3ea89367df6a7290efa9b13cf94e7b /include | |
parent | fdbeb057b8a844b641f323fd27a61ffcb32b43da (diff) |
MapVector: Add lookup().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170527 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/MapVector.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/llvm/ADT/MapVector.h b/include/llvm/ADT/MapVector.h index 42f8e553d4..c34e32a480 100644 --- a/include/llvm/ADT/MapVector.h +++ b/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; |