Skip to content

TFPCustomHashTable

Hash class.

Declaration

Source position: contnrs.pp line 371

type

  TFPCustomHashTable = class(TObject)
  public
    constructor Create;
    constructor CreateWith;
    destructor Destroy;
    procedure ChangeTableSize;
    procedure Clear;
    procedure Delete;
    function Find : THTCustomNode;
    function IsEmpty : Boolean;
    property HashFunction: THashFunction; {rw}
    property Count: LongWord; {r}
    property HashTableSize: LongWord; {rw}
    property HashTable: TFPObjectList; {r}
    property VoidSlots: LongWord; {r}
    property LoadFactor: Double; {r}
    property AVGChainLen: Double; {r}
    property MaxChainLength: LongWord; {r}
    property NumberOfCollisions: LongWord; {r}
    property Density: LongWord; {r}
  end;

Description

TFPCustomHashTable is a general-purpose hashing class. It can store string keys and pointers associated with these strings. The hash mechanism is configurable and can be optionally be specified when a new instance of the class is created; A default hash mechanism is implemented in RSHash.

The TFPHashList can also be used when fast lookup of data based on some key is required. It is slightly faster than the TFPCustomHashTable implementation, but the keys are limited to a length of 256 characters, and it is not suitable for re-use: it is a one-time fill, many times search object. TFPCustomHashTable is slower, but handles re-use better.

Properties

Member Visibility Description
AVGChainLen read only public Average chain length.
Count read only public Number of items in the hash table.
Density read only public Number of filled slots.
HashFunction public Hash function currently in use.
HashTable read only public Hash table instance.
HashTableSize public Size of the hash table.
LoadFactor read only public Fraction of count versus size.
MaxChainLength read only public Maximum chain length.
NumberOfCollisions read only public Number of extra items.
VoidSlots read only public Number of empty slots in the hash table.
See all Properties

Methods

Member Visibility Description
ChangeTableSize public Change the table size of the hash table.
Clear public Clear the hash table.
Create public Instantiate a new TFPCustomHashTable instance using the default hash mechanism.
CreateWith public Instantiate a new TFPCustomHashTable instance with given algorithm and size.
Delete public Delete a key from the hash list.
Destroy public Free the hash table.
Find public Search for an item with a certain key value.
IsEmpty public Check if the hash table is empty.
See all Methods

See also

Name Description
THTCustomNode Single item in the hash table.
TFPObjectList TFPList descendent which manages objects.
RSHash Standard hash value calculating function.