428
|
1 /* This file is part of XEmacs.
|
|
2
|
|
3 XEmacs is free software; you can redistribute it and/or modify it
|
|
4 under the terms of the GNU General Public License as published by the
|
|
5 Free Software Foundation; either version 2, or (at your option) any
|
|
6 later version.
|
|
7
|
|
8 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
9 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
10 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
11 for more details.
|
|
12
|
|
13 You should have received a copy of the GNU General Public License
|
|
14 along with XEmacs; see the file COPYING. If not, write to
|
|
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
16 Boston, MA 02111-1307, USA. */
|
|
17
|
|
18 /* Synched up with: Not in FSF. */
|
|
19
|
440
|
20 #ifndef INCLUDED_hash_h_
|
|
21 #define INCLUDED_hash_h_
|
428
|
22
|
|
23 typedef struct
|
|
24 {
|
442
|
25 const void *key;
|
428
|
26 void *contents;
|
|
27 } hentry;
|
|
28
|
442
|
29 typedef int (*hash_table_test_function) (const void *, const void *);
|
647
|
30 typedef Hash_Code (*hash_table_hash_function) (const void *);
|
428
|
31
|
|
32 struct hash_table
|
|
33 {
|
|
34 hentry *harray;
|
|
35 long zero_set;
|
|
36 void *zero_entry;
|
647
|
37 Element_Count size; /* size of the hasharray */
|
|
38 Element_Count fullness; /* number of entries in the hash table */
|
428
|
39 hash_table_hash_function hash_function;
|
|
40 hash_table_test_function test_function;
|
|
41 };
|
|
42
|
|
43 /* SIZE is the number of initial entries. The hash table will be grown
|
|
44 automatically if the number of entries approaches the size */
|
647
|
45 struct hash_table *make_hash_table (Element_Count size);
|
428
|
46
|
|
47 struct hash_table *
|
647
|
48 make_general_hash_table (Element_Count size,
|
|
49 hash_table_hash_function hash_function,
|
|
50 hash_table_test_function test_function);
|
428
|
51
|
|
52 /* Clear HASH-TABLE. A freshly created hash table is already cleared up. */
|
|
53 void clrhash (struct hash_table *hash_table);
|
|
54
|
|
55 /* Free HASH-TABLE and its substructures */
|
|
56 void free_hash_table (struct hash_table *hash_table);
|
|
57
|
|
58 /* Returns a hentry whose key is 0 if the entry does not exist in HASH-TABLE */
|
442
|
59 const void *gethash (const void *key, struct hash_table *hash_table,
|
|
60 const void **ret_value);
|
428
|
61
|
|
62 /* KEY should be different from 0 */
|
442
|
63 void puthash (const void *key, void *contents, struct hash_table *hash_table);
|
428
|
64
|
|
65 /* delete the entry with key KEY */
|
442
|
66 void remhash (const void *key, struct hash_table *hash_table);
|
428
|
67
|
442
|
68 typedef int (*maphash_function) (const void* key, void* contents, void* arg);
|
428
|
69
|
442
|
70 typedef int (*remhash_predicate) (const void* key, const void* contents,
|
428
|
71 void* arg);
|
|
72
|
|
73 /* Call MF (key, contents, arg) for every entry in HASH-TABLE */
|
|
74 void maphash (maphash_function mf, struct hash_table *hash_table, void* arg);
|
|
75
|
|
76 /* Delete all objects from HASH-TABLE satisfying PREDICATE */
|
|
77 void map_remhash (remhash_predicate predicate,
|
|
78 struct hash_table *hash_table, void *arg);
|
|
79
|
440
|
80 #endif /* INCLUDED_hash_h_ */
|