Add methods to StringMap to erase entries by key.
authorDan Gohman <gohman@apple.com>
Mon, 23 Jun 2008 21:07:03 +0000 (21:07 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 23 Jun 2008 21:07:03 +0000 (21:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52640 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringMap.h

index 869a87fdced331b0be84ea6b353dfe211cd46f48..0a4a5d631d9c55df99e10d12b5f51eeff4348fc3 100644 (file)
@@ -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())