for (list<foo>::iterator i = mylist.begin(), e = mylist.end(); i != e; ++i) { update_code; }
list<foo> tmp = mylist;
for (list<foo>::iterator i = tmp.begin(), e = tmp.end(); i != e; ++i) { update_code; }
iter = list.erase(iter)since erase returns the next value.
void combat_update( void )
{
… declares
for( li = fight_list.begin(); li != fight_list.end(); li++ )
{
ch = *li;
if( ch == NULL )
{
monitor_chan("Removing a null ch from queue.",MONITOR_DEBUG);
li = fight_list.erase(li);
}
if( ch->fighting == NULL )
{
monitor_chan("Removing a null ch->fighting from queue.",MONITOR_DEBUG);
li = fight_list.erase(li);
}
victim = ch->fighting;
… do_more_stuff()
}
}
void stop_fighting( CHAR_DATA * ch, bool fBoth )
{
std::list<CHAR_DATA *>::iterator li;
CHAR_DATA *victim = ch->fighting;
ch->position = POS_STANDING;
update_pos( ch );
fight_list.remove(ch);
if( !fBoth )
{
ch->fighting = NULL;
return;
}
for( li = fight_list.begin(); li != fight_list.end(); li++ )
{
if( *li == victim )
{
victim->position = POS_STANDING;
update_pos( victim );
victim->fighting = NULL;
li = fight_list.erase(li);
}
}
ch->fighting = NULL;
return;
}
for (list<foo>::iterator i = mylist.begin(); i != mylist.end(); ) {
if ( /* delete condition */ ) {
mylist.erase(i++);
} else
…
++i;
}
}
iter = list.erase(iter)since erase returns the next value.
iter = list.begin();
while (iter != list.end()) {
if (need_to_delete)
iter = list.erase(iter);
else
++iter;
}
if( delete )
list.erase(iter++)
if( delete )
list.erase(iter++)
do_stuff()
++iter
if( delete )
list.erase(iter++)
else if( delete )
list.erase(iter++)
else
++iter
do_stuff()
if( delete )
list.erase(iter++)
else if( delete )
list.erase(iter++)
if( delete )
list.erase(iter++)
else if( delete )
list.erase(iter++)
else
++iter
do_stuff()
Is there any good way to log, trace, or even get more info about this? Once the data passes to the STL functions I can't seem to print any information within that frame to look at further, so I've come to a stopping point.