Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2019-08

TFPList / TList Sort with Context parameter

3 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ondrej Pokorny

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

Reply by email

Ondrej Pokorny
to Ondrej Pokorny
Ondrej Pokorny wrote 5 lines
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);
The methods will be:
     procedure Sort(Compare: TListSortComparer_Context; Context: Pointer);
     procedure Sort(Compare: TListSortComparer_Context; Context:
Pointer; SortingAlgorithm: PSortingAlgorithm);

obviously...

Ondrej

Reply by email