Forum > General

How to make a specialized TList that holds a list of records?

<< < (2/3) > >>

Warfley:
The easiest solution for you is to use Generics.Collections TList class instead of FGL:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses ...,Generics.Collections,......  TProjectList = specialize TList<TProject>;It's in most cases the better option anyway (more functionality, easier to use, etc.)

To answer your problem with the FGL list, you need to overload the equality:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TProject=recordprivate  …  class operator =(const lhs,rhs: TProject): Boolean;end; ... class operator TProject.=(const lhs,rhs: TProject): Boolean;begin  Result := (lhs.Field1 = rhs.Field2)        and (lhs.Field2 = rhs.Field2)        and (lhs.Field3 = rhs.Field3);            ...end;

Cascade:
I hadn't realised there were two separate implementations of generics available.  I will take a look at Generics.Collections - thank you.

PascalDragon:

--- Quote from: Cascade on November 11, 2024, 07:05:41 pm ---I hadn't realised there were two separate implementations of generics available.

--- End quote ---

Well, it's even more than two, cause there is also the fcl-stl and there is at least one more available here on the forum.

Cascade:
I have a lot to learn.  Generics.Collections is working OK for me - thank you.

VisualLab:

--- Quote from: Cascade on November 11, 2024, 08:59:23 pm ---I have a lot to learn.  Generics.Collections is working OK for me - thank you.

--- End quote ---

Not only for you  :D

If your project manager is (will be) large, then it's probably better to implement it as a class. That's what I would do. For many reasons (e.g. if it will create internal objects as fields, or reference system resources). Managed records are good for "smaller things" (e.g. complex numbers, quaternions, vectors, maybe polynomials, etc.).

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version