A C++ STL question# Programming - 葵花宝典
T*r
1 楼
Supposedly I want to delete multiple entries in a STL hash map. The code
looks like the following:
for (it = hash_table.begin(); it != hash_table.end(); it ++)
{
if (some_condition)
hash_table.erase (it);
}
My questions is, after erasing an entry referenced by 'it', will 'it' still
be valid such that you can use 'it++' to find the next entry in the hash map
? Or will 'it' automatically points to the next entry in the hash map
because the total number of entries already reduced by one
looks like the following:
for (it = hash_table.begin(); it != hash_table.end(); it ++)
{
if (some_condition)
hash_table.erase (it);
}
My questions is, after erasing an entry referenced by 'it', will 'it' still
be valid such that you can use 'it++' to find the next entry in the hash map
? Or will 'it' automatically points to the next entry in the hash map
because the total number of entries already reduced by one