[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Java-Swarm questions
From: |
Ralf Stephan |
Subject: |
Re: Java-Swarm questions |
Date: |
Sun, 31 Dec 2000 22:10:57 +0100 |
User-agent: |
Mutt/1.2.5i |
Paul E. Johnson wrote
> 2. This one thing in Java really goes against my C impulse. Suppose you
> want to interate over a collection several times. You create an
> iterator, step through the collection. There is (apparently??) no way
> to tell the Java iterator to go back to the beginning of the collection,
> so the only thing to do is to create another one? And you don't drop
> the first one?
That is collected by GC, at some time, yes. In (Obj)-C, you keep the
the control over *when* space is freed, with the drawback of
additional work/risk.
>
>
> public void stepAgents (){
> int x;
> Iterator iterator = agents.listIterator(0);
> Agent anAgent = null ;
> while (iterator.hasNext()){
> anAgent = (Agent) iterator.next();
> x = anAgent.makeChoice();
> }
>
> iterator = agents.listIterator(0);
> while (iterator.hasNext()){
> anAgent = (Agent) iterator2.next();
> anAgent.updateStrategies();
> }
> }
>
>
> There's no way to drop the first iterator forcefully, before coining the
> second? Aren't we relying on the garbage collector for an awful lot of
> help?
Yes, but it works, with the disadvantage of losing fine-grained control
over *when* space is freed. But Sun succeded in getting back some
detail with Java 1.2 AFAIR, where additional GC flags were introduced.
ralf
==================================
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.