Board index » delphi » TList.Delete

TList.Delete

Hi,

I would like to know if TList.Delete removes the entry as well as the
object referred by that entry.

example:

    list := TList.Create;
    obj := TSomeObject.Create;
    TList.Add(obj);
    TList.Delete(0);
    (* is obj at this position still valid or does it now point to an
already destroyed object? *)

...and if Delete destroys the referred objects as well, I wonder what
does Count do?

Is a list.Count :=0 equal to destroying all referred objects as well as
the pointer in list? Or do I have to destroy them manually before
I set the list.Count to zero?

The help pages in D3 on TList are somewhat confusing on that topic (at
least in German).

Thanks for help,

Jens

 

Re:TList.Delete


Quote
"Jens Reinhardt" <jreinha...@foni.net> wrote in message

news:39D0C910.78E91DCA@foni.net...

Quote
> Hi,

> I would like to know if TList.Delete removes the entry as well as the
> object referred by that entry.

No, the Delete removes only the entry in the TList, it does not destroy the
actual referenced object. That is done separately.

Woody

Re:TList.Delete


Quote
In article <39D0C910.78E91...@foni.net>, Jens Reinhardt wrote:
> I would like to know if TList.Delete removes the entry as well as the
> object referred by that entry.

No it doesn't.

 Mike Orriss (TeamB & Developer Express)
 (Unless stated otherwise, my replies relate to Delphi 5)
 (No unsolicited e-mail replies please)

Re:TList.Delete


Quote
woody wrote:

> "Jens Reinhardt" <jreinha...@foni.net> wrote in message
> news:39D0C910.78E91DCA@foni.net...
> > Hi,

> > I would like to know if TList.Delete removes the entry as well as the
> > object referred by that entry.

> No, the Delete removes only the entry in the TList, it does not destroy the
> actual referenced object. That is done separately.

        However, if this is the behavior that you *want* you can use
TObjectList instead.

        HTH,

        -Craig

--
Craig Stuntz            Vertex Systems Corporation
Senior Developer        http://www.vertexsoftware.com

Re:TList.Delete


In article <39D0F633.52760425@no_spam.vertexsoftware.com>, Craig Stuntz
wrote:

Quote
> However, if this is the behavior that you *want* you can use
> TObjectList instead.

I was going to mention this until I noticed that Jens is using D3 <g>

 Mike Orriss (TeamB & Developer Express)
 (Unless stated otherwise, my replies relate to Delphi 5)
 (No unsolicited e-mail replies please)

Re:TList.Delete


Quote
"Mike Orriss (TeamB)" wrote:

> In article <39D0F633.52760425@no_spam.vertexsoftware.com>, Craig Stuntz
> wrote:
> > However, if this is the behavior that you *want* you can use
> > TObjectList instead.

> I was going to mention this until I noticed that Jens is using D3 <g>

        Oops.  I didn't notice that.  Jens, TObjectList is a new feature in D5.

        -Craig

--
Craig Stuntz            Vertex Systems Corporation
Senior Developer        http://www.vertexsoftware.com

Re:TList.Delete


Quote

> > I was going to mention this until I noticed that Jens is using D3 <g>

>         Oops.  I didn't notice that.  Jens, TObjectList is a new feature in D5.

Okay, in other words: I'll free them manually for this project and take a closer
look at D5 for future projects.

Thanks,

Jens

Other Threads