Original Post
Assume I have the following container: What would be more efficient? Erasing each node after I deleted it or removing them all at the end? Thanks a lot :)
stdext::hash_map<String, SceneNode*> NodeList;
NodeList nodes;
//Here we add nodes to the list, a lot of nodes
//Here we want to remove the nodes (delete them of course)
NodeList::iterator it, endIt;
//Here is the delete Either Way1 or Way2
//WAY1
it = nodes.begin();
endIt = = nodes.end();
while(it != endIt){
delete it->second;
it = nodes.erase(it);
}
//WAY2
it = nodes.begin();
endIt = = nodes.end();
while(it != endIt){
delete it->second;
it++;
}
nodes.clear();