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. */
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 struct hash_table *make_strings_hash_table (hash_size_t size);
55 /* Clear HASH-TABLE. A freshly created hash table is already cleared up. */
56 void clrhash (struct hash_table *hash_table);
58 /* Free HASH-TABLE and its substructures */
59 void free_hash_table (struct hash_table *hash_table);
61 /* Returns a hentry whose key is 0 if the entry does not exist in HASH-TABLE */
62 CONST void *gethash (CONST void *key, struct hash_table *hash_table,
63 CONST void **ret_value);
65 /* KEY should be different from 0 */
66 void puthash (CONST void *key, void *contents, struct hash_table *hash_table);
68 /* delete the entry with key KEY */
69 void remhash (CONST void *key, struct hash_table *hash_table);
71 typedef int (*maphash_function) (CONST void* key, void* contents, void* arg);
73 typedef int (*remhash_predicate) (CONST void* key, CONST void* contents,
76 typedef void (*generic_hash_table_op) (struct hash_table *hash_table,
77 void *arg1, void *arg2, void *arg3);
79 /* Call MF (key, contents, arg) for every entry in HASH-TABLE */
80 void maphash (maphash_function mf, struct hash_table *hash_table, void* arg);
82 /* Delete all objects from HASH-TABLE satisfying PREDICATE */
83 void map_remhash (remhash_predicate predicate,
84 struct hash_table *hash_table, void *arg);
86 /* Copy all the entries from SRC into DEST -- DEST is modified as needed
87 so it is as big as SRC. */
88 void copy_hash (struct hash_table *dest, struct hash_table *src);
90 /* Make sure HASH-TABLE can hold at least NEEDED_SIZE entries */
91 void expand_hash_table (struct hash_table *hash_table, hash_size_t needed_size);