I often use extenders of TList: TList<SomeClass1>
, TList<SomeClass2>
etc.
Almost every time there's a need to empty them, deleting all the objects they store.
I do it by writing a specific procedure for every specific TList. For example:
while Dirs.Count > 0 do
begin
Dirs.Items[0].Free;
Dirs.Delete(0);
end;
Is there a way to code a universal procedure? Something like this:
procedure EmptyAList(_List : TClass; _Object : TClass);
begin
_Object(_List.Items[0]).Free;
_List.Delete(0);
end;
Or anything of the kind.