1 /* hash.h: declarations for a hash table.
3 Copyright 1994, 1995, 2008, 2010-2012 Karl Berry.
4 Copyright 1999, 2005 Olaf Weber.
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.
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.
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/>. */
22 #include <kpathsea/c-proto.h>
23 #include <kpathsea/types.h>
26 * The code freeing strings and hash tables is enabled/disabled
27 * by KPATHSEA_CAN_FREE.
29 /* At the moment can not free */
30 #define KPATHSEA_CAN_FREE 0
36 /* A single (key,value) pair. */
37 typedef struct hash_element_struct
41 struct hash_element_struct
*next
;
44 /* The usual arrangement of buckets initialized to null. */
47 hash_element_type
**buckets
;
52 /* Create a hash table of size SIZE. */
53 extern KPSEDLL hash_table_type
hash_create (unsigned size
);
55 /* Insert the (KEY,VALUE) association into TABLE. KEY may have more
56 than one VALUE. Neither KEY nor VALUE is copied. */
57 extern KPSEDLL
void hash_insert (hash_table_type
*table
,
61 #ifdef MAKE_KPSE_DLL /* libkpathsea internal only */
63 /* Insert the (KEY, VALUE) association into TABLE. KEY may have more
64 than one VALUE. Neither KEY nor VALUE is copied. Assume that KEY
65 is already normalized (all lowercase) on platforms where this matters. */
66 extern void hash_insert_normalized (hash_table_type
*table
,
70 #endif /* MAKE_KPSE_DLL */
72 /* Remove the (KEY,VALUE) association from TABLE. */
73 extern KPSEDLL
void hash_remove (hash_table_type
*table
, const_string key
,
76 /* Look up KEY in TABLE, and return NULL-terminated list of all matching
77 values (not copies), in insertion order. If none, return NULL. */
78 extern KPSEDLL const_string
*hash_lookup (hash_table_type table
, const_string key
);
80 #ifdef MAKE_KPSE_DLL /* libkpathsea internal only */
82 /* Print TABLE to stderr. */
83 extern void hash_print (hash_table_type table
, boolean summary_only
);
87 extern void hash_free (hash_table_type table
);
90 #endif /* MAKE_KPSE_DLL */
96 #endif /* not HASH_H */