Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 15171, FAST! String-Pointer associative map (hashtable implementation)

by Barry Kelly Email: Anonymous


This class is *extremely* useful where performance degrades rapidly when using a TStringList & TStringList.Objects
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 2.0  to 5.0 1338 downloads
Copyright: No significant restrictions


Size: 10,225 bytes
Updated on Tue, 13 Mar 2001 22:38:06 GMT
Originally uploaded on Wed, 30 Aug 2000 17:27:16 GMT
SHA1 Hash: 4B15F26CB66194DDE8B00E19C12C7ED811854DD0
MD5 Hash: C023C3B10B54226C9D5CD10E0CDB5A3A

    Explore the files in this upload

Description
A fast associative array targeted specifically at create and looking up associations between strings and 32-bit untyped fields (usually pointers to records or classes).

Examples:

hash.Add('abc', myobject);
TMyObject(hash['abc']).Whatever;
if not hash.Find('abc', myobject) then ..
TObject(hash.Remove('abc')).Free; // removes and frees without temp
hash.Iterate(nil, Iterate_FreeObjects);

Summary of public interface:
----------------------------
constructor Create(AHashSize: Integer; ACompareFunc: TCompareFunc;
AHashFunc: THashFunc);
procedure Add(const s: string; const p{: Pointer});
procedure RemoveData(const p{: Pointer});
function Remove(const s: string): Pointer;
procedure Iterate(AUserData: Pointer; AIterateFunc: TIterateFunc);
procedure IterateMethod(AUserData: Pointer; AIterateMethod:
TIterateMethod);
function Has(const s: string): Boolean;
function Find(const s: string; var p{: Pointer}): Boolean;
function FindData(const p{: Pointer}; var s: string): Boolean;

procedure Clear;

Public properties:
------------------
property Count: Integer read FCount;
property Data[const s: string]: Pointer read GetData
write SetData; default;

Protected interface for custom memory allocation:
-------------------------------------------------
function AllocNode: PHashNode; virtual;
procedure FreeNode(ANode: PHashNode); virtual;

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03