假如数据库中有一系列数据在delphi程序中经常用到,而且数据本身每分钟不断在新增。
因为频繁用到,我想设计个多维多态数组,用来记录这些数据,即先通过数据库组件取数据,然后赋给数组。这个思路应该是正确的吧?
要解决数据不断新增,就需要设置定时器不断地刷新数据库组件的数据,然后把新数据追加到动态数组,这就会造成不断变更动态数组的长度,想问下这样会明显影响运行效率吗?
因为频繁用到,我想设计个多维多态数组,用来记录这些数据,即先通过数据库组件取数据,然后赋给数组。这个思路应该是正确的吧?
要解决数据不断新增,就需要设置定时器不断地刷新数据库组件的数据,然后把新数据追加到动态数组,这就会造成不断变更动态数组的长度,想问下这样会明显影响运行效率吗?
解决方案 »
- 第3方控件Ehlib3.0和DevExpress QuantumGridSuite3.2.2是否收费?
- 在Delphi中如何将XML中提供的文件进行下载
- 征集一些dephi招聘考试的笔试或机试题目。出题者统统有分。
- 怎样更新数据阿?
- 哪个好心人可以帮我吗?我想用delphi连接.mdb(access文件)。能连接能显示字段内容就可以,可以帮我吗?我不会用delphi的ado
- 怎样可以在win98下得到本机的硬盘序列号?高分请教!
- 版本管理工具VSS哪里有下载
- 100分求解:MIDAS应用服务器方法参数问题
- Install Shield Express哪有载我的盘里的不能用!!
- 谁来帮帮我解决DELPHI构建services application!!!!急
- delphi xe 生成的 webservice 在iis7 出错
- 我很茫然
http://stackoverflow.com/questions/3183851/can-i-resize-a-delphi-array-without-losing-its-previous-contents
10
Just be aware it can be a memory intensive operation, because the whole array could be moved if there is not enough space to extend it where it is allocated. An array, unlike lists, must be allocated in a contiguos memory block. That's why list (and other containers) exist. Use the best container for you needs. – user160694 Jul 6 '10 at 8:28
5
@ldsandon: Be careful: Many "lists" in Delphi are implemented as arrays or at least contiguous memory blocks in exactly the same way as an array "under the hood". TList, TObjectList, TStringList... these most commonly encountered lists are all effectively arrays inside object wrappers. The "Length" of these "arrays" has more flexible management tools than "real" arrays however, as they support both Capacity (size of the "array") and Count (number of elements actually being used) so you can pre-allocate the contiguous memory you need (via Capacity) before filling it. –
这会明显影响运行效率,使用一个成熟的容器,可能比你自己管理内存更为可靠。
动态数组要重新分配内存
不用刷新 数据库组件的数据吧 你是怎么刷新的?
数据一般设有一个自动增加字段ID 把当大于本地最大ID的记录查出来
增加到list (数组)中即可