Sign in Join

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

Mailing lists / fpc-pascal / 2019-02

FGL.TFPSList Find method needed (binary search)

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

AlexeyT

Hello. Can you pls, add Sorted property to TFPSList / TFPGList (Add() method must sort newly added item), and also Find method (which must use binary search in Sorted case, and use plain loop if not sorted)?

Regards, Alexey

Reply by email

Sven Barth
to AlexeyT

Am Sa., 16. Feb. 2019, 21:30 hat AlexeyT geschrieben:

Hello. Can you pls, add Sorted property to TFPSList / TFPGList (Add() method must sort newly added item), and also Find method (which must use binary search in Sorted case, and use plain loop if not sorted)

You could also check whether rtl-generics already provides what you need.

Just in case anyone wants to add this (I won't): this also requires properties for a comparer and a compare algorithm (essentially the arguments to Sort) as TFPGList should not require the presence of a comparison operator in the generic parameter type.

Regards,
Sven

Reply by email

Michael Van Canneyt
to AlexeyT: Hello. Can you pls, add Sorted property to TFPSList / TFPGList (Add() method must sort…
AlexeyT wrote
Hello. Can you pls, add Sorted property to TFPSList / TFPGList (Add() method must sort newly added item), and also Find method (which must use binary search in Sorted case, and use plain loop if not sorted)?

You can use the rtl-generics generics.collections.pas if you want sorting and binary search.

It makes no sense to re-implement all what is there in fgl.

Michael.

Reply by email