[fpc-pascal] TSortedCollection dupes ordering

waldo kitty wkitty42 at windstream.net
Thu Feb 6 18:04:46 CET 2014


On 2/5/2014 7:48 PM, Jim Leonard wrote:
> On 2/5/2014 5:24 PM, waldo kitty wrote:
>> i'm unsure what to do or how to handle this so that there is a secondary
>> (sub) sorting order so that the main key is the master sort and then a
>> secondary ""key"" is used when duplicates are allowed...
>
> You put both key comparisons in the same .Compare function.

interesting...

> In one of my Turbo Pascal projects, I used this:
>
> PSystems=^TSystems;
> TSystems=object(TSortedCollection)
>    function Compare(Key1, Key2: Pointer): Integer; virtual;
>    function GetSize:longint;
> end;
>
> ...
>
> Function TSystems.Compare;
>
> begin
>    if PSystem(Key1)^.score < PSystem(Key2)^.score
>      then Compare := -1

ahh... i see what you are doing... you are passing the pointer to the whole 
record instead of just the needed key... hummm... i'll have to think about that 
and how to do it in my app... right now i'm only passing the necessary key 
because the record is 'large'... but then again... some thought and meditation 
is necessary ;)


-- 
NOTE: No off-list assistance is given without prior approval.
       Please keep mailing list traffic on the list unless
       private contact is specifically requested and granted.



More information about the fpc-pascal mailing list