Creates a resizable list for object references.
Delphi
class function CreateObjectList<T: class>(OwnsObjects: Boolean = True): IList<T>; static;
Type Parameters
- T
The type of objects in the list.
Parameters
- OwnsObjects
- Boolean
True to free objects when they are removed, deleted, cleared, or when the list is destroyed; otherwise, false.
Returns
IList<T>
A new IList<T> instance for object references.
Use this factory when the returned IList<T> should own the lifetime of the objects it contains. Assigning a new value through IList<T>.Items does not free the object being replaced.
delphi
var
Items: IList<TObject>;
begin
Items := TCollections.CreateObjectList<TObject>(True);
Items.Add(TObject.Create);
Items.Clear;
end;