Skip to content

TCollection

Base class to manage collections of named objects.

Declaration

Source position: classesh.inc line 919

type

  TCollection = class(TPersistent)
  public
    constructor Create;
    destructor Destroy;
    function Owner : TPersistent;
    function Add : TCollectionItem;
    procedure Assign;
    procedure BeginUpdate;
    procedure Clear;
    procedure EndUpdate;
    procedure Delete;
    function GetEnumerator : TCollectionEnumerator;
    function GetNamePath : string;
    function Insert : TCollectionItem;
    function FindItemID : TCollectionItem;
    procedure Exchange;
    procedure Move;
    procedure Sort(const Compare: TCollectionSortCompare);
    procedure Sort(const Compare: TCollectionSortCompare_Context; 
              Context: Pointer);
    property Count: Integer; {r}
    property ItemClass: TCollectionItemClass; {r}
    property Items[Index : Integer]: TCollectionItem; {rw}
  end;

Description

TCollection implements functionality to manage a collection of named objects. Each of these objects needs to be a descendant of the TCollectionItem class. Exactly which type of object is managed can be seen from the TCollection.ItemClass property.

Normally, no TCollection is created directly. Instead, a descendants of TCollection and TCollectionItem are created as a pair.

Properties

Member Visibility Description
Count read only public Number of items in the collection.
ItemClass read only public Class pointer for each item in the collection.
Items public Indexed array of items in the collection.
See all Properties

Methods

Member Visibility Description
Add public Creates and adds a new item to the collection.
Assign public Assigns one collection to another.
BeginUpdate public Start an update batch.
Clear public Removes all items from the collection.
Create public Creates a new collection.
Delete public Delete an item from the collection.
Destroy public Destroys the collection and frees all the objects it manages.
EndUpdate public Ends an update batch.
Exchange public Exchange 2 items in the collection.
FindItemID public Searches for an Item in the collection, based on its TCollectionItem.ID property.
GetEnumerator public Create an IEnumerator instance.
GetNamePath public Overrides TPersistent.GetNamePath to return a proper pathname.
Insert public Insert an item in the collection.
Move public Move an item in the collection.
Owner public Owner of the collection.
Sort public Sort the items in the collection.
See all Methods

See also

Name Description
TCollectionItem Basic object that is managed by a TCollection class.