[llvm-commits] [llvm] r66750 - /llvm/trunk/include/llvm/ADT/StringMap.h
Daniel Dunbar
daniel at zuster.org
Wed Mar 11 18:16:06 PDT 2009
Author: ddunbar
Date: Wed Mar 11 20:16:06 2009
New Revision: 66750
URL: http://llvm.org/viewvc/llvm-project?rev=66750&view=rev
Log:
Add StringMap::lookup.
Modified:
llvm/trunk/include/llvm/ADT/StringMap.h
Modified: llvm/trunk/include/llvm/ADT/StringMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=66750&r1=66749&r2=66750&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)
+++ llvm/trunk/include/llvm/ADT/StringMap.h Wed Mar 11 20:16:06 2009
@@ -303,6 +303,27 @@
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();
}
More information about the llvm-commits
mailing list