On Fri, 25 Jul 2008 05:46:56 -0700, Iain King wrote:

> or 3. build a new list every iteration intead of deleting from the old
> one:
> 
> while processing:
>     new_off_list = []
>     for x in off_list:
>         if goes_on(x):
>             on_list.append(x)
>         else:
>             new_off_list.append(x)
>     off_list = new_off_list
>     generation += 1
> 
> Iain

Or 4, since the order of my nodes doesn't matter:  swap the node to be 
deleted with the last node in the list and then remove the last node of 
the list.  This is the fastest to date, if using native structures, for 
low number nodes being deleted per cycle (def if only deleting one).
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to