Consider the following incomplete snippet:
for (std::list<CollidableNode*>::iterator it = m_Enemies.begin(); it != m_Enemies.end();it++)
{
//for current position+1 to end loop
for (std::list<CollidableNode*>::iterator jt = it+1; jt != m_Enemies.end();jt++)
{
//do stuff
}
}
This code produces obvious errors, but illustrates what I'm trying to do, which is: in the nested loop, set the start point of the loop at the current position in the list, plus one position, so that no duplicate checks are carried out.
Considerations are that the list is highly dynamic in size, with the list being checked for items to remove every update, and new items being added often, so that removals will be faster than a vector.
Is it possible to offset the iterator to a desired position, and if so, how do I go about doing that?
Thanks in advance