1 /* This file is part of XEmacs.
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
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
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. */
18 /* Synched up with: Not in FSF. */
20 #ifndef INCLUDED_hash_h_
21 #define INCLUDED_hash_h_
29 typedef int (*hash_table_test_function) (const void *, const void *);
30 typedef unsigned long (*hash_table_hash_function) (const void *);
31 typedef size_t hash_size_t;
38 hash_size_t size; /* size of the hasharray */
39 hash_size_t fullness; /* number of entries in the hash table */
40 hash_table_hash_function hash_function;
41 hash_table_test_function test_function;
44 /* SIZE is the number of initial entries. The hash table will be grown
45 automatically if the number of entries approaches the size */
46 struct hash_table *make_hash_table (hash_size_t size);
49 make_general_hash_table (hash_size_t size,
50 hash_table_hash_function hash_function,
51 hash_table_test_function test_function);
53 /* Clear HASH-TABLE. A freshly created hash table is already cleared up. */
54 void clrhash (struct hash_table *hash_table);
56 /* Free HASH-TABLE and its substructures */
57 void free_hash_table (struct hash_table *hash_table);
59 /* Returns a hentry whose key is 0 if the entry does not exist in HASH-TABLE */
60 const void *gethash (const void *key, struct hash_table *hash_table,
61 const void **ret_value);
63 /* KEY should be different from 0 */
64 void puthash (const void *key, void *contents, struct hash_table *hash_table);
66 /* delete the entry with key KEY */
67 void remhash (const void *key, struct hash_table *hash_table);
69 typedef int (*maphash_function) (const void* key, void* contents, void* arg);
71 typedef int (*remhash_predicate) (const void* key, const void* contents,
74 /* Call MF (key, contents, arg) for every entry in HASH-TABLE */
75 void maphash (maphash_function mf, struct hash_table *hash_table, void* arg);
77 /* Delete all objects from HASH-TABLE satisfying PREDICATE */
78 void map_remhash (remhash_predicate predicate,
79 struct hash_table *hash_table, void *arg);
81 #endif /* INCLUDED_hash_h_ */