i have this iterator loop,
typedef boost::unordered_map<std::pair<int, int>, NavigationNode> NodesMap;
NodesMap nodes;
for (NodesMap::iterator it= nodes.begin(); it != nodes.end() ; ++it)
{
if(it->second.type == NavigationNodeType_Walkable)
{
ConnectNode(&it->second);
}
}
ConnectNode function seems to be invalidating the iterator. It pushes new elements inside the NavigationNode and modifies existing members of the NavigationNode.
i have two questions
- Is passing it->second as pointer bad?
- What's the best way to iterate through this container?
thank you.
edit:
does accessing container's elements like this
nodes[intpair(x, y)]
inside ConnectNode function would cause this problem?
edit2 yes it does.
Why is that? and How would i get around it?