swarm-support
[Top][All Lists]
Advanced

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

[Swarm-Support] Objects on multiple lists


From: Darold Higa
Subject: [Swarm-Support] Objects on multiple lists
Date: Mon, 17 Feb 2003 12:35:46 -0800

Dear All:

This is probably a really dead and beaten horse, but I couldn't find specific 
references to it...so here it goes.  I was going about trying to improve my 
code and in the process I decided to use collections more agressively , but 
now I have some unusual problems.

Here are my questions:

1.  When an object creates an internal collection, it seems that I can only 
do so by creating it within the ModelSwarm zone.  Is there no way to create 
temporary or instance collections internal to that object?  My only fear is 
by creating them within the ModelSwarm zone, I might leave collections lying 
about when the objects that create them are destroyed by my reaperqueue.  I 
thought I understood zones, but now I fear that maybe I don't, so any help 
here is appreciated.

I tried to do:

localAgentList = [List create: self];

but had to do

localAgentList = [List create: [modelSwarm getZone]];

2.  Is there some way to determine what effect having the same object in 
multiple collections will have?  I don't remember where I read/heard it, but 
I thought it was OK for an object to exist in multiple collections, since 
collections were pointers to the specific instances of an object.  In one 
case I had an object create a temporary list and assigned it the value of 
another list from another object.  (I guess I should have used copy.)  In any 
case, when I sent a removeAll command to the temporary list, the objects were 
removed from the original list as well.  How does this work?  I planned to 
have objects be on many lists at once, and I am not sure how manipulating 
collections affect other collections.

To make it clearer, I have a master list of agents (for scheduling purposes), 
then at each geographic cell in my world there is a list tracking what agents 
are in that cell, then I also wanted each agent to maintain their own 
internal lists of agents with similar identities, who they interacted with, 
etc.

To make a long and complicated question hopefully shorter, is the problem 
that I had with removeAll a result of my use of :

temporaryAgentList = [terrainObject getLocalAgentList];

instead of

temporaryAgentList = [[terrainObject getLocalAgentList] copy [modelSwarm 
getZone]];

?  Or does it have to do with objets on multiple lists that I do not 
understand.

2A.  If a list is made of objects through addLast, what effect will removing 
and or dropping items from this list have on any other lists?

I have targetAgentList as a subset of localAgentList.  If I eventually remove 
all from the targetAgentList, will it affect localAgentList?

I realize this may be a questioned answered adnauseum, but I searched through 
the archives and could not find an answer.  (BTW, is there an archive search 
like before?  I used to look things up that way but now I am doing it 
manually, which is not working too well.)

Darold Higa


reply via email to

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