swarm-support
[Top][All Lists]
Advanced

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

Java-Swarm questions


From: Paul E Johnson
Subject: Java-Swarm questions
Date: Sun, 31 Dec 2000 10:44:57 -0600

1. I have a subclass of Grid2d for multi occupancy. It is a modernized
version of Sven's MoGrid2d. Throughout, the objc version uses the
pointer/MACRO to get "fast access" to items in the grid:

  cell = *discrete2dSiteAt(lattice, offsets, x, y);

If in Java I subclass from Grid2d, I don't see how I can use this.  I've
always assumed there must be some significant advantage to direct access
with *discrete2dSiteAt as opposed to getObjectAtX:Y:, and that's why I
kept doing it with the pointer.  But, come to think of it, I never
actually tested whether the subclass runs faster using the pointer.  Am
I understanding the situation correctly.  When in Java one subclases
from an objective C class, one gains access to the methods, but the
IVARs, especially pointer IVARs, can't be accessed?

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? 


   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?  

3. I understand from Marcus's example code the procedure to create an
instance of an objc class that requries the createBegin/createEnd
routine.  I can manage that.  I can't understand how to create
subclasses of such things, however.  For example, I understand how to
create an instance of an arguments object in this example
(http://lark.cc.ukans.edu/~pauljohn/SwarmFaq/WorkingExampleCode/java/ArgumentsCommandLine.java
) but I don't see what is needed to create a subclass of Arguments.  I
realize I need the newest Swarm to subclass Arguments, but an example of
any other class would be fine.  I guess I mean to say, I don't know how
the C, CImpl, Impl, etc, gets thrown in for subclassing as opposed to
instantiating, and how constructors relate to them.


-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700

                  ==================================
   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]