Skip to content

TFPGInterfacedObjectList

[Properties (by Name)][Methods (by Name)][Events (by Name)]

Generic interfaced object list

Declaration

Source position: fgl.pp line 208

Type
  generic TFPGInterfacedObjectList<T> = class (TFPSList)
  private
    TCompareFunc = function(const Item1: T; const Item2: T) : Integer;
    PT = ^T;
    TTypeList = PT;
    PTypeList = ^TTypeList;
    TFPGListEnumeratorSpec = specialize TFPGListEnumerator<;
  protected
    FOnCompare : TCompareFunc;
    procedure CopyItem(Src: Pointer; Dest: Pointer);  Override;
    procedure Deref(Item: Pointer);  Override;
    function Get(Index: Integer) : T;
    function GetList : PTypeList;
    function ItemPtrCompare(Item1: Pointer; Item2: Pointer) : Integer;
    procedure Put(Index: Integer; const Item: T);
    function GetLast : T;
    procedure SetLast(const Value: T);
    function GetFirst : T;
    procedure SetFirst(const Value: T);
  public
    constructor Create;
    function Add(const Item: T) : Integer;
    function Extract(const Item: T) : T;
    First : T;
    function GetEnumerator : TFPGListEnumeratorSpec;
    function IndexOf(const Item: T) : Integer;
    procedure Insert(Index: Integer; const Item: T);
    Last : T;
    procedure Assign(Source: TFPGInterfacedObjectList);
    procedure AddList(Source: TFPGInterfacedObjectList);
    function Remove(const Item: T) : Integer;
    procedure Sort(Compare: TCompareFunc);
    procedure Sort(Compare: TCompareFunc; 
                  SortingAlgorithm: PSortingAlgorithm);
    Items[Index: Integer]: T; default;
    List : PTypeList;
  end
  ;

Description

TFPGList can be used to specialize a list for any class type T that requires reference counting (all objects that implement IInterface or IUnknown)). It will specialize to a list with the same methods as TFPSList or classes.TFPList or TFPObjectList

Classes that implement IInterface or IUnknown require special care to maintain the reference count. The TFPGInterfacedObjectList list provides the necessary functionality to deal with this.

Members

Member Type Visibility Description
Add Method public Add new object of class T to the list.
AddList Method public Adds the elements from another list
Assign Method public Copy objects from Source list
CopyItem Method protected
Create Method public Instantiate a new interfaced object list.
Deref Method protected
Extract Method public Extract an item from the list
First Property public First non-nil object
FOnCompare Field protected
Get Method protected
GetEnumerator Method public Return a list enumerator for T
GetFirst Method protected
GetLast Method protected
GetList Method protected
IndexOf Method public Index of object
Insert Method public Insert a new object in the list
ItemPtrCompare Method protected
Items Property public Indexed access to objects in the list.
Last Property public Last non-Nil object
List Property public Internal list pointer
PT Type private
PTypeList Type private
Put Method protected
Remove Method public Remove an object from the list.
SetFirst Method protected
SetLast Method protected
Sort Method public Sort the objects in the list
TCompareFunc Type private
TFPGListEnumeratorSpec Type private
TTypeList Type private

Inheritance

Class Description
TFPGInterfacedObjectList Generic interfaced object list

See also

Name Description
classes.TFPList Class to manage collections of pointers.
TFPSList Basic list of memory blocks