swarm-support
[Top][All Lists]
Advanced

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

Want to delete item from list. Can't understand archived notes


From: Paul Johnson
Subject: Want to delete item from list. Can't understand archived notes
Date: Fri, 17 Jul 1998 10:56:09 -0500 (CDT)

I have a list of objects, each is evaluated by a criterion, I pick the
best and add it to another list. Then I want to delete that best
alternative from the list, do the same procedure to pick the second best,
add it on that other list.  The problem is that I can't seem to find
a way to code the removal from the list that does not cause a seg fault.

I found in the mailing list archives (May 22, 1998) a discussion between Roger,
Doug D,  Marcus, and Geoff Schultz, and I'm too dense to understand how to
adapt their suggestions.

Here is my code snippet that finds the alternative with the lowest disutility
from the list invitationsList and adds it to invitationsRanking.


           invitationsRanking=[List create: [self getZone]];
            bestValue=100000.0;
           index = [invitationsList begin: [self getZone]];
      
           while (( aRecruiter = [index next]) ) {
               
                  proposal= [aRecruiter getProposal];
                  disutility = [self distFromIdeal: proposal];
                  if(disutility < bestValue) { bestValue=disutility; 
bestAlternative=aRecruiter;}
              
              }
      
            [invitationsRanking addLast: bestAlternative];


This code runs FINE to pick the bestAlternaive.  It only works when
I want to pick the single
best alternative, and I want to cycle through it again to pick the second best
as well.  To do that I need to remove bestAlternative from the invitationsList.

I tried just putting
                [invitationsList remove: bestAlternative];
at the end of all this, but it seg faults big time.

If you have an idea, please let me know!

Incidentally, I got into this because I got lots of strange output from the
Qsort method  in Simtools.  I asked about that method a couple of weeks ago in 
here and didn't find any authorities on it, so I gave up. The problem seems
to be that the Sort method insists the criterion be an integer, rather than
a double.  Oh, well, if I can find a way to pick the second best, third best,
etc, I will be happy and it won't take as much time as a full Qsort anyway.

Paul E. Johnson                      address@hidden
Dept. of Political Science           http://lark.cc.ukans.edu/~pauljohn
University of Kansas                 Office: (913) 864-9086
Lawrence, Kansas 66045               FAX: (913) 864-5700
 


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