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. */
34 size_t size; /* size of the hasharray */
35 unsigned int fullness; /* number of entries in the hashtable */
36 unsigned long (*hash_function) (CONST void *);
37 int (*test_function) (CONST void *, CONST void *);
39 Lisp_Object elisp_table;
43 typedef struct _C_hashtable *c_hashtable;
45 /* size is the number of initial entries. The hashtable will be grown
46 automatically if the number of entries approaches the size */
47 c_hashtable make_hashtable (unsigned int size);
49 c_hashtable make_general_hashtable (unsigned int hsize,
50 unsigned long (*hash_function)
52 int (*test_function) (CONST void *,
55 c_hashtable make_strings_hashtable (unsigned int hsize);
57 /* clears the hash table. A freshly created hashtable is already cleared up */
58 void clrhash (c_hashtable hash);
60 /* frees the table and substructures */
61 void free_hashtable (c_hashtable hash);
63 /* returns a hentry whose key is 0 if the entry does not exist in hashtable */
64 CONST void *gethash (CONST void *key, c_hashtable hash,
65 CONST void **ret_value);
67 /* key should be different from 0 */
68 void puthash (CONST void *key, void *contents, c_hashtable hash);
70 /* delete the entry which key is key */
71 void remhash (CONST void *key, c_hashtable hash);
73 typedef int (*maphash_function) (CONST void* key, void* contents, void* arg);
75 typedef int (*remhash_predicate) (CONST void* key, CONST void* contents,
78 typedef void (*generic_hashtable_op) (c_hashtable table,
79 void *arg1, void *arg2, void *arg3);
81 /* calls mf with the following arguments: key, contents, arg; for every
82 entry in the hashtable */
83 void maphash (maphash_function fn, c_hashtable hash, void* arg);
85 /* delete objects from the table which satisfy the predicate */
86 void map_remhash (remhash_predicate predicate, c_hashtable hash, void *arg);
88 /* copies all the entries of src into dest -- dest is modified as needed
89 so it is as big as src. */
90 void copy_hash (c_hashtable dest, c_hashtable src);
92 /* makes sure that hashtable can hold at least needed_size entries */
93 void expand_hashtable (c_hashtable hash, unsigned int needed_size);
95 #ifdef emacs /* for elhash.c */
96 unsigned int compute_harray_size (unsigned int);