[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
problem with adding to Map collection
From: |
Arend Ligtenberg |
Subject: |
problem with adding to Map collection |
Date: |
Tue, 10 Aug 1999 12:52:13 +0200 |
Dear listmembers,
I'am a novice in using SWARM. So perhaps my problem gives you a good laugh.
Anyway here it comes
What I like to do:
1) read a sequence of values (function values) from a file, each line a
seperate function ==> no problem
2) read these function values into a List object ==> no problem
3) add the list objects to a Map object so I can access them by a unique key
==> PROBLEM
My Map object only likes to create one entry. Next it says: do it yourself.
Below a sniplet of the code (from modelswarm.m) illustrating my approach.
Question:
- What am I doing wrong here?
- Is this a good solution anyway?
...
...
//Reading functionValues into List
// and next List into Map
functionCollection = [Map create: [self getZone]];
for (functcount=0; functcount < ([readFunction
getNrOfRelations]);functcount++){
[readFunction readRelation];
passor = [readFunction getPassor];
actor = [readFunction getActor];
radius = [readFunction getRadius];
printf("Passor: %d, Actor: %d, Neigborhood %d\n", passor, actor,
radius);
functionValueList = [List create: [self getZone]];
for (functvaluecount=0; functvaluecount < radius; functvaluecount++){
functvalue = [readFunction readFunctions];
[functionValueList addLast: functvalue];
}
printf("nr of elements in list: %d\n",[functionValueList getCount]);
[functionCollection at: functcount insert: functionValueList];
}
//debuging stuff
printf("the number of elements in the
functionCollection%d\n",[functionCollection getCount]);
printf("And here the values of each list stored in the Map collection
object\n");
indexje = [functionCollection begin: [self getZone]];
for (theSet = [indexje next]; [indexje getLoc] == Member; theSet =
[indexje next] ){
index = [theSet begin: [self getZone]];
for (fromMap = [index next]; [index getLoc] == Member; fromMap
= [index next]){
printf("value: %d\n",fromMap);
}
[index drop];
}
[indexje drop];
// end debuging stuff
Arend Ligtenberg
Wageningen University and Research Centre
Centre for Geo-information
Laboratory Geo-Information Science and Remote Sensing
Po Box 339
6700 AH Wageningen
tel: ++31 317 474640
www.gis.wau.nl/girs
==================================
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.
- problem with adding to Map collection,
Arend Ligtenberg <=