]> sjero.net Git - wget/blob - src/hash.h
[svn] Declare hash_table_get_pair and hash_table_count.
[wget] / src / hash.h
1 /* Hash table declarations.
2    Copyright (C) 2000 Free Software Foundation, Inc.
3
4 This file is part of Wget.
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 /* From XEmacs, and hence from Dragon book. */
21
22 #define GOOD_HASH 65599 /* prime number just over 2^16; Dragon book, p. 435 */
23 #define HASH2(a,b)               (GOOD_HASH * (a)                     + (b))
24 #define HASH3(a,b,c)             (GOOD_HASH * HASH2 (a,b)             + (c))
25 #define HASH4(a,b,c,d)           (GOOD_HASH * HASH3 (a,b,c)           + (d))
26 #define HASH5(a,b,c,d,e)         (GOOD_HASH * HASH4 (a,b,c,d)         + (e))
27 #define HASH6(a,b,c,d,e,f)       (GOOD_HASH * HASH5 (a,b,c,d,e)       + (f))
28 #define HASH7(a,b,c,d,e,f,g)     (GOOD_HASH * HASH6 (a,b,c,d,e,f)     + (g))
29 #define HASH8(a,b,c,d,e,f,g,h)   (GOOD_HASH * HASH7 (a,b,c,d,e,f,g)   + (h))
30 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i))
31
32 struct hash_table;
33
34 struct hash_table *hash_table_new PARAMS ((int,
35                                            unsigned long (*) (const void *),
36                                            int (*) (const void *,
37                                                     const void *)));
38 void hash_table_destroy PARAMS ((struct hash_table *));
39
40 void *hash_table_get PARAMS ((struct hash_table *, const void *));
41 int hash_table_get_pair PARAMS ((struct hash_table *, const void *,
42                                  void *, void *));
43 int hash_table_exists PARAMS ((struct hash_table *, const void *));
44
45 void hash_table_put PARAMS ((struct hash_table *, const void *, void *));
46 int hash_table_remove PARAMS ((struct hash_table *, const void *));
47 void hash_table_clear PARAMS ((struct hash_table *));
48
49 void hash_table_map PARAMS ((struct hash_table *,
50                              int (*) (void *, void *, void *),
51                              void *));
52 int hash_table_count PARAMS ((struct hash_table *));
53
54 unsigned long string_hash PARAMS ((const void *));
55 int string_cmp PARAMS ((const void *, const void *));
56 struct hash_table *make_string_hash_table PARAMS ((int));