Data Structures and Algorithms
with Object-Oriented Design Patterns in C# |
The constructor, Length property, and Purge methods of the ChainedHashTable class are defined in Program . The constructor takes a single argument which specifies the size of hash table desired. It creates an array of the specified length and then initializes the elements of the array. Each element of the array is assigned an empty linked list. The running time for the ChainedHashTable constructor is O(M) where M is the size of the hash table.
Program: ChainedHashTable class constructor, Length property, and Purge methods.
The Length property provides a get accessor that returns the length of the array field. Clearly its running time is O(1)
The purpose of the Purge method is to make the container empty. It does this by invoking the Purge method one-by-one on each of the linked lists in the array. The running time of the Purge method is O(M), where M is the size of the hash table.