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

TCollection.DeleteAll

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

Declaration

Source position: objects.pp line 414

procedure TCollection.DeleteAll;

Description

DeleteAll deletes all elements from the collection. It just sets the Count variable to zero. Contrary to FreeAll, DeletAll doesn't call the destructor of the objects.

Errors

None.

See also

TCollection.FreeAll

  

Release all objects from the collection.

TCollection.Delete

  

Delete an item from the collection, but does not destroy it.

Example

Program ex29;

{
 Program to demonstrate the TCollection.DeleteAll method
 Compare with example 28, where FreeAll is used.
}

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^.DeleteAll;
  Writeln ('Deleted all objects.');
  Dispose(C,Done);
end.

Documentation generated on: Mar 17 2017