summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/StringMap.h
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-03-12 01:16:06 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-03-12 01:16:06 +0000
commite889d837a4d226280525b1eafe5a6317c594ebf3 (patch)
tree5045eff86eaac953746afedc9d71cdfa6e356234 /include/llvm/ADT/StringMap.h
parenta9537cf3fcf9fdaac94749db9fbd34912b1f0f08 (diff)
downloadllvm-e889d837a4d226280525b1eafe5a6317c594ebf3.tar.gz
llvm-e889d837a4d226280525b1eafe5a6317c594ebf3.tar.bz2
llvm-e889d837a4d226280525b1eafe5a6317c594ebf3.tar.xz
Add StringMap::lookup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66750 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/StringMap.h')
-rw-r--r--include/llvm/ADT/StringMap.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h
index 08418ee3c1..f5394750f2 100644
--- a/include/llvm/ADT/StringMap.h
+++ b/include/llvm/ADT/StringMap.h
@@ -303,6 +303,27 @@ public:
return find(key_start, key_start + Key.size());
}
+ /// lookup - Return the entry for the specified key, or a default
+ /// constructed value if no such entry exists.
+ ValueTy lookup(const char *KeyStart, const char *KeyEnd) const {
+ const_iterator it = find(KeyStart, KeyEnd);
+ if (it != end())
+ return it->second;
+ return ValueTy();
+ }
+ ValueTy lookup(const char *Key) const {
+ const_iterator it = find(Key);
+ if (it != end())
+ return it->second;
+ return ValueTy();
+ }
+ ValueTy lookup(const std::string &Key) const {
+ const_iterator it = find(Key);
+ if (it != end())
+ return it->second;
+ return ValueTy();
+ }
+
ValueTy& operator[](const char *Key) {
return GetOrCreateValue(Key, Key + strlen(Key)).getValue();
}