This commit is contained in:
Jidong Xiao
2025-03-11 00:57:42 -04:00
committed by JamesFlare1212
parent 95d9bb50ca
commit 890d4d2be8
2 changed files with 0 additions and 40 deletions

View File

@@ -1,20 +0,0 @@
#include <iostream>
#include <map>
int main() {
const int N = 1000000;
std::map<int, int> m;
// fill the map with some values
for (int i = 0; i < N; ++i) {
m[i] = i;
}
// erase all elements using iterators
for (std::map<int, int>::iterator itr = m.begin(); itr != m.end(); ) {
itr = m.erase(itr); // erase using iterator and move to the next element
}
return 0;
}

View File

@@ -1,20 +0,0 @@
#include <iostream>
#include <map>
int main() {
const int N = 1000000;
std::map<int, int> m;
// fill the map with some values
for (int i = 0; i < N; ++i) {
m[i] = i;
}
// erase by key
for (int i = 0; i < N; ++i) {
m.erase(i);
}
return 0;
}