/* Synched up with: Not in FSF. */
-#ifndef _HASH_H_
-#define _HASH_H_
+#ifndef INCLUDED_hash_h_
+#define INCLUDED_hash_h_
typedef struct
{
- CONST void *key;
+ const void *key;
void *contents;
} hentry;
-struct _C_hashtable
+typedef int (*hash_table_test_function) (const void *, const void *);
+typedef unsigned long (*hash_table_hash_function) (const void *);
+typedef size_t hash_size_t;
+
+struct hash_table
{
hentry *harray;
long zero_set;
void *zero_entry;
- size_t size; /* size of the hasharray */
- unsigned int fullness; /* number of entries in the hashtable */
- unsigned long (*hash_function) (CONST void *);
- int (*test_function) (CONST void *, CONST void *);
-#ifdef emacs
- Lisp_Object elisp_table;
-#endif
+ hash_size_t size; /* size of the hasharray */
+ hash_size_t fullness; /* number of entries in the hash table */
+ hash_table_hash_function hash_function;
+ hash_table_test_function test_function;
};
-typedef struct _C_hashtable *c_hashtable;
-
-/* size is the number of initial entries. The hashtable will be grown
+/* SIZE is the number of initial entries. The hash table will be grown
automatically if the number of entries approaches the size */
-c_hashtable make_hashtable (unsigned int size);
+struct hash_table *make_hash_table (hash_size_t size);
-c_hashtable make_general_hashtable (unsigned int hsize,
- unsigned long (*hash_function)
- (CONST void *),
- int (*test_function) (CONST void *,
- CONST void *));
+struct hash_table *
+make_general_hash_table (hash_size_t size,
+ hash_table_hash_function hash_function,
+ hash_table_test_function test_function);
-c_hashtable make_strings_hashtable (unsigned int hsize);
+/* Clear HASH-TABLE. A freshly created hash table is already cleared up. */
+void clrhash (struct hash_table *hash_table);
-/* clears the hash table. A freshly created hashtable is already cleared up */
-void clrhash (c_hashtable hash);
+/* Free HASH-TABLE and its substructures */
+void free_hash_table (struct hash_table *hash_table);
-/* frees the table and substructures */
-void free_hashtable (c_hashtable hash);
+/* Returns a hentry whose key is 0 if the entry does not exist in HASH-TABLE */
+const void *gethash (const void *key, struct hash_table *hash_table,
+ const void **ret_value);
-/* returns a hentry whose key is 0 if the entry does not exist in hashtable */
-CONST void *gethash (CONST void *key, c_hashtable hash,
- CONST void **ret_value);
+/* KEY should be different from 0 */
+void puthash (const void *key, void *contents, struct hash_table *hash_table);
-/* key should be different from 0 */
-void puthash (CONST void *key, void *contents, c_hashtable hash);
+/* delete the entry with key KEY */
+void remhash (const void *key, struct hash_table *hash_table);
-/* delete the entry which key is key */
-void remhash (CONST void *key, c_hashtable hash);
+typedef int (*maphash_function) (const void* key, void* contents, void* arg);
-typedef int (*maphash_function) (CONST void* key, void* contents, void* arg);
-
-typedef int (*remhash_predicate) (CONST void* key, CONST void* contents,
+typedef int (*remhash_predicate) (const void* key, const void* contents,
void* arg);
-typedef void (*generic_hashtable_op) (c_hashtable table,
- void *arg1, void *arg2, void *arg3);
-
-/* calls mf with the following arguments: key, contents, arg; for every
- entry in the hashtable */
-void maphash (maphash_function fn, c_hashtable hash, void* arg);
-
-/* delete objects from the table which satisfy the predicate */
-void map_remhash (remhash_predicate predicate, c_hashtable hash, void *arg);
-
-/* copies all the entries of src into dest -- dest is modified as needed
- so it is as big as src. */
-void copy_hash (c_hashtable dest, c_hashtable src);
-
-/* makes sure that hashtable can hold at least needed_size entries */
-void expand_hashtable (c_hashtable hash, unsigned int needed_size);
+/* Call MF (key, contents, arg) for every entry in HASH-TABLE */
+void maphash (maphash_function mf, struct hash_table *hash_table, void* arg);
-#ifdef emacs /* for elhash.c */
-unsigned int compute_harray_size (unsigned int);
-#endif
+/* Delete all objects from HASH-TABLE satisfying PREDICATE */
+void map_remhash (remhash_predicate predicate,
+ struct hash_table *hash_table, void *arg);
-#endif /* _HASH_H_ */
+#endif /* INCLUDED_hash_h_ */