System.Contnrs.TObjectList.Remove

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function Remove(AObject: TObject): NativeInt; overload; inline;

C++

HIDESBASE System::NativeInt __fastcall Remove(System::TObject* AObject)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.Contnrs.pas
System.Contnrs.hpp
System.Contnrs TObjectList

Description

Removes a specified object from the list and (if OwnsObjects is true) frees the object.

Call Remove to delete a specific object from the list when its index is unknown. The value returned is the index of the object in the Items array before it was removed. If the specified object is not found on the list, Remove returns –1. If OwnsObjects is true, Remove frees the object in addition to removing it from the list.

After an object is deleted, all the objects that follow it are moved up in index position and Count is decremented. If an object appears more than once on the list, Remove deletes only the first appearance. Hence, if OwnsObjects is true, removing an object that appears more than once results in empty object references later in the list.

To use an index position (rather than an object reference) to specify the object to be removed, call Delete.

To remove an object from the list without freeing it, call Extract.

See Also