The most compilers use search structures. Here the package `hashtab' which implements expandable hash tables is suggested. This abstract data implements features analogous to ones of public domain functions `hsearch', `hcreate' and `hdestroy'. The goal of the abstract data creation is to implement additional needed features. The abstract data permits to work simultaneously with several expandable hash tables. Besides insertion and search of elements the elements from the hash tables can be also removed. The table element can be only a pointer. The size of hash tables is not fixed. The hash table will be expanded when its occupancy will become big.

The abstract data implementation is based on generalized Algorithm D from Knuth's book "The art of computer programming". Hash table is expanded by creation of new hash table and transferring elements from the old table to the new table.

The package uses package `allocate'. The interface part of the abstract data is file `hashtab.h'. The implementation part is file `hashtab.cpp'. The interface contains the following objects:

**Type `hash_table_entry_t'**is described as `void *' and represents hash table element type. Empty entries have value `NULL'.

**Type `hash_table_t'**describes hash table itself. The type is simply synonym of `class hash_table *'.

**Class `hash_table'**The class contains the following functions:

**Public constructor `hash_table'**

creates hash table with length slightly longer than value of function parameter `size'. Created hash table is initiated as empty (all the hash table entries are NULL). The hash table will use functions `hash_function', `eq_function' given as the function parameters to evaluate table element hash value and function to test on equality of two table elements.`hash_table (size_t size, unsigned (*hash_function) (hash_table_entry_t el_ptr), int (*eq_function) (hash_table_entry_t el1_ptr, hash_table_entry_t el2_ptr))'

**Public destructor ` hash_table'**

deletes given hash table and frees memory allocated for it.`~hash_table (void)'

**Public function `empty'**

makes the hash table empty. If you need to remove all table elements, it is better to use this function than several times function `remove_element_from_entry'. This function does not change size of the table or clear statistics about collisions.`void empty (void)'

**Public function `find_entry'**

searches for hash table entry which contains element equal to value of the function parameter `element' or empty entry in which `element' can be placed (if the element does not exist in the table). The function parameter `reserve' is to be nonzero if the element is to be placed in the table. The element should be inserted into the table entry before another call of `find_hash_table_entry'. The table is expanded if occupancy (taking into account also deleted elements) is more than 75%. The occupancy of the table after the expansion will be about 50%.`hash_table_entry_t *find_entry (hash_table_entry_t element, int reserve)'

**Public function `remove_element_from_entry'**

removes element from hash table_entry whose value is given as the function parameter. Hash table entry for given value should be not empty (or deleted). The hash table entry value will be marked as deleted after the function call.`void remove_element_from_entry (hash_table_entry_t element)'

**Public function `size'**

returns current size of given hash table.`size_t size (void)'

**Public function `elements_number'**

returns current number of elements in given hash table.`size_t elements_number (void)'

**Public function `collisions'**

returns number of of percents of fixed collisions during all work with given hash table.`int collisions (void)'

**Static public function `all_collisions'**

returns number of of percents of fixed collisions during all work with all hash tables.`int all_collisions (void)'

Next Previous Contents