From: Dan Gohman Date: Mon, 23 Jun 2008 21:07:03 +0000 (+0000) Subject: Add methods to StringMap to erase entries by key. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=84701836bfb1889e2e26e361ebd5d29d972ab396;p=oota-llvm.git Add methods to StringMap to erase entries by key. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52640 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index 869a87fdced..0a4a5d631d9 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -377,6 +377,20 @@ public: V.Destroy(Allocator); } + bool erase(const char *Key) { + iterator I = find(Key); + if (I == end()) return false; + erase(I); + return true; + } + + bool erase(std::string Key) { + iterator I = find(Key); + if (I == end()) return false; + erase(I); + return true; + } + ~StringMap() { for (ItemBucket *I = TheTable, *E = TheTable+NumBuckets; I != E; ++I) { if (I->Item && I->Item != getTombstoneVal())