swarm-support
[Top][All Lists]
Advanced

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

Re: ooops!


From: Marcus G. Daniels
Subject: Re: ooops!
Date: 07 Dec 1999 17:09:46 -0800
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "JR" == Juan A Rodriguez <address@hidden> writes:

JR> but I would appreciate it, just curiostity, if anyone sent me an
JR> example as I requested before.

import swarm.defobj.Zone;
import swarm.collections.List;
import swarm.collections.Map;
import swarm.collections.MapImpl;
import swarm.collections.MapIndex;
import swarm.collections.ListImpl;
import swarm.collections.ListIndex;
import swarm.Globals;

public class TestIndex {
  List list;
  Map map;

  class Agent {
    int value;

    Agent (int value) {
      super ();

      this.value = value;
    }
    
    int getValue () {
      return value;
    }
  }
  
  TestIndex () {
    super ();
  }

  void checkListIndex (Zone aZone) {
    list = new ListImpl (aZone);

    list.addLast (new Agent (1));
    list.addLast (new Agent (2));
    
    ListIndex index = list.listBegin (aZone);
    Object obj;

    while ((obj = index.next ()) != null) {
      System.out.println (((Agent) obj).getValue ());
    }
  }

  void checkMapIndex (Zone aZone) {
    map = new MapImpl (aZone);
    
    map.at$insert (new Integer (4), new Agent (5));
    map.at$insert (new Integer (6), new Agent (7));

    MapIndex index = map.mapBegin (aZone);
    Object obj;

    while ((obj = index.next ()) != null) {
      System.out.println (((Agent) obj).getValue ());
    }
  }
  
  public static void main (String[] args) {
    Zone aZone = Globals.env.globalZone;
    Globals.env.initSwarm ("testIndex",
                           "2.0.1", "address@hidden",
                           args);
    TestIndex testIndex = new TestIndex ();
    testIndex.checkListIndex (aZone);
    testIndex.checkMapIndex (aZone);
  }
}


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