.\" Copyright 1993 Ulrich Drepper (drepper@karlsruhe.gmd.de) .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, .\" USA. .\" .\" References consulted: .\" SunOS 4.1.1 man pages .TH HSEARCH 3 "August 28, 1993" "GNU" "Linux Programmer's Manual" .SH NAME hcreate, hdestroy, hsearch \- hash table management .SH SYNOPSIS .nf .B #include .sp .BI "ENTRY *hsearch(ENTRY " item ", ACTION " action "); .RE .fi .SH DESCRIPTION This three functions allow the user to create a hash table of type \fIENTRY\fP (defined in \fB\fP) which associates a key with any data. The implementation uses \fBmalloc(3)\fP. .PP First the table must be created with the function \fBhcreate()\fP. \fInel\fP is an estimation of the table size which will suffice the needs. For better algorithms this value can be corrected upwards. .PP The corresponding function \fIhdestroy()\fP frees the memory occupied by the hash table for that a new table can be constructed. .PP \fIhsearch()\fP is the function for searching and inserting. Which action is done is controlled by the parameter \fIaction\fP. It is of the type \fIACTION\fP (also defined in \fB\fP) and can have the values \fIENTER\fP or \fIFIND\fP. \fIENTER\fP means to insert the given \fIitem\fP and \fIFIND\fP means to only search. Unsuccesful actions result in a return value \fINULL\fP. .SH "RETURN VALUE" \fBhcreate()\fP return zero if the hash table cannot be succesfully installed. .PP \fBhsearch()\fP return \fINULL\fP if either action is \fIENTER\fP and the hash table is full or action is \fIFIND\fP and the \fIitem\fP cannot be find in the hash table. .SH BUGS The implementation can manage only one hash table at a time. .SH "SEE ALSO" .BR bsearch (3), lsearch (3), malloc (3)