cltnhash.pas

来自「《Delphi技术手册源码》原书佩戴的光盘」· PAS 代码 · 共 28 行

PAS
28
字号
unit CltnHash;

(*
  Hash tables.
  The hash tables implement the ISet and IMap interfaces, using a closed
  hash table as the implementation. Items with the same hash value are
  stored in a dynamic, unordered array.

  A possible performance improvement if you know that the trees
  are truly ordered is to use a TSortedList instead of TArrayList.
  Changing a linear search to a binary search can help speed up
  access if the hash table faces many collisions and is densely packed.
  I haven't done this because a hash table that does not face
  heavy collisions doesn't need the additional overhead. More important
  is that as currently implemented, one can use a hash table to
  store objects that don't really have a defined order. Yes, they
  must implement ICollectible, but sometimes, only a comparison for
  equality is meaningful. In that case, a hash table is more suitable
  than, say, a tree.

  The programmer can set the treshold percentage. When the count/capacity
  ratio reaches the threshold, the hash table grows.

  The hash table implementation uses a TList for the main hash table.
  Each element of the list is either nil or another TList. The sublist
  contains the actual ICollectible items.
  
  Copyright 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?