1 /*
2  *  hash table management
3  *
4  *  Copyright (c) 1997 Alfredo K. Kojima
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20 
21 #ifndef HASHTABLE_H_
22 #define HASHTABLE_H_
23 
24 
25 typedef struct HashEntry {
26     struct HashEntry *nptr, *pptr;     /* linked list */
27     unsigned long key;
28     unsigned long data;
29     struct HashEntry *next;	       /* next on the linked-list for
30 					* collisions */
31 } HashEntry;
32 
33 
34 /*
35  * A generic hash table structure
36  */
37 typedef struct HashTable {
38     int elements;		       /* elements stored in the table */
39     int size;			       /* size of the table */
40     HashEntry **table;
41     HashEntry *last;		       /* last on the linked list */
42 } HashTable;
43 
44 
45 
46 HashTable *table_init(HashTable *table);
47 void table_idestroy(HashTable *table);
48 void table_iput(HashTable *table, unsigned long key, unsigned long data);
49 int table_iget(HashTable *table, unsigned long key, unsigned long *data);
50 void table_idelete(HashTable *table, unsigned long key);
51 
52 
53 #endif
54