[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'contnrs' (#fcl)

# TFPCustomHashTable

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Hash class

## Declaration

Source position: contnrs.pp line 352

`type TFPCustomHashTable = class(TObject)`
`protected`
`function Chain();`
`function CreateNewNode(); virtual; abstract;`
`procedure AddNode(); virtual; abstract;`
`function ChainLength(); virtual;`
`function FindOrCreateNew(); virtual;`
`procedure SetHashFunction(); virtual;`
`function FindChainForAdd();`
`public`
`constructor Create;` |  | Instantiate a new TFPCustomHashTable instance using the default hash mechanism
`constructor CreateWith();` |  | Instantiate a new TFPCustomHashTable instance with given algorithm and size
`destructor Destroy; override;` |  | Free the hash table.
`procedure ChangeTableSize(); virtual;` |  | Change the table size of the hash table.
`procedure Clear; virtual;` |  | Clear the hash table.
`procedure Delete(); virtual;` |  | Delete a key from the hash list.
`function Find();` |  | Search for an item with a certain key value.
`function IsEmpty;` |  | Check if the hash table is empty.
`property HashFunction: THashFunction; [rw]` |  | Hash function currently in use
`property Count: LongWord; [r]` |  | Number of items in the hash table.
`property HashTableSize: LongWord; [rw]` |  | Size of the hash table
`property HashTable: TFPObjectList; [r]` |  | Hash table instance
`property VoidSlots: LongWord; [r]` |  | Number of empty slots in the hash table.
`property LoadFactor: double; [r]` |  | Fraction of count versus size
`property AVGChainLen: double; [r]` |  | Average chain length
`property MaxChainLength: LongWord; [r]` |  | Maximum chain length
`property NumberOfCollisions: LongWord; [r]` |  | Number of extra items
`property Density: LongWord; [r]` |  | Number of filled slots
`end;`

## Inheritance

`TFPCustomHashTable` |  | Hash class
`TObject`

## 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.

A TFPHasList should be used when fast lookup of data based on some key is required. The other container objects only offer linear search methods, while the hash list offers faster search mechanisms.

## See also

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

The latest version of this document can be found at lazarus-ccr.sourceforge.net .