Units
Classes, Interfaces, Objects
Types
Variables
Constants
Functions, Procedures
Identifiers

Unit rjExDictHash

Description

Dictionary and Hash container base classes and functions.

Dictionary and Hash containers store and manipulate their Items by reference to a Key. This Key could be of any type: Strings, Numbers, or blocks of memory. In the rjExContainers Library, Dictionary containers store their Keys a variable-length strings, while Hash containers handle fixed-length Keys.

Both Dictionary and Hash containers implement the same, fast lookup mechanism called hashing: First, a hashing function (see OnHashKey) calculates a numberic representation of a Key. Based on this hash value, the Key can then be instantly located in the container.

Hashing is one of the fastest methods available for searching if all Items fit into memory.

Classes, interfaces and objects

NameDescription
Class TExAbstractDictHash Abstract base class for Dictionary and Hash containers.

Functions and procedures

Overview

function AnsiBufferHashCI(const Buffer: Pointer; const BufferLength: Cardinal): Cardinal;
function AnsiBufferHashCS(const Buffer: Pointer; const BufferLength: Cardinal): Cardinal;
function AnsiHashCI(const s: AnsiString): Cardinal;
function AnsiHashCS(const s: AnsiString): Cardinal;

Description

function AnsiBufferHashCI(const Buffer: Pointer; const BufferLength: Cardinal): Cardinal;

Calculates a hash value for a Buffer pointet to by Buffer with the length of BufferLength. AnsiBufferHashCI is case insensitive.

function AnsiBufferHashCS(const Buffer: Pointer; const BufferLength: Cardinal): Cardinal;

Calculates a hash value for a Buffer pointet to by Buffer with the length of BufferLength. AnsiBufferHashCS is case sensitive.

function AnsiHashCI(const s: AnsiString): Cardinal;

Calculates a hash value for an AnsiString. AnsiHashCI is case insensitive.

function AnsiHashCS(const s: AnsiString): Cardinal;

Calculates a hash value for an AnsiString. AnsiHashCS is case sensitive.

Types

NameDescription
TExHashKeyFunc function(const Key: Pointer; const KeySize: Cardinal): Cardinal;
TExSameKeysFunc function(const Key1, Key2: Pointer; const KeySize: Cardinal): Boolean;

Constants

NameDescription
HASH_DELETED Holds the leftmost bit of an Integer / Cardinal. It is used to mark deleted slots in the vector. Both HASH_DELETED and HASH_END limit the maximum number of items a hash container can hold to 2^30.

Only for internal use. Do not modify.

HASH_END Holds the second leftmost bit of an Integer / Cardinal. It is used to indicate the end of the linked hash list. Both HASH_END and HASH_DELETED limit the maximum number of items a hash container can hold to 2^30.

Only for internal use. Do not modify.

MIN_HASH_SIZE The minimum size of FHash initially allocated. Increase it for speed, decrease it for smaller memory footprint. Use a prime number if possible. Default is 11.

Variables

None.

Author

Ralf Junker -- delphi@zeitungsjunge.de


rjExContainer Library Version 0.1
Copyright Ralf Junker 2000-2001
http://www.zeitungsjunge.de/delphi/