Generics with Delphi 2009 Win32
With, as a bonus, anonymous routines and routine references
Date de publication : November 13th, 2008
We have been waiting for them for a while! Now they are here: generics in Delphi Win32. Those little awesome things are coming with Delphi 2009. This tutorial will help you understand and use them, and design your own generic classes.
This is a translation of a tutorial initially written in French: Les génériques avec Delphi 2009 Win32. I have translated my own tutorial, but I am no perfect English speeker. I therefore apologize for all the mistakes I certainly did in this translation.
Juan Badell has also translated this tutorial into Spanish: Los genéricos en Delphi 2009 (HTTP mirror)
Aleksey Timohin has also made a translation into Russian.
This translation may be read in PDF form, which was built by Andrew Tishkin (HTTP mirror).
I-B. What are generics?
II. Daily usage: the example of TList<T>
II-A. A simple code to start with
II-B. Assignments between generic classes
II-C. Methods of TList<T>
II-D. TList<T> and comparers
II-D-1. Writing a comparer using TComparer<T>
II-D-2. Writing a comparer using a simple comparison function
Design of a generic class
III. Design of a generic class
III-A. Class declaration
III-B. Implementing a method
III-C. The pseudo-routine Default
III-D. Routine references with tree walks
III-D-1. Other methods using anonymous routines?
III-E. And the rest
III-F. How to use TTreeNode<T> ?
Design of a generic record
IV. Design of a generic record
More with generics: constraints, several parameters
V. Contraints on generic types
V-A. What are the available constraints?
V-B. But what is the purpose of it?
V-C. A variant with constructor
VI. Parameterizing with more than on type
VII. Other generic types
VIII. Generic methods
VIII-A. A generic Min function
VIII-B. Overloading and constraints
VIII-C. Some extras for TList<T>
RTTI and generics
IX. RTTI and generics
IX-A. Changes to the pseudo-routine TypeInfo
IX-A-1. A more general TypeInfo function
IX-B. Do generic types have RTTI?
XI. Download the sources
Warning: include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/developpez/www/developpez-com/upload/sjrd/delphi/tutoriel/generics/index.php on line 41
Warning: include(http://sjrd.developpez.com/references.inc) [function.include]: failed to open stream: no suitable wrapper could be found in /home/developpez/www/developpez-com/upload/sjrd/delphi/tutoriel/generics/index.php on line 41
Warning: include() [function.include]: Failed opening 'http://sjrd.developpez.com/references.inc' for inclusion (include_path='.:/usr/php53/lib/php') in /home/developpez/www/developpez-com/upload/sjrd/delphi/tutoriel/generics/index.php on line 41
Copyright © 2008-2009 Sébastien Doeraene. Aucune reproduction, même partielle, ne peut être faite de ce site ni de l'ensemble de son contenu : textes, documents, images, etc. sans l'autorisation expresse de l'auteur. Sinon vous encourez selon la loi jusqu'à trois ans de prison et jusqu'à 300 000 € de dommages et intérêts.