dvitomp fix from Akira
[mplib] / src / texk / kpathsea / hash.h
1 /* hash.h: declarations for a hash table.
2
3    Copyright 1994, 1995, 2008 Karl Berry.
4    Copyright 1999, 2005 Olaf Weber.
5
6    This library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
11    This library 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 GNU
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public License
17    along with this library; if not, see <http://www.gnu.org/licenses/>.  */
18
19 #ifndef HASH_H
20 #define HASH_H
21
22 #include <kpathsea/c-proto.h>
23 #include <kpathsea/types.h>
24
25
26 /* A single (key,value) pair.  */
27 typedef struct hash_element_struct
28 {
29   const_string key;
30   const_string value;
31   struct hash_element_struct *next;
32 } hash_element_type;
33
34 /* The usual arrangement of buckets initialized to null.  */
35 typedef struct
36 {
37   hash_element_type **buckets;
38   unsigned size;
39 } hash_table_type;
40 \f
41 #ifdef KPSE_DEBUG
42 /* How to print the hash results when debugging.  */
43 extern KPSEDLL boolean kpse_debug_hash_lookup_int;
44 #endif
45
46 /* Create a hash table of size SIZE.  */
47 extern KPSEDLL hash_table_type hash_create P1H(unsigned size);
48
49 /* Insert the (KEY,VALUE) association into TABLE.  KEY may have more
50    than one VALUE.  Neither KEY nor VALUE is copied.  */
51 extern KPSEDLL void hash_insert P3H(hash_table_type *table,
52                                     const_string key,
53                                     const_string value);
54
55 /* Insert the (KEY, VALUE) association into TABLE.  KEY may have more
56    than one VALUE.  Neither KEY nor VALUE is copied.  Assume that KEY
57    is already normalized (all lowercase) on platforms where this matters. */
58 extern KPSEDLL void hash_insert_normalized P3H(hash_table_type *table,
59                                                const_string key,
60                                                const_string value);
61
62 /* Remove the (KEY,VALUE) association from TABLE.  */
63 extern KPSEDLL void hash_remove P3H(hash_table_type *table,  const_string key,
64                                     const_string value);
65
66 /* Look up KEY in MAP, and return NULL-terminated list of all matching
67    values (not copies), in insertion order.  If none, return NULL.  */
68 extern KPSEDLL string *hash_lookup P2H(hash_table_type table, const_string key);
69
70 /* Print TABLE to stderr.  */
71 extern void hash_print P2H(hash_table_type table, boolean summary_only);
72
73 #endif /* not HASH_H */