[an error occurred while processing this directive]

Table Module Implementation Specifications


Client Specifications

Implementation Data Model

Except for caching, the Table implementation is a standard hash table with separate chaining. In brief, a Table is a reference to a structure that contains an array of linked lists. Each node in a linked list contains a key and a data field for a table entry, and a reference to the next node in the list.

A key parameter is specified for the isKey(), add(), dataFor(), and remove() functions. For each of these functions, a hash value is computed for the key. The hash value is used to select one of the linked lists. Then a standard linked list operation is done with the selected list.

Caching is used to reduce the overhead that results from separating the check for presence of a key in isKey() from the add(), dataFor(), and remove() functions. Caching is accomplished by storing the key for the most recent call to isKey(), along with a reference to the list node that contains the key. A reference to the preceding node is also saved to facilitate the remove() function. This reference is null for the first entry in a hash list. Finally, the hash value for the key is saved to handle the remove() case where the entry to be removed is at the front of its list. When an isKey() search is unsuccessful, a null value is stored as the cache key. All data access functions use a call to isKey() to set up the cache variables.

For the add(), dataFor(), and remove() functions, the parameter key is first compared with the cached key. If they are the same then the cached information is used to do the required operation. Otherwise, a normal hash table operation is attempted. The function isKey() is always called after checking the cached key in order to ensure that preconditions are met. This call also puts the right values into the cache variables so that these functions do not need to do a search.

Private Importing Information

The source code file for this module must include Table.h. If the data type is a non-standard type declared in a header file then that header file must be included prior to the include for Table.h

Private Data Type Implementations

The following data types are declared in Table.C.

Public Data Type Implementations

The following data type is declared in Table.h.

Private Function Specifications

The following functions are declared static in Table.C.

Private Function Algorithms

Public Function Algorithms

[an error occurred while processing this directive]