Hi Florain, Thanks for the quick response.
On 2016-12-04 10:06, Florian Klämpfl wrote: > You mean you want allow duplicates? I want the list to silently ignore duplicates. eg: numberList.Duplicates := dupIgnore; numberList.Sorted := true; numberList.add(1); numberList.add(2); numberList.add(3); numberList.add(1); The list will only contain 3 items in the end and the list is always sorted. > Then you should have a look at TFPGList, even if you do not like > generics. TFPGList is our approach to extend FPC carefully with generics. At the moment I'm using FPC 2.6.4 for the work I'm doing. I can't yet move to FPC 3.0.0. My worry about Generics is the following statement in the fgl.pp unit: " { be aware, this unit is a prototype and subject to be changed heavily } " So that tells me this is not to be used in production software as it is more like an experiment than anything else. > As it is written in objfpc > mode, you are forced not to clutter your code with specializations but you do > once a TInt8List = > specialize TFPGList<Int8> etc. and continue to use TInt8List. This is good news at least. I also only use objfpc mode in my code. I'm not totally discarding the use of Generics, I'm just worried about that prototype statement I mentioned. That made me thing that I might be better off implementing my own TList<T> because I don't know the future of the fgl.pp unit. But then if I go to all the trouble of implementing my own TList<T> then I can just as well use TIntegerList = class(TList) or something (but I do realise this last point will most likely be more coding). ps: Is it recommended to always define a specialised type? I guess it makes the code more clear when read by a human. Or is it perfectly acceptable doing: var lst: specialize TFPGList<Int8>; begin ... end; > Further, TFPGList is a > wrapper/anchestor around TFPSList, so each specialization does not explode > into another full TList > like implementation: a lot of code is shared by all specializations of > TFPGList. I was just looking over the fgl.pp unit and noticed that exact point. So that is at least another good design. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal