TList
[Properties (by Name)][Methods (by Name)][Events (by Name)]
Class to manage collections of pointers.
Declaration
Source position: classesh.inc line 296
Type
TList = class (TObject, IFPObserved)
private
FList : TFPList;
FObservers : TFPList;
procedure CopyMove(aList: TList);
procedure MergeMove(aList: TList);
procedure DoCopy(ListA: TList; ListB: TList);
procedure DoSrcUnique(ListA: TList; ListB: TList);
procedure DoAnd(ListA: TList; ListB: TList);
procedure DoDestUnique(ListA: TList; ListB: TList);
procedure DoOr(ListA: TList; ListB: TList);
procedure DoXOr(ListA: TList; ListB: TList);
protected
function Get(Index: Integer) : Pointer;
procedure Grow; Virtual;
procedure Put(Index: Integer; Item: Pointer);
procedure Notify(Ptr: Pointer; Action: TListNotification); Virtual;
procedure SetCapacity(NewCapacity: Integer);
function GetCapacity : Integer;
procedure SetCount(NewCount: Integer);
function GetCount : Integer;
function GetList : PPointerList;
public
constructor Create;
destructor Destroy; Override;
procedure FPOAttachObserver(AObserver: TObject);
procedure FPODetachObserver(AObserver: TObject);
procedure FPONotifyObservers(ASender: TObject;
AOperation: TFPObservedOperation;
Data: Pointer);
procedure AddList(AList: TList);
function Add(Item: Pointer) : Integer;
procedure Clear; Virtual;
procedure Delete(Index: Integer);
class procedure Error(const Msg: string; Data: PtrInt); Virtual;
procedure Exchange(Index1: Integer; Index2: Integer);
function Expand : TList;
function Extract(item: Pointer) : Pointer;
function First : Pointer;
function GetEnumerator : TListEnumerator;
function IndexOf(Item: Pointer) : Integer;
procedure Insert(Index: Integer; Item: Pointer);
function Last : Pointer;
procedure Move(CurIndex: Integer; NewIndex: Integer);
procedure Assign(ListA: TList; AOperator: TListAssignOp; ListB: TList);
function Remove(Item: Pointer) : Integer;
procedure Pack;
procedure Sort(Compare: TListSortCompare);
procedure Sort(Compare: TListSortCompare;
SortingAlgorithm: PSortingAlgorithm);
procedure Sort(Compare: TListSortComparer_Context; Context: Pointer);
procedure Sort(Compare: TListSortComparer_Context; Context: Pointer;
SortingAlgorithm: PSortingAlgorithm);
Capacity : Integer;
Count : Integer;
Items[Index: Integer]: Pointer; default;
List : PPointerList;
end
;
Description
TList is a class that can be used to manage collections of pointers. It introduces methods and properties to store the pointers, search in the list of pointers, sort them. It manages its memory by itself, no intervention for that is needed. It has an event notification mechanism which allows to notify of list changes. This slows down some of TList mechanisms, and if no notification is used, TFPList may be used instead.
To manage collections of strings, it is better to use a TStrings descendant such as TStringList . To manage general objects, a TCollection class exists, from which a descendant can be made to manage collections of various kinds.
Members
Member | Type | Visibility | Description |
---|---|---|---|
Add | Method | public | Adds a new pointer to the list. |
AddList | Method | public | Add all pointers from another list |
Assign | Method | public | Copy the contents of other lists. |
Capacity | Property | public | Current capacity (i.e. number of pointers that can be stored) of the list. |
Clear | Method | public | Clears the pointer list. |
CopyMove | Method | private | |
Count | Property | public | Current number of pointers in the list. |
Create | Method | public | Class to manage collections of pointers. |
Delete | Method | public | Removes a pointer from the list. |
Destroy | Method | public | Destroys the list and releases the memory used to store the list elements. |
DoAnd | Method | private | |
DoCopy | Method | private | |
DoDestUnique | Method | private | |
DoOr | Method | private | |
DoSrcUnique | Method | private | |
DoXOr | Method | private | |
Error | Method | public | Raises an EListError exception. |
Exchange | Method | public | Exchanges two pointers in the list. |
Expand | Method | public | Increases the capacity of the list if needed. |
Extract | Method | public | Remove the first occurrence of a pointer from the list. |
First | Method | public | Returns the first non-nil pointer in the list. |
FList | Field | private | |
FObservers | Field | private | |
FPOAttachObserver | Method | public | Add an observer to the list of observers |
FPODetachObserver | Method | public | Remove an observer from the list of observers |
FPONotifyObservers | Method | public | Notify observers of changes in the list |
Get | Method | protected | |
GetCapacity | Method | protected | |
GetCount | Method | protected | |
GetEnumerator | Method | public | Create an IEnumerator instance |
GetList | Method | protected | |
Grow | Method | protected | |
IndexOf | Method | public | Returns the index of a given pointer. |
Insert | Method | public | Inserts a new pointer in the list at a given position. |
Items | Property | public | Provides access to the pointers in the list. |
Last | Method | public | Returns the last non-nil pointer in the list. |
List | Property | public | Memory array where pointers are stored. |
MergeMove | Method | private | |
Move | Method | public | Moves a pointer from one position in the list to another. |
Notify | Method | protected | |
Pack | Method | public | Removes Nil pointers from the list and frees unused memory. |
Put | Method | protected | |
Remove | Method | public | Removes a value from the list. |
SetCapacity | Method | protected | |
SetCount | Method | protected | |
Sort | Method | public | Sorts the pointers in the list. |
Inheritance
Class | Description |
---|---|
TList(IFPObserved) | Class to manage collections of pointers. |
See also
Name | Description |
---|---|
Integer | A signed 16-bits integer |
Integer | A signed 16-bits integer |
TCollection | Base class to manage collections of named objects. |
TFPList | Class to manage collections of pointers. |
TFPList | Class to manage collections of pointers. |
TStrings | Class to manage arrays or collections of strings |