HP 3000 Manuals

hsearch [ HP C/iX Library Reference Manual ] MPE/iX 5.0 Documentation


HP C/iX Library Reference Manual

hsearch 

Returns a pointer into a hash table, indicating the location of a
specified entry.

Syntax 

     #include <search.h>
     ENTRY *hsearch (ENTRY item, ACTION action);

Parameters 

item          A structure of type ENTRY, defined in the <search.h> header
              file.  The item parameter contains two pointers:
                 *   item.key points to the comparison key.
                 *   item.data points to any other data to be associated
                     with that key.

              Pointers to types other than character should be cast to
              pointer-to-character.

action        A member of an enumeration type ACTION which indicates the
              disposition of the entry if it cannot be found in the
              table.  ENTER indicates that the item should be inserted in
              the table at an appropriate point.  FIND indicates that no
              entry should be made.  Unsuccessful resolution is indicated
              by the return of a null pointer.

Return Values 

x             A pointer to an object of type ENTRY, giving the location
              of the item in the table.

NULL          The table is full, or the item was not found.

Description 

The hsearch function returns a pointer into a hash table, indicating the
location at which a specified entry can be found.  This function uses
malloc() to allocate space.

Only one hash search table may be active at any given time.  The hcreate
function must be called before hsearch() to allocate sufficient space for
the hash table.

The hsearch function is a hash-table search function generalized from
Knuth Algorithm D (6.4) described in The Art of Computer Programming, 
Vol.3 (Sorting and Searching) by Donald Ervin Knuth (Reading,
Mass.:Addison- Wesley, 1973).


NOTE The hsearch function and the header file <search.h> are not part of ANSI C. Using them may make your program less portable.
Example Refer to the example located in the hcreate function description. See Also hcreate(), hdestroy()


MPE/iX 5.0 Documentation