/*Marcus Daniels swarm-support list Feb. 09, 2000 GO> I would like to have some help, but with another object: Permutation. Permutation really only exists to support permuted indices. Here's an example of the use of permuted indices: */ #import // initSwarm #import // List #import // CreateDrop #import // sprintf @interface Integer: CreateDrop { int value; } - setValue: (int)value; - (int)getValue; @end @implementation Integer - setValue: (int)theValue { value = theValue; return self; } - (int)getValue { return value; } - (void)describe: outputCharStream { char buf[DSIZE (int) + 1 + 1]; sprintf (buf, "%d\n", value); [outputCharStream catC: buf]; } @end #define INTEGER(value) \ [[[Integer createBegin: globalZone] setValue: value] createEnd] #define PARTITION_SIZE 5 #define PARTITION_COUNT 10 int main (int argc, const char **argv) { id l; id li; id obj; unsigned i; initSwarmBatch (argc, argv); l = [List create: globalZone]; for (i = 0; i < PARTITION_SIZE * PARTITION_COUNT; i++) [l addFirst: INTEGER (i)]; li = [l beginPermuted: globalZone]; for (i = 0; (obj = [li next]); i++) { printf ("partition#: %u [%u] value: %u\n", i / PARTITION_SIZE, i % PARTITION_SIZE, [obj getValue]); } [li drop]; [l deleteAll]; [l drop]; return 0; } /* Local Variables: compile-command: "$SWARMHOME/bin/libtool-swarm --mode=link gcc -o randomindex -Wall -Werror -g -Wno-import -I$SWARMHOME/include/swarm -L$SWARMHOME/lib/swarm randomindex.m -lswarm -lobjc" End: */