Free an item at the indicates position, calling it's destructor.
Source position: objects.pp line 463
procedure TCollection.AtFree( |
Index: Sw_Integer |
); |
AtFree deletes the item at position Index in the collection, and calls the item's destructor if it is not Nil.
If Index isn't valid then Error is called with CoIndexError.
|
Free item from collection, calling it's destructor. |
|
|
Delete item at certain position. |
Program ex32; { Program to demonstrate the TCollection.AtFree method } Uses Objects,MyObject; { For TMyObject definition and registration } Var C : PCollection; M : PMyObject; I : Longint; begin Randomize; C:=New(PCollection,Init(120,10)); or:=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 AtFree(Count-1); Writeln ('Freed all objects.'); Dispose(C,Done); end.