Skip to content

TFPList

Class to manage collections of pointers.

Declaration

Source position: classesh.inc line 505

type

  TFPList = class(TObject)
  public
    TDirection = (FromBeginning,FromEnd);
    destructor Destroy;
    procedure AddList;
    function Add : Integer;
    procedure Clear;
    procedure Delete;
    class procedure Error;
    procedure Exchange;
    function Expand : TFPList;
    function Extract : Pointer;
    function First : Pointer;
    function GetEnumerator : TFPListEnumerator;
    function Contains : Boolean;
    function IndexOf : Integer;
    function IndexOfItem : Integer;
    procedure Insert;
    function Last : Pointer;
    procedure Move;
    procedure Assign;
    function Remove : 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);
    property Capacity: Integer; {rw}
    property Count: Integer; {rw}
    property Items[Index : Integer]: Pointer; {rw}
    property List: PPointerList; {r}
  end;

Inheritance

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.

Properties

Member Visibility Description
Capacity public Current capacity (i.e. number of pointers that can be stored) of the list.
Count public Current number of pointers in the list.
Items public Provides access to the pointers in the list.
List read only public Memory array where pointers are stored.
See all Properties

Methods

Member Visibility Description
Add public Adds a new pointer to the list.
AddList public Add all pointers from another list.
Assign public Assign performs the given operation on the list.
Clear public Clears the pointer list.
Contains public
Delete public Removes a pointer from the list.
Destroy public Destroys the list and releases the memory used to store the list elements.
Error public Raises an EListError exception.
Exchange public Exchanges two pointers in the list.
Expand public Increases the capacity of the list if needed.
Extract public Remove the first occurrence of a pointer from the list.
First public Returns the first non-nil pointer in the list.
ForEachCall public Call a procedure or method for each pointer in the list.
GetEnumerator public Create an IEnumerator instance.
IndexOf public Returns the index of a given pointer.
IndexOfItem public Search an item in the list.
Insert public Inserts a new pointer in the list at a given position.
Last public Returns the last non-nil pointer in the list.
Move public Moves a pointer from one position in the list to another.
Pack public Removes Nil pointers from the list and frees unused memory.
Remove public Removes a value from the list.
Sort public Sorts the pointers in the list.
See all Methods

See also

Name Description
TStrings Class to manage arrays or collections of strings.
TCollection Base class to manage collections of named objects.