swarm-support
[Top][All Lists]
Advanced

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

Re: removing elements while looping with an index, and returnvaluesfrom


From: Gary Polhill
Subject: Re: removing elements while looping with an index, and returnvaluesfrom Set add
Date: Tue, 19 Mar 2002 13:26:49 +0000

Just for the tedious pedantry of it, I've just thought of a solution involving 
one pass through the list and no dummy list:

-(void)removeFromListUnlessCondition: (id <List>) aList {
  int n;

  for(n = [aList getCount]; n > 0; n--) {
    id elem = [aList removeFirst];

    if(condition) {
      [aList addLast: elem];
    }
  }
}

Gary



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