Class TStructList
Unit
Declaration
type generic TStructList<T> = class(specialize TList<T>)
Description
List of structures. This is just TList class from Generics.Collections, with some useful helpers.
Hierarchy
- TObject
- TList
- TStructList
Overview
Nested Types
PtrT = ˆT; |
|
PTypeList = ˆTTypeList; |
|
TTypeList = array [0 .. MaxInt div SizeOf(T) - 1] of T; |
Methods
function List: PTypeList; deprecated 'use L, like MyList.L[123] instead of MyList.Listˆ[123]'; |
|
function L: PtrT; |
|
function Add: PtrT; overload; |
|
function Ptr(const I: TListSize): PtrT; |
|
procedure Assign(const Source: TStructList ); overload; |
|
procedure Assign(const A: array of T); overload; |
|
function ItemSize: TListSize; |
|
procedure AddSubRange(const Source: TStructList ; const Index, AddCount: TListSize); |
|
procedure AssignLerpRange(const Fraction: Single; const V1, V2: TStructList ; const Index1, Index2, ACount: TListSize); virtual; |
|
procedure AssignLerp(const Fraction: Single; const V1, V2: TStructList ); |
|
function PerfectlyEquals( const SecondValue: TStructList): Boolean; |
|
procedure AddArray(const A: array of T); deprecated 'use AddRange'; |
|
procedure AddList(const Source: TStructList ); deprecated 'use AddRange'; |
|
procedure AssignArray(const A: array of T); deprecated 'use Assign'; |
Description
Nested Types
PtrT = ˆT; |
|
This item has no description. |
PTypeList = ˆTTypeList; |
|
This item has no description. |
TTypeList = array [0 .. MaxInt div SizeOf(T) - 1] of T; |
|
TODO: Can we calculate better size on Delphi? Now we just assume that T has max size 16 * 16. This declaration will fail if you try to use TStructList with larger T. Note: we cannot declare list size too small, or using it may fail with range check error (e.g. Delphi, in IndexedPolygons_TrianglesCount, testcase: build_3d_object_by_code_2_tunnel. |
Methods
function List: PTypeList; deprecated 'use L, like MyList.L[123] instead of MyList.Listˆ[123]'; |
|
Warning: this symbol is deprecated: use L, like MyList.L[123] instead of MyList.Listˆ[123] Access the list contents through a pointer to an array of items. This is exactly the same pointer as L, but the type is different: List points to an array of items, while L points to a single item. Using L is preferred over this List, because L avoids "fake infinite list" type TTypeList, that in particular on Delphi may have too small size (and cause range check errors). See the L description for a more detailed explanation and example. See also
|
function L: PtrT; |
|
Access the list contents through a pointer, to get or set them efficiently. Use this to directly access a list value, like this: MyIntList.L[I] := 123; // Equivalent but less efficient to syntax without L: // MyIntList[I] := 123; MyIntList.L[I] := MyIntList.L[I] + 123; // Equivalent but less efficient to syntax without L: // MyIntList[I] := MyIntList[I] + 123; MyRecordList.L[I].MyField := 123; // Never use syntax without L (see below for reasons): // MyRecordList[I].MyField := 123; //< never do this!
The above examples of L work only in FPC ObjFpc mode or in Delphi with pointermath "on" (see https://docwiki.embarcadero.com/RADStudio/Sydney/en/Pointer_Math_(Delphi) ). These are CGE default settings when being compiled with FPC or Delphi, so you can depend on them at least in CGE implementation. Note that Delphi applications just using L don't actually have pointermath "on", it is enough that this unit is compiled with pointermath "on" and then one can use math on PtrT. This is in particular useful if you have a list of records and you would like to set their fields. E.g. this is incorrect (and should not even compile if MyField is really a simple field): type TMyRecord = record MyField: Integer; end; TMyRecordList = specialize TGenericStructList<TMyRecord>; var MyList: TMyRecordList; begin // ... MyList[I].MyField := 123;
It will not work OK because you would modify only a temporary record returned by the In contrast, this will work OK:
MyList.L[I].MyField := 123;
Using L is preferred over this List, because it avoids "fake infinite list" type TTypeList, that in particular on Delphi may have too small size. See also
|
function Add: PtrT; overload; |
|
Increase Count and return pointer to new item. Comfortable and efficient way to add a new item that you want to immediately initialize. |
function Ptr(const I: TListSize): PtrT; |
|
Pointer to ith item. |
procedure Assign(const Source: TStructList ); overload; |
|
This item has no description. |
procedure Assign(const A: array of T); overload; |
|
This item has no description. |
function ItemSize: TListSize; |
|
This item has no description. |
procedure AddSubRange(const Source: TStructList ; const Index, AddCount: TListSize); |
|
Add a subrange of another list here. This method may ignore the OnNotify mechanism, for the sake of fast execution. |
procedure AssignLerpRange(const Fraction: Single; const V1, V2: TStructList ; const Index1, Index2, ACount: TListSize); virtual; |
|
Assign here a linear interpolation of two other arrays. We take ACount items, from V1[Index1 ... Index1 + ACount - 1] and V2[Index2 ... Index2 + ACount - 1], and interpolate between them. It's Ok for both V1 and V2 to be the same objects. But their ranges should not overlap, for future optimizations. Exceptions raised
|
procedure AssignLerp(const Fraction: Single; const V1, V2: TStructList ); |
|
Assign linear interpolation between two other arrays. Exceptions raised
|
function PerfectlyEquals( const SecondValue: TStructList): Boolean; |
|
Does the SecondValue have equal type, length and content. The values are compared perfectly, without any tolerance for difference. |
procedure AddArray(const A: array of T); deprecated 'use AddRange'; |
|
Warning: this symbol is deprecated: use AddRange This item has no description. |
procedure AddList(const Source: TStructList ); deprecated 'use AddRange'; |
|
Warning: this symbol is deprecated: use AddRange This item has no description. |
procedure AssignArray(const A: array of T); deprecated 'use Assign'; |
|
Warning: this symbol is deprecated: use Assign This item has no description. |
Generated by PasDoc 0.16.0-snapshot.