本文介绍了有什么优点和使用记录与从TList&LT动态数组的利弊; TMyRecord>在德尔福?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是为了产生德尔福优点和不同的数据存储方式利弊一个查找列表中的理论问题。
This is a theoretical question intended to generate a look-up list of pros and cons of different data storage ways in Delphi.
让我们说我们有一个记录:
Let's say we have a record:
type
TMyRecord = record
X,Y,Z: Single;
IsValid: Boolean;
end;
存储这些记录阵列的基本选项是:
Basic options of storing an array of such records are:
-
TMyRecord的阵列;
-
从TList
用的getter / setter定制后裔 -
&的TList LT; TMyRecord取代;
array of TMyRecord;
- custom descendant of
TList
with getter/setter TList<TMyRecord>;
我对#1#VS 3比较特别感兴趣,有多少是那些之间的差异,尤其是性能明智的。
I'm specifically interested about #1 vs #3 comparison, how much is the difference between those, especially performance-wise.
推荐答案
&的TList LT; T&GT;
优点:
- 时,没有必要。 删除 when not needed.
- System.Generics.Collections unit could add plenty of binary size to a project that wasn't using System.Classes unit before.
至于我自己,我写了 TRecordList&LT; T&GT;
这工作项目,如指针(如经典做的TList)班
For myself I wrote TRecordList<T>
class which operates items as pointers (like classic TList does).
这篇关于有什么优点和使用记录与从TList&LT动态数组的利弊; TMyRecord&GT;在德尔福?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!