]> sjero.net Git - wget/blob - src/hash.h
[svn] Guard against header files getting included twice.
[wget] / src / hash.h
1 /* Hash table declarations.
2    Copyright (C) 2000 Free Software Foundation, Inc.
3
4 This file is part of GNU Wget.
5
6 GNU Wget 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 GNU Wget 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 Wget; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20 #ifndef HASH_H
21 #define HASH_H
22
23 /* From XEmacs, and hence from Dragon book. */
24
25 #define GOOD_HASH 65599 /* prime number just over 2^16; Dragon book, p. 435 */
26 #define HASH2(a,b)               (GOOD_HASH * (a)                     + (b))
27 #define HASH3(a,b,c)             (GOOD_HASH * HASH2 (a,b)             + (c))
28 #define HASH4(a,b,c,d)           (GOOD_HASH * HASH3 (a,b,c)           + (d))
29 #define HASH5(a,b,c,d,e)         (GOOD_HASH * HASH4 (a,b,c,d)         + (e))
30 #define HASH6(a,b,c,d,e,f)       (GOOD_HASH * HASH5 (a,b,c,d,e)       + (f))
31 #define HASH7(a,b,c,d,e,f,g)     (GOOD_HASH * HASH6 (a,b,c,d,e,f)     + (g))
32 #define HASH8(a,b,c,d,e,f,g,h)   (GOOD_HASH * HASH7 (a,b,c,d,e,f,g)   + (h))
33 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i))
34
35 struct hash_table;
36
37 struct hash_table *hash_table_new PARAMS ((int,
38                                            unsigned long (*) (const void *),
39                                            int (*) (const void *,
40                                                     const void *)));
41 void hash_table_destroy PARAMS ((struct hash_table *));
42
43 void *hash_table_get PARAMS ((struct hash_table *, const void *));
44 int hash_table_get_pair PARAMS ((struct hash_table *, const void *,
45                                  void *, void *));
46 int hash_table_contains PARAMS ((struct hash_table *, const void *));
47
48 void hash_table_put PARAMS ((struct hash_table *, const void *, void *));
49 int hash_table_remove PARAMS ((struct hash_table *, const void *));
50 void hash_table_clear PARAMS ((struct hash_table *));
51
52 void hash_table_map PARAMS ((struct hash_table *,
53                              int (*) (void *, void *, void *),
54                              void *));
55 int hash_table_count PARAMS ((struct hash_table *));
56
57 unsigned long string_hash PARAMS ((const void *));
58 int string_cmp PARAMS ((const void *, const void *));
59 struct hash_table *make_string_hash_table PARAMS ((int));
60 struct hash_table *make_nocase_string_hash_table PARAMS ((int));
61
62 #endif /* HASH_H */