[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: QSort.......
From: |
Ralf Stephan |
Subject: |
Re: QSort....... |
Date: |
Mon, 29 May 2000 17:05:23 +0200 |
Marie-Edith Bisset:
> So my problem:
> I have an array of Value objects, which I would like to rank. In my
> program, the Value class is an object wrapper for integers.
>
> The statement:
>
> [QSort sortObjectsIn: arrayOfDistance];
>
> does not crash the program, but basically does nothing: the elements
> in the array are still in the same order.
This invokes Value::compare which is probably not defined.
This message has to be of the form int compare: (id) otherObject;
> The statement:
>
> [QSort sortObjectsIn: arrayOfDistance using:M(getMyValue)];
>
> where getMyValue is a function of the Value class returning the
> integer value of the object, does something (ie the elements in the
> array are in a different order), but does not rank the array in
> ascending order.
The values are probably interpreted as comparison results and so
this produces garbage behaviour.
> I have also written a comparison function which I put in the value
> class:
>
> -(int)compareValue:value1:value2
> {
> int val1,val2;
> val1=[value1 getMyValue];
> val2=[value2 getMyValue];
> return val1<val2?-1:val1!=val2;
> }
The func has to be of type (PTRINT) func: (id) otherObject;
if I understand the source correctly.
In logzone (v.0.6 in anarchy) I have augmented the QSort source,
as I was also unable to get the other mechanisms to work but I will
revise it ASAP if Marcus gives a better answer to your query than
mine is <g>.
ralf
--
http://ME.IN-berlin.de/~rws/
==================================
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.
- QSort......., Marie-Edith Bissey, 2000/05/29
- Re: QSort.......,
Ralf Stephan <=