map遍历删除
1 map<int, vector<int>>::iterator it = g_map.begin(); 2 for (; it != g_map.end(); /*it++*/) 3 { 4 g_map.erase(it++); 5 }
vector遍历删除
1 vector<int>::iterator iter = vec.begin(); 2 while (iter != vec.end()) 3 { 4 if(*iter == 1) 5 { 6 iter = vec.earse(iter); 7 } 8 else 9 { 10 ++iter; 11 } 12 }
时间: 2024-10-17 11:52:36