swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help on walking lists of Swarm Collection


From: Marcus G. Daniels
Subject: Re: Help on walking lists of Swarm Collection
Date: 08 May 1999 09:25:34 -0700

>>>>> "WS" == William S Shu <address@hidden> writes:

WS> for (i = 0; i < count; ++i) {
WS>   cly = [colonyList atOffset: i];

You don't want to do this.  Since List is a linked list, finding the
ith with atOffset: item requires iterating through from the beginning.
The result will be that processing all the colonies will slow as the
square of the count.

WS> What is not clear --
WS> not in the manual -- is whether such changes might adversely affect the
WS> forEach: message invoking dropDead. 

If dropDead has the side effect of touching the List, the Index will
break, and you'll probably get a segfault. 

Conceptually, I don't think it is clean to have agents touching global
bookkeeping data structures.  I mean, unless it is a suicide or a
terminal illness, people don't generally cancel their utilities and
fill out their own death certificates, etc.  Instead, a death causes a
disruption and society makes the necessary adaptations. 

At the code level, putting colonyList in each Agent means that there
need to be gratuitous setColonyList: calls needed in the construction
of each agent (or some other implicit environment like a global
variable or global environment object).



                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]