难道发现Delphi bug了?关于THashedStringlist的问题

ccdarkness 2010-04-05 12:06:16

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IniFiles;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
FCacheConfigList: THashedStringlist;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
t: Cardinal;
i: Integer;
begin
t := GetTickCount;
for i := 0 to 10000 do
FCacheConfigList.Add(IntToStr(i + 1));
FCacheConfigList.Sort;{问题在这里,第一次排序很快,如果再点击一次Button1就排序很耗时,等待大约5分钟以后排序完成,再点击button1就没问题了}
ShowMessage(IntToStr(GetTickCount - t));
ShowMessage(IntToStr(FCacheConfigList.Count));
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
FCacheConfigList := THashedStringlist.Create;
end;

end.



Delphi 2007和Delphi 2010都存在这样的情况,还没有测试TStringList,各位可以试一试
...全文
275 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ccdarkness 2011-05-10
  • 打赏
  • 举报
回复
顶一个
ccdarkness 2010-04-17
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 qiume 的回复:]

FCacheConfigList.Clear;

没有执行上面这一句代码的话,每执行一次,数据都会增长,而且有重复键值,所以......
[/Quote]

是因为有重复的键值问题??
qiume 2010-04-15
  • 打赏
  • 举报
回复
FCacheConfigList.Clear;

没有执行上面这一句代码的话,每执行一次,数据都会增长,而且有重复键值,所以......
zhuang_bx 2010-04-15
  • 打赏
  • 举报
回复
THashedStringlist;
TStringlist;
都有这样的问题

应该不是数据量的问题,因为第二次之后数据量比第二次多,第三,第四.....次就不会这么慢了

不清楚什么原因
superglh 2010-04-05
  • 打赏
  • 举报
回复
加一行


FCacheConfigList.Clear;
ccdarkness 2010-04-05
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zhouzhangkui 的回复:]

http://topic.csdn.net/u/20090807/08/3420b33a-b030-4b28-91d5-17383e48a6c3.html
[/Quote]

这个没说明问题啊,上面没说清楚是怎么回事
wanjianjun 2010-04-05
  • 打赏
  • 举报
回复
THashedStringlist 本身在处理大量数据的时候是很慢的,

TStringList 要好些,

如果数量少的情况下用THashedStringlist ,多的情况下最好用TStringList 。
Delphi 7.1 Update Release Notes=======================================================This file contains important supplemental and late-breakinginformation that may not appear in the main productdocumentation, and supersedes information contained in otherdocuments, including previously installed release notes.Borland recommends that you read this file in its entirety.NOTE: If you are updating a localized version of Delphi 7, visit the Borland Registered User web site to obtain a localized readme file that may contain important late- breaking information not included in this readme file.IMPORTANT: Delphi must be closed before installing this update. =====================================================CONTENTS * INSTALLING THIS UPDATE * UPDATING LOCALIZED VERSIONS OF DELPHI 7 * KNOWN ISSUES * ISSUES ADDRESSED BY THIS UPDATE - IDE - CORE DATABASE - DATASNAP - DBGO (ADO COMPONENTS) - dbExpress - dbExpress COMPONENTS AND DB VCL - dbExpress CORE DRIVER AND METADATA - dbExpress VENDOR ISSUES - dbExpress CERTIFICATION - WEB SNAP - ACTIVEX - COMPILER - RTL - VCL - THIRD PARTY - BOLD FOR DELPHI * VERIFYING THAT THE UPDATE WAS SUCCESSFUL * FILES INSTALLED BY THIS UPDATE =======================================================INSTALLING THIS UPDATE* This update can not be applied to Delphi 7 Architect Trial version. * This update can not be removed after it is installed.* You will need the original Delphi 7 installation CD available to install this update.* To install this update from the CD, insert the CD, and launch the d7_ent_upd1.exe file appropriate for your locale.* To install this update from the Web, double-click the self-executing installation file and follow the prompts. * The Delphi 7 documentation PDF files are available on the update CD.========================================================UPDATING LOCALIZED VERSIONS OF DELPHI 7* This update can be applied only to the English version of Delphi 7. There are separate updates for the German, French and Japanese ver

16,747

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧