-unsigned int
- hash_get_n_keys PARAMS((const HT *ht));
-
-int
- hash_query_in_table PARAMS((const HT *ht, const void *e));
-
-void *
- hash_lookup PARAMS((const HT *ht, const void *e));
-
-void *
- hash_insert_if_absent PARAMS((HT *ht,
- const void *e,
- int *failed));
-
-void *
- hash_delete_if_present PARAMS((HT *ht, const void *e));
-
-void
- hash_print_statistics PARAMS((const HT *ht, FILE *stream));
-
-int
- hash_get_statistics PARAMS((const HT *ht, unsigned int *n_slots_used,
- unsigned int *n_keys,
- unsigned int *max_chain_length));
-
-int
- hash_table_ok PARAMS((HT *ht));
-
-void
- hash_do_for_each PARAMS((HT *ht,
- void (*f) PARAMS((void *e, void *aux)),
- void *aux));
-
-int
- hash_do_for_each_2 PARAMS((HT *ht,
- int (*f) PARAMS((void *e, void *aux)),
- void *aux));
-
-int
- hash_do_for_each_in_selected_bucket PARAMS((HT *ht,
- const void *key,
- int (*f) PARAMS((const void *bucket_key,
- void *e,
- void *aux)),
- void *aux));
-
-void
- hash_clear PARAMS((HT *ht));
-
-void
- hash_free PARAMS((HT *ht));
-
-void
- hash_get_key_list PARAMS((const HT *ht,
- unsigned int bufsize,
- void **buf));
-
-void *
- hash_get_first PARAMS((const HT *ht));
-
-void *
- hash_get_next PARAMS((const HT *ht, const void *e));
-
-/* This interface to hash_insert_if_absent is used frequently enough to
- merit a macro here. */
-
-# define HASH_INSERT_NEW_ITEM(Ht, Item, Failp) \
- do \
- { \
- void *_already; \
- _already = hash_insert_if_absent ((Ht), (Item), Failp); \
- assert (_already == NULL); \
- } \
- while (0)
+struct hash_table
+ {
+ /* The array of buckets starts at BUCKET and extends to BUCKET_LIMIT-1,
+ for a possibility of N_BUCKETS. Among those, N_BUCKETS_USED buckets
+ are not empty, there are N_ENTRIES active entries in the table. */
+ struct hash_entry *bucket;
+ struct hash_entry *bucket_limit;
+ unsigned n_buckets;
+ unsigned n_buckets_used;
+ unsigned n_entries;
+
+ /* Tuning arguments, kept in a physicaly separate structure. */
+ const Hash_tuning *tuning;
+
+ /* Three functions are given to `hash_initialize', see the documentation
+ block for this function. In a word, HASHER randomizes a user entry
+ into a number up from 0 up to some maximum minus 1; COMPARATOR returns
+ true if two user entries compare equally; and DATA_FREER is the cleanup
+ function for a user entry. */
+ Hash_hasher hasher;
+ Hash_comparator comparator;
+ Hash_data_freer data_freer;
+
+ /* A linked list of freed struct hash_entry structs. */
+ struct hash_entry *free_entry_list;
+
+#if USE_OBSTACK
+ /* Whenever obstacks are used, it is possible to allocate all overflowed
+ entries into a single stack, so they all can be freed in a single
+ operation. It is not clear if the speedup is worth the trouble. */
+ struct obstack entry_stack;
+#endif
+ };