avi123
March 28th, 2004, 02:56 AM
Hi,
I have a std::hash_map
every item is dynamically allocated
and I want to delete an item in the hash map
so what I do is this:
/////////////////////////////////////////////////////////////////////
hash_map <int, myStruct*>::const_iterator it;
//search for the item to delete
it = m_MyTable.find(nKey);
if(it != m_MyTable.end()) //found
delete it->second;
////////////////////////////////////////////////////////////////////////
so I free the allocate item with the delete
my question is:
does my hash_map (m_MyTable) is know with 1 less entry
or that the enrty is not deleted and just its data part was deleted?
if this is the case, how do I delete the entry?
Thanks
avi
p.S should I use erase after the delete statment?
I have a std::hash_map
every item is dynamically allocated
and I want to delete an item in the hash map
so what I do is this:
/////////////////////////////////////////////////////////////////////
hash_map <int, myStruct*>::const_iterator it;
//search for the item to delete
it = m_MyTable.find(nKey);
if(it != m_MyTable.end()) //found
delete it->second;
////////////////////////////////////////////////////////////////////////
so I free the allocate item with the delete
my question is:
does my hash_map (m_MyTable) is know with 1 less entry
or that the enrty is not deleted and just its data part was deleted?
if this is the case, how do I delete the entry?
Thanks
avi
p.S should I use erase after the delete statment?