Declarations Section
Hash Table Class
Hash Table Data Structure
Copyright 1999 Entisoft
Summary: The Hash Table is a data structure that stores Key and Item pairs. It can store multiple pairs which have the same Key. This data structure can be used as a symbol table or as an associative array. When asked to lookup a duplicate Key, the Lookup method usually returns the Item that was most recently added (see the Lookup method for details). The hash table provides quick access to Items based upon their Key because it "hashes" the Key. The hashing process turns a String (or numeric value) into a number that is within the specified range. The hash table will expand as necessary to accomodate amount of data stored within it. It will contract as necessary to free unused space depending upon the setting of the Contract property.
Examples: Since this class represents a data structure, you must create a instance of this class for each hash table you would like to create. The following line of Visual Basic code will create a HashTable: Public htTemp As New HashTable
Please Note: None of the examples will execute within the Debug/Immediate window because that window does not support the definition of variables. To run these examples, you must place the code within a function or subroutine.
See also: HashString Function
HashStringFast Function
SymbolTable Class
SparseArray Class
UsingTheDataStructuresHelp Topic
Using this Class in Your Projects: Please see the UsingTheDataStructuresHelp Topic for important details about the data structure Classes such as this one within your projects.
v1.3 Changes:
1. This class has been fixed to support the storage and retrieveal of Object and DataObject type Items (variables with a datatype of vbObject and vbDataObject). See the other BugFix notes within this class for a list of the individual properties and methods that are affected by this change.
2. New Name and Tag properties allow you to associate a Name and some other arbitraty data (a Tag) with each instance of a HashTable.
v1.5 Changes:
1. This class has been completely rewritten to make more efficient use of memory when large numbers of items are removed from a hash table. In the past, the "buckets" in which removed items were stored were never reused until the hash table was expanded or contracted; this is no longer the case.
2. Added new Key, Item, Keys, Items, and KeysAndItems properties to this class.
3. Added new AddFromHashTable and Exists methods to this class.
4. Changed the AddAndUpdate method to return a True or False value depending upon whether a new hash table entry was added or an existing hash table entry was updated.
5. All arguments named vName have been changed to vKey, and all documentation references to "Name" have been changed to "Key". This is to avoid confusion with the this class's Name property, and to be consistent with the names used in Visual Basic 6.0's new Dictionary class.
6. All arguments named vValue have been changed to vItem, and all documentation references to "Value" have been changed to "Item". This is to be consistent with the names used in Visual Basic 6.0's new Dictionary class.
7. Pro Users: This Class has been extended to support Events. You can enable Events, then create a Class module which uses the HashTable data structure and responds to the various events that it generates.
v2.0 Change: Embedded local copies of a few Entisoft Tools routines within this Class so that this Class is no longer dependent upon routines in any of the other Entisoft Tools Classes. Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.