Tutorial :Generic Linked List for Delphi 2009


I was looking in Generics.Collections and noticed there was no linked list. Sure they are simple to make, but I thought it was odd there was not one (or I just missed it). Are linked lists just outdated when compared to new modern data structures, or is there a need for a general generic linked list? Does anyone know of one?


Do you know the DeHL?

I think the TLinkedList<T> from the DeHL.Collections.LinkedList.pas unit is exactly what you are looking for.


In the old days, almost any piece of serious software contained linked lists or trees.

I haven't used linked lists alot, but trees are another story.

With the introduction of dynamic arrays, there is not that much need for linked lists. But I can imagine that you want to use it if your datastructure is changed often (add + delete).

You can easily create a generic linked list yourself, using a container class and records for the elements.


I don't know of any generic, linked list in the existing Delphi RTL.

They are still very useful as a data structure, however. Especially if you include variants on a linked list such as a b-tree or a binary tree. Unlike a regular list, a linked list can be expanded, edited, or modified without moving data in memory. They are very easy to version, and work well in purely functional code which does not allow mutating existing data. So it is still a very useful data structure.


Isn't that what tStringList is for?


Actually, any generic tList works fine as a linked list, and supplies most of the functionality needed. The ancient technique passed down from our ancestors of storing a pointer to memory in each record, and navigating to that has been easily replaced by dynamic arrays and doing things...more generically.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »