|
What would be the best way to hold an enumeration of record type?
Should I declare them as a Tobject instead of record and then keep them in a TList?
Jay
-----Original
Message-----
Looks okay to me. Although you don't really need the Remove() and IndexOf() methods, as these just call the TList methods anyway.
Also, GetPic() could just call the inherited Get() method and cast the result as TPicture. In your GetPic() and PutPic() methods there's no need to cast with the Pointer type as TPicture is just a pointer anyway.
eg. procedure TPics.PutPic(index: Integer; Pic: TPicture); begin inherited Put(index, Pic); end;
function TPics.GetPic(index: Integer): TPicture; begin result := TPicture(inherited Get(index)); end;
Personally, I think the Put() method is very scary, since it can easily lead to memory leaks when the list holds the only pointer to an object. In other words, I usually make the Items property read only.
Cheers, Todd.
|
- [DUG]: Using TList Jason Coley
- Re: [DUG]: Using TList Todd Martin
- Re: Re: [DUG]: Using TList Jason Coley
- Re: Re: [DUG]: Using TList Paul Mckenzie
- RE: Re: [DUG]: Using TList Jason Coley
- Re: Re: [DUG]: Using TList Todd Martin
- RE: Re: [DUG]: Using TList David Brennan
