When iterating through a core::map, there are some items I need to check before deleting them and I can't find any simple way to delete a Node* or an Iterator from map. remove only accepts a key which means I will look twice for the same item as I already have the correct Node*.
TJoystickMap::Iterator itr = Joysticks.getIterator();
for( ;!itr.atEnd(); ++itr)
{
TJoystickMap::Node* n = itr.getNode();
CJoystickDirectInput* joystick = n->getValue();
// Copy Save state
const SJoystickState savedState = joystick->getState();
if( joystick->update() )
{
// generate events
IInputManager::compareStates(savedState, joystick);
}
else
{
sendJoystickEvent(EJE_UNPLUGGED, joystick );
Joysticks.remove ( n->getKey() ); //!< Here is the "problem", I don't need to search the node again. I wish I could do: Joysticks.remove(n);
}
}
This is very simple to do and effective.
Matt
Using trunk with mingw/gcc 4.6, Windows 7 64 bits driver opengl