我用TCnStrToPtrHashMap和TCnHashTableBig测试了一下,代码如下:
var
time,i:Cardinal;
hash:TCnStrToPtrHashMap;
begin
hash := TCnStrToPtrHashMap.Create();
time := GetTickCount;
for i := 0 to 9000000 do
begin
hash.Add(IntToStr(i),TObject(i));
end;
btn1.Caption := IntToStr(GetTickCount - time);
var
time,i:Cardinal;
hash:TCnHashTableBig;
begin
hash := TCnHashTableBig.Create(9000000 ); //如果我这个初始化9000000 就提示内存超出,小一点的数值是可以,不过好像最大就1百多万
time := GetTickCount;
for i := 0 to 9000000 do
begin
hash.put(IntToStr(i),TObject(i));
end;
btn1.Caption := IntToStr(GetTickCount - time);