Generic Linked List for Delphi 2009

前端 未结 4 1289
南笙
南笙 2021-01-19 09:16

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).

相关标签:
4条回答
  • 2021-01-19 09:31

    Isn't that what tStringList is for?

    (ducking)

    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.

    0 讨论(0)
  • 2021-01-19 09:34

    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.

    0 讨论(0)
  • 2021-01-19 09:35

    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.

    0 讨论(0)
  • 2021-01-19 09:53

    Do you know the DeHL?

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

    0 讨论(0)
提交回复
热议问题