[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Objects' (#rtl)

TCollection.FreeAll

Release all objects from the collection.

Declaration

Source position: objects.pp line 418

procedure TCollection.FreeAll;

Description

FreeAll calls the destructor of each object in the collection. It doesn't release any memory occupied by the collection itself, but it does set Count to zero.

See also

TCollection.DeleteAll

  

Delete all elements from the collection. Objects are not destroyed.

TCollection.FreeItem

  

Destroy a non-nil item.

Example

Program ex28;

{ Program to demonstrate the TCollection.FreeAll method }

Uses Objects,MyObject; { For TMyObject definition and registration }

Var C : PCollection;
    M : PMyObject;
    I : Longint;

begin
  Randomize;
  C:=New(PCollection,Init(120,10));
  For I:=1 to 100 do
    begin
    M:=New(PMyObject,Init);
    M^.SetField(I-1);
    C^.Insert(M);
    end;
  Writeln ('Added 100 Items.');
  C^.FreeAll;
  Writeln ('Freed all objects.');
  Dispose(C,Done);
end.

Documentation generated on: Jun 22 2020