what is the correct way of removing an object from a list and then reinserting into the back of the list?
Code: Select all
void CSGUI_Window::popToBack(CSGUI_Window* w)
{
list<CSGUI_Window*>::Iterator it;
for (it = CSChildren.begin(); it != CSChildren.end(); it++)
{
if ((*it) == w)
{
CSChildren.erase(it);
CSChildren.push_back(w);
}
}
}
Code: Select all
void CSGUI_Window::popToBack(CSGUI_Window* w)
{
if (!CSChildren.empty())
{
list<CSGUI_Window*>::Iterator it;
for (it = CSChildren.begin(); it != CSChildren.end(); it++)
{
if ((*it) == w)
{
it = CSChildren.erase(it);
}
}
}
CSChildren.push_back(w);
}