disposing item in linked list, but not immediately

Started by
2 comments, last by iMalc 18 years, 6 months ago
I've a bunch of 'enemies' in a linked list, and when they are shot they must be disposed of. So I search in the list and adjust the list accordingly. But now a problem arises, I need to let the enemy 'live' for a while, but I want to dispose the enemy somewhat later, without searching the list again. How can I solve this problem. Do i need to set a pointer to that pointer in the list? And dispose this pointer later. yuk, getting complicated.
Advertisement
have a second list.
remove "dead" creatures from the first list, insert them into the second list.
then you can delete them from the second list when youare done with them
an interesting solution.. thanks.
Quote:Original post by KulSeran
have a second list.
remove "dead" creatures from the first list, insert them into the second list.
then you can delete them from the second list when youare done with them
Ditto. Take them out of your main list and put them on death row[grin]

[Edited by - iMalc on October 5, 2005 8:38:58 PM]
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms

This topic is closed to new replies.

Advertisement