Class THash (unit hash)

Inherits from

TObject

Constructors


constructor Create;



Functions

function Add( const Key: string; Val: Pointer): boolean;

add is like put, but does not check for existing item

procedure Clear;


function Delete( const Key: string): boolean;

value is nil, must want to delete it

destructor Destroy;


function First: THashItem;


function Get( const Key: string): Pointer;


function Next: THashItem;


procedure Put( const Key: string; Val: Pointer);

bucket slot now points to chain

function ChainOf( B: integer): TStringList;

helper functions; should really be macros, but.

procedure CheckGrowth;


function FindFirst( Start: integer): THashItem;

yes, delete the chain, too

function GetAvgChainSize: real;


function GetiCount( B: integer): integer;


function GetLongestChain: integer;


function h( const Key: string): longint;


function HasChain( B: integer): boolean;


procedure Rebuild( sz: integer);


procedure SetAutoGrow( flag: boolean);


procedure SetHashFunc( Fn: THashFunc);


procedure SetSize( sz: integer);


Properties

property AutoGrow : boolean


property AvgChainSize : real


property Chains : integer


property Count : integer


property HashFunc : THashFunc


property iCount : integer


property Items : Pointer


property LongestChain : integer


property Size : integer


property Used : integer


Events

Variables

FAutoGrow : boolean;


FBIdx : integer;

bucket and chain index of current item (used for .

FChains : integer;


FCIdx : integer;


FCount : integer;


FHash : TStringList;


FHashFunc : THashFunc;


FSize : integer;

max # of buckets, occupied buckets, # of chains created, # of hash items added

FUsed : integer;



Constructors


constructor Create;


Functions


function Add( const Key: string; Val: Pointer): boolean;

add is like put, but does not check for existing item


procedure Clear;


function Delete( const Key: string): boolean;

value is nil, must want to delete it


destructor Destroy;


function First: THashItem;


function Get( const Key: string): Pointer;


function Next: THashItem;


procedure Put( const Key: string; Val: Pointer);

bucket slot now points to chain


function ChainOf( B: integer): TStringList;

helper functions; should really be macros, but...


procedure CheckGrowth;


function FindFirst( Start: integer): THashItem;

yes, delete the chain, too


function GetAvgChainSize: real;


function GetiCount( B: integer): integer;


function GetLongestChain: integer;


function h( const Key: string): longint;


function HasChain( B: integer): boolean;


procedure Rebuild( sz: integer);


procedure SetAutoGrow( flag: boolean);


procedure SetHashFunc( Fn: THashFunc);


procedure SetSize( sz: integer);


Properties


property AutoGrow : boolean


property AvgChainSize : real


property Chains : integer


property Count : integer


property HashFunc : THashFunc


property iCount : integer


property Items : Pointer


property LongestChain : integer


property Size : integer


property Used : integer


Events


Variables


FAutoGrow : boolean;


FBIdx : integer;

bucket and chain index of current item (used for .First and .Next method to


FChains : integer;


FCIdx : integer;


FCount : integer;


FHash : TStringList;


FHashFunc : THashFunc;


FSize : integer;

max # of buckets, occupied buckets, # of chains created, # of hash items added


FUsed : integer;