swarm-support
[Top][All Lists]
Advanced

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

Re: Using permutations


From: Marcus G. Daniels
Subject: Re: Using permutations
Date: 10 Feb 2000 11:11:07 -0800
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "GO" == Gadi Oron <address@hidden> writes:

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 <simtools.h> // initSwarm
#import <collections.h> // List
#import <defobj/Create.h> // CreateDrop
#import <misc.h> // 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 <List> l;
  id <Index> 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:
*/

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