Intro to Generic Collections with Delphi 2009
A very short introduction to Generic Collections in Delphi 2009. Create a TList of Integers and show adding and removing items from it. Showing some of the differences in types, gotchas and errors you might get.
Generics, or parametrized types, are a type that works with another type that is defined later. Collections are a great example of using them. You create a generic TList, and then when you use it you declare what type it will contain. Then it will be strongly typed to that specific type, both in adding items and removing them.
Delphi Generics work with all types in Delphi: native types (Integer, string, etc.), Records, Objects and Interfaces.
- Episode 2 – Intro to Generic Collections with Delphi 2009
- [NOTE: Run full screen, in HD with Scaling off. It should display at 1280x720.]
This is screen cast episode 2, shot with Camtasia and hosted on Vimeo. I had to shoot it at 1280×720 so they will offer it in HD and not downscale it. Let me know how it works for everyone.
As was pointed out in the comments, the download link only works after you sign into Vimeo. If that doesn’t work for people let me know and I will come up with a different solution.









September 26th, 2008 at 12:39 pm
Great introduction ! I’m waiting for the next one
September 26th, 2008 at 1:48 pm
Great video
It was great to see it in HD – works well for me.
September 26th, 2008 at 2:30 pm
Will this be downloadable like the previous screencast?
September 26th, 2008 at 4:35 pm
Once you join Vimeo (free signup), a download link is available.
October 2nd, 2008 at 10:06 am
Great podcast… but leaves me wanting to know if you create a generic list of TObjects, and call the sort method, what magic allows them to sort?
October 6th, 2008 at 4:43 pm
Great podcast – thanks!
October 7th, 2008 at 9:49 am
When you are sorting a “non-standard” type then you provide an IComparer via the overloaded constructor:
constructor Create(const AComparer: IComparer); overload;
Maybe I will demo that later.
October 22nd, 2008 at 6:32 pm
Awesome video, thanks Jim!
March 14th, 2009 at 5:21 pm
Great video, thanks. I was looking for info about Generics, this is great!
August 5th, 2009 at 8:04 pm
wow. what a great video. a great function. i’ve spent hours creating descendants of tlists for integers and other types.