// archives

Generics

This tag is associated with 6 posts

Generic Interfaces in Delphi

Most of the examples I’ve seen of Generics in Delphi use classes containing a generic type. However, while working on a personal project, I decided I wanted an Interface containing a generic type.
The project uses an in-process publish/subscribe mechanism, and I wanted a subscriber to have a separate Receive method for each event type, [...]

Storing code in a collection : TDictionary and Anonymous Methods

In my earlier post, I mentioned you could use the new generic collection classes in Delphi 2009 to store anonymous methods instead of data. I wanted to try this out so I came up with the scenario of implementing factory classes as an excuse to experiment.
Factories can be a very useful way to centralise [...]

A TDictionary explanation

On the recent Delphi 2009 roadshow in Australia, I had a few people ask me about the new TDictionary<TKey, TValue> container in Generics.Collections. If you haven’t played with it yet,  Roland Beenhakker has a nice write up on using it, but most of the questions I was getting were not about how to use [...]

Delphi 2009 : TQueue<T>.Dequeue vs TObjectQueue<T>.Dequeue

I was poking around inside Generics.Collections the other day while writing some code for a future post on pooling, and I came up against something puzzling.
Generics.Collections has a class called TQueue<T>, which is a generic version of the classic first-in-first-out datastructure. The nice thing of course is that it can now be made type-safe [...]

Anonymous Methods, Generics and Enumerators

I’ve been playing around with Anonymous Methods in Delphi 2009 a little bit lately, and I thought one of my experiments might be worth sharing.
I decided I would try to extend TList<T> so that when you enumerate over it in a for..in loop, not every item would be returned. Specifically, only items that passed [...]

Nullable Types in Delphi

I was traveling a bunch over the last two weeks, USA, Japan and Korea. In Osaka, I did a session on Generics for the Japan Developer Camp.
Afterwards, I was having a further play with Highlander and Generics and stumbled across something rather nice. Maybe everyone else is aware of this already, but the new Generics [...]

Subscribe to RSS Follow on Twitter Connect on LinkedIn Connect on Facebook Subscribe on YouTube Subscribe on iTunes

Recent Tweets

This is a personal website. As such, any opinions expressed are my own, and do not necessarily represent the views of my employer, Embarcadero Technologies.