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

TCollection.AtDelete

Delete item at certain position.

Declaration

Source position: objects.pp line 417

procedure TCollection.AtDelete(

  Index: Sw_Integer

);

Description

AtDeletedeletes the pointer at position Indexin the collection. It doesn't call the object's destructor.

Errors

If Indexisn't valid then Erroris called with CoIndexError.

See also

TCollection.Delete

  

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

Example

Program ex33;

{ Program to demonstrate the TCollection.AtDelete 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.');
  With C^ do
    While Count>0 do AtDelete(Count-1);
  Writeln ('Freed all objects.');
  Dispose(C,Done);
end.