<div class="gmail_quote">2011/8/7 Michael Thompson <span dir="ltr"><<a href="mailto:mike.cornflake@gmail.com">mike.cornflake@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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.<br>
<br><pre style="margin:0pt;padding:0pt"><code>uses<br> fgl;<br><br>type<br>// for {$mode objfpc}<br> TIntegerList = specialize TFPGList<Integer>;</code></pre><br>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. <br>
<br>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? <br>
</blockquote></div><br>Good question. I have also though when we should start using generics in Lazarus and LCL code. Generics containers can eliminate many typecasts.<br>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.<br>
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.<br><br>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?<br>
<br>The generics TIntegerList doesn't support Sort or Find, they must be implemented if needed.<br>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:<br>
<a href="https://github.com/JuhaManninen/Pascal/tree/master/IntList">https://github.com/JuhaManninen/Pascal/tree/master/IntList</a><br>It is well optimised and has Sort (using QuickSort) and Find.<br>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.<br>
<br>Juha<br><br>