swarm-support
[Top][All Lists]
Advanced

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

Re: Adding and removing repeated pointers to a list


From: Marcus G. Daniels
Subject: Re: Adding and removing repeated pointers to a list
Date: 21 Sep 1999 16:09:05 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.4

>>>>> "JG" == Jonathan Greenberg <address@hidden> writes:

JG> Time 1: Add agent "A" Time 2: Add agent "B" Time 3: Add agent "A"

JG> Is the list now: A B A

JG> or is it A B ?

If it is an ordinary List then it is "A B A".

JG> what happens if I "remove A" from the list,
JG> will I end up with "B" or "B,A" from that list?  Thanks in
JG> advance!

They are removed from left to right; "B,A".

#import <simtools.h>
#import <collections.h>
#import <defobj/Create.h>

@interface Character: CreateDrop
{
  char value;
  member_t link;
}
- setValue: (char)value;
- (char)getValue;
@end

@implementation Character
- setValue: (char)theValue
{
  value = theValue;
  return self;
}

- (char)getValue
{
  return value;
}

- (void)describe: outputCharStream
{
  char buf[1 + 1 + 2 + 1];

  sprintf (buf, "`%c'\n", value);
  [outputCharStream catC: buf];
}
@end

#define MAKECHARACTER(value) \
  [[[Character createBegin: globalZone] setValue: value] createEnd]
  
int 
main (int argc, const char **argv)
{
  initSwarmBatch (argc, argv);
  
  {
    id <List> l;
    
    id obj1, obj2;

    l = [List create: globalZone];

    obj1 = MAKECHARACTER ('A');
    obj2 = MAKECHARACTER ('B');

    [l addLast: obj1];
    [l addLast: obj2];
    [l addLast: obj1];

    [l remove: obj1];
    xfprint (l);
  }
}

/*
Local Variables:
compile-command: "$SWARMHOME/bin/libtool-swarm --mode=link gcc -o list -g 
-Wno-import -I$SWARMHOME/include -L$SWARMHOME/lib list.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]