[fpc-devel] TFPList / TList Sort with Context parameter

Ondrej Pokorny lazarus at kluug.net
Mon Aug 12 13:02:34 CEST 2019


Hello!

I see that sortbase.pp has prepared sorting functionality with context 
(=custom parameter) that I need to use. See 
TSortingAlgorithm.PtrListSorter_ContextComparer and 
QuickSort_PtrList_Context.

But I don't know how to use them within TList because TFPList / TList 
doesn't publish any Sort() overloads that use them. Furthermore FList is 
private which means I cannot access it in a derived object and I cannot 
add this functionality for my own list object.

My question is: how can I sort a TList/TFPList with a custom context 
parameter?:

   TList = class(TObject,IFPObserved)
     // ...
     procedure Sort(Compare: TListSortComparer_Context);
   end;

If this is not possible (which I think it is not), will a patch be 
accepted that adds these methods to TFPList/TList?:
     procedure Sort(Compare: TListSortComparer_Context);
     procedure Sort(Compare: TListSortComparer_Context; 
SortingAlgorithm: PSortingAlgorithm);

Best
Ondrej



More information about the fpc-devel mailing list