CnPack Forum » CnVCL 组件包 » HashMap 建议


2018-11-6 11:03 wuyou
HashMap 建议

建议将 FList: array of TCnHashMapRec;
移到 protected
使得继承的类可以输出 FList 列表,不需要每次都跑 GetNext,这不是线程安全的

TWgs = array of TWg;

function TWgMap.GetList: TWgs;
var
  i,j: Integer;
begin
  SetLength(Result, Size);
  j := 0;

  for I := Low(FList) to High(FList) do begin
    if FList[i].HashCode < 0 then Continue;

    Result[j] := PWg(Pointer(Integer(FList[i].Value)))^;
    inc(j);
  end;
end;

[[i] 本帖最后由 wuyou 于 2018-11-6 11:20 编辑 [/i]]

2018-11-6 22:45 Passion
您的建议有道理,我们已将FList移动至protected节,git上的cnvcl代码已更新。:handshake

页: [1]
查看完整版本: HashMap 建议


Powered by Discuz! Archiver 5.0.0  © 2001-2006 Comsenz Inc.