TList<T>
pros:
- Array doesn't have useful methods for adding/inserting/deleting/sorting/searching, TList does.
- TList has Notify method that could be overriden to perform some custom actions on item addition/deletion.
TList<T>
cons:
TList<T>[i]
actually returns a copy of its element. So you can't write something likeTList<TMyRec>[idx].SomeField := foo
. Instead, you have to use temporary variable. Array obviously allows such expression. David Heffernan mentionedTList<T>.List
which eliminates this drawback; however, it appeared only in XE3- TList is an object which should be deleted
at program finishwhen not needed. - System.Generics.Collections unit could add plenty of binary size to a project that wasn't using System.Classes unit before.
For myself I wrote TRecordList<T>
class which operates items as pointers (like classic TList does).