[Lazarus] GTK TlistView

Juha Manninen juha.manninen62 at gmail.com
Mon Aug 8 23:19:20 CEST 2011


2011/8/7 Michael Thompson <mike.cornflake at gmail.com>

> Before I submit the patch I'd like to optimise this code using a sorted
> integer list or two (side by side with ItemCache).  Someone on the forums
> pointed me to a syntax I was previously unfamiliar with, that I'd like to
> use.
>
> uses
>   fgl;
>
> type
> // for {$mode objfpc}
>   TIntegerList = specialize TFPGList<Integer>;
>
>
> My problem is that when I go into fgl it states this is prototype code -
> and to me that means either the interface or implementation is likely to
> change in the future.
>
> My question is, are you guys happy if I go ahead and implement code inside
> gtk2wscustomlistview.inc that uses this functionality, or should I just stay
> on the safe side and implement a specific TIntegerList for this scenario?
>

Good question. I have also though when we should start using generics in
Lazarus and LCL code. Generics containers can eliminate many typecasts.
I remember that 2 latest FPC versions should be supported by Lazarus trunk
code. Currently it means FPC 2.4.2 and 2.4.4.
In FPC 2.4.2 generics work already quite well. They may have some
performance problems still, don't know. In FPC 2.4.0 generics were broken.

It may still be safer to use a dedicated IntegerList now and start using
generics after next Lazarus release & FPC 2.6.0 release. What do others say?

The generics TIntegerList doesn't support Sort or Find, they must be
implemented if needed.
If you decide to go with a traditional (non-generics) integer list, you
don't need to code a yet-another version of it yourself. For example I have
one here:
 https://github.com/JuhaManninen/Pascal/tree/master/IntList
It is well optimised and has Sort (using QuickSort) and Find.
It is strange that Lazarus code-base still doesn't have such a list. In many
places pointer-lists are used for integers or even for chars with horrible
typecasts.

Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110809/b64966ee/attachment-0003.html>


More information about the Lazarus mailing list