hsearch() is a hash-table search routine. It returns a pointer into a hash table indicating the location at which an entry can be found. The comparison function used by hsearch() is strcmp() . item is a structure of type ENTRY (defined in the search.h header) containing two pointers: item.key points to the comparison key (of type char* ), and item.data (a void* ) points to any other data to be associated with that key.
Extension Pointers to types that are not void must be converted to pointers to void . (End) action is a member of the enumeration type ACTION (defined in search.h ) indicating the disposition of the entry if it cannot be found in the table. ENTER indicates that item should be inserted in the table at an appropriate point. Extension If a duplicate to an existing entry is present, the new item is not entered, and hsearch() returns the pointer to the existing entry. (End) FIND indicates that no entry should be made. Unsuccessful resolution is indicated by the return of a null pointer.
hcreate() allocates sufficient space for the table and must be called before hsearch() is used. The nel argument is an estimate of the maximum number of entries that the table will contain. This number may be adjusted upward by the algorithm in order to obtain certain mathematically favorable circumstances.
hdestroy() destroys the search table and may be followed by another call to hcreate() . After the call to hdestroy() , the data can no longer be considered accessible.
|