[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Death In Swarm
From: |
Tomas Gudmundsson |
Subject: |
RE: Death In Swarm |
Date: |
Thu, 17 Oct 1996 08:11:46 +0000 |
Hello Manor
> but this, as we shall see, causes trouble - which is why you need to use
> a ReaperQueue. This is how it works...
Thanks for the help ! I also ended up with a similar solution while waiting for
the sun to rise in your part of the world :-).
> id index, suicidalBanana ;
> index = [reaperQueue begin: [self getZone]] ;
> while( (suicidalBanana = [index next]) ){
> [index remove] ; //remove the Banana from the reaperQueue.
> [suicidalBanana drop] ; //remove the Banana from the world.
> }
One question though. As far as I can see, you are actually removing and
dropping objects from a list while traversing it. Isn't that just as fatal as
the original problem that started this dicussion ?
I first traverse the reaper list and remove the objects in it from the banana
list. Finally I empty the reaper list :
id index, suicidalBanana;
if ([reaperQueue getCount] > 0);
{
// Remove the items in the reaper list from the banana list
index = [reaperQueue begin: [self getZone]];
while ((suicidalBanana = [index next]))
{
[bananaList remove: suicidalBanana];
[suicidalBanana drop];
}
// Empty reaper list
[reaperQueue removeAll];
}
Best Regards
Tomas Gudmundsson
Danish Hydraulic Institute