TFPList

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

Class to manage collections of pointers.

Declaration

Source position: classesh.inc line 217

Type
  TFPList = class (TObject)
  private
    FList : PPointerList;
    FCount : Integer;
    FCapacity : Integer;
    procedure CopyMove(aList: TFPList);
    procedure MergeMove(aList: TFPList);
    procedure DoCopy(ListA: TFPList; ListB: TFPList);
    procedure DoSrcUnique(ListA: TFPList; ListB: TFPList);
    procedure DoAnd(ListA: TFPList; ListB: TFPList);
    procedure DoDestUnique(ListA: TFPList; ListB: TFPList);
    procedure DoOr(ListA: TFPList; ListB: TFPList);
    procedure DoXOr(ListA: TFPList; ListB: TFPList);
  protected
    function Get(Index: Integer) : Pointer;
    procedure Put(Index: Integer; Item: Pointer);
    procedure SetCapacity(NewCapacity: Integer);
    procedure SetCount(NewCount: Integer);
    procedure RaiseIndexError(Index: Integer);
    procedure CheckIndex(AIndex: Integer);
  public
    TDirection = (FromBeginning,FromEnd);
    destructor Destroy;  Override;
    procedure AddList(AList: TFPList);
    function Add(Item: Pointer) : Integer;
    procedure Clear;
    procedure Delete(Index: Integer);
    class procedure Error(const Msg: string; Data: PtrInt);  Static;
    procedure Exchange(Index1: Integer; Index2: Integer);
    function Expand : TFPList;
    function Extract(Item: Pointer) : Pointer;
    function First : Pointer;
    function GetEnumerator : TFPListEnumerator;
    function IndexOf(Item: Pointer) : Integer;
    function IndexOfItem(Item: Pointer; Direction: TDirection) : Integer;
    procedure Insert(Index: Integer; Item: Pointer);
    function Last : Pointer;
    procedure Move(CurIndex: Integer; NewIndex: Integer);
    procedure Assign(ListA: TFPList; AOperator: TListAssignOp; 
                    ListB: TFPList);
    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);
    procedure ForEachCall(proc2call: TListCallback; arg: pointer);
    procedure ForEachCall(proc2call: TListStaticCallback; arg: pointer);
    Capacity : Integer;
    Count : Integer;
    Items[Index: Integer]: Pointer; default;
    List : PPointerList;
  end
  ;

Description

TFPList 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. Contrary to TList , TFPList has no notification mechanism. If no notification mechanism is used, it is better to use TFPList instead of TList, as the performance of TFPList is much higher.

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 Assign performs the given operation on the list.
Capacity Property public Current capacity (i.e. number of pointers that can be stored) of the list.
CheckIndex Method protected
Clear Method public Clears the pointer list.
CopyMove Method private
Count Property public Current number of pointers in the list.
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.
FCapacity Field private
FCount Field private
First Method public Returns the first non-nil pointer in the list.
FList Field private
ForEachCall Method public Call a procedure or method for each pointer in the list.
Get Method protected
GetEnumerator Method public Create an IEnumerator instance
IndexOf Method public Returns the index of a given pointer.
IndexOfItem Method public Search an item in the list
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.
Pack Method public Removes Nil pointers from the list and frees unused memory.
Put Method protected
RaiseIndexError 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.
TDirection Type public Search direction for IndexOfItem

Inheritance

Class Description
TFPList Class to manage collections of pointers.

See also

Name Description
Integer A signed 16-bits integer
Integer A signed 16-bits integer
Integer A signed 16-bits integer
Integer A signed 16-bits integer
TCollection Base class to manage collections of named objects.
TStrings Class to manage arrays or collections of strings