[fpc-devel] Standard generic classes

Sven Barth pascaldragon at googlemail.com
Wed Jun 5 09:01:21 CEST 2019


J. Gareth Moreton <gareth at moreton-family.com> schrieb am Di., 4. Juni 2019,
22:40:

> Hi everyone,
>
> I may be missing the obvious here, but I've noticed that there are some
> notable absences in the Free Generics Library.  While there's a standard
> list and a map and the like, there aren't any of the special lists like
> a stack and a queue and the like.  It proved slightly problematic while
> in a mentoring session with another programmer whom I was introducing to
> Free Pascal, because our sample project required a stack.  The standard
> TStack uses pointers, which is not exactly portable.
>
> If not present, can I request the addition of TFPGStack and TFPGQueue to
> the Free Generics Library? They should be simple descendants of of
> TFPGList unless I'm missing something painfully obvious.  Or am I
> missing something even more obvious in that they are defined elsewhere?
>

Just to add a bit to the other answer: FPC has three generic libraries:
fgl, fcl-stl and rtl-generics.
fgl is the oldest and also served as a testbed for the generics. It cycles
together with the compiler and is comparatively lightweight (at least to
the other two), but has some requirements when using records as parameters
and the performance isn't as good as that if rtl-generics.
fcl-stl had been a contribution by a third party developer for a
C++-STL-like generics library.
rtl-generics was also contributed by a third party developer for Delphi
compatibility, is rather performant, but also rather heavy weight.

You can also see a speed comparison here:
http://www.benibela.de/fpc-map-benchmark_en.html

In the end (if you don't need specific functionality like a stack ;) ),
it's a "pick your own poison" problem :P

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190605/d7edb6cc/attachment.html>


More information about the fpc-devel mailing list