hsearch(3) — Subroutines
OSF
NAME
hsearch, hcreate, hdestroy − Manages hash tables
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <search.h>
ENTRY ∗hsearch(
ENTRY item,
ACTION action) ;
int hcreate(
unsigned int nel) ;
void hdestroy(void) ;
PARAMETERS
itemIdentifies a structure of the type ENTRY as defined in the search.h header file. It contains two pointers:
item.keyPoints to the comparison key string.
item.dataPoints to any other data associated with the item.key parameter.
Pointers to types other than char should be cast as char ∗.
actionSpecifies a value for an ACTION enum type, which indicates what is to be done with an item key when it cannot be found in the hash table. The ACTION enum type specifies the following two actions that can be specified for this parameter:
ENTEREnter the key specified by the item parameter into the hash table at the appropriate place. When the table is full, a null pointer is returned.
FINDDo not enter the item key into the table, but return a null pointer when an item key cannot be found in the hash table.
nelSpecifies an estimate of the maximum number of entries that the hash table contains. Under some circumstances, the hcreate() function may make the hash table larger than specified, to obtain mathematically favorable conditions for access to the hash table.
DESCRIPTION
The hsearch(), hcreate() and hdestroy() functions are used to manage hash-table operations.
The hsearch() function searches a hash table. It returns a pointer into a hash table that indicates where a given entry can be found. The hsearch()" function uses "open addressing" with a hash function.
The hcreate() function initializes the hash table. You must call the hcreate() function before calling the hsearch() function.
The hdestroy() function deletes the hash table. This allows you to start a new hash table because only one table may be active at a time. After the call to hdestroy() the hash-table data should no longer be considered accessible.
NOTES
AES Support Level:
Trial use
RETURN VALUES
The hsearch() function returns a null pointer when the action is FIND and the key pointed to by item can not be found, or when the specified action is ENTER and the hash table is full.
Upon successful completion, the hcreate() function returns a nonzero value. Otherwise, when sufficient space for the table cannot be allocated, the hcreate() function returns 0 (zero).
RELATED INFORMATION
Functions: bsearch(3), lsearch(3), tsearch(3)