1 /* Lisp interface to hash tables -- include file.
2 Copyright (C) 1995, 1996 Ben Wing.
4 This file is part of SXEmacs
6 SXEmacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 SXEmacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* Synched up with: Not in FSF. */
22 #ifndef INCLUDED_elhash_h_
23 #define INCLUDED_elhash_h_
25 typedef struct hash_table_s *hash_table_t;
26 typedef struct hentry_s *hentry_t;
28 extern void elhash_reinit(void);
30 typedef int (*hash_table_test_f)(Lisp_Object obj1, Lisp_Object obj2);
31 typedef long unsigned int (*hash_table_hash_f)(Lisp_Object obj);
32 typedef int (*maphash_f)(Lisp_Object key, Lisp_Object value, void*);
34 DECLARE_LRECORD(hash_table, struct hash_table_s);
36 #define XHASH_TABLE(x) XRECORD(x, hash_table, struct hash_table_s)
37 #define XSETHASH_TABLE(x, p) XSETRECORD(x, p, hash_table)
38 #define HASH_TABLEP(x) RECORDP(x, hash_table)
39 #define CHECK_HASH_TABLE(x) CHECK_RECORD(x, hash_table)
40 #define CONCHECK_HASH_TABLE(x) CONCHECK_RECORD(x, hash_table)
42 enum hash_table_weakness {
45 HASH_TABLE_VALUE_WEAK,
46 HASH_TABLE_KEY_VALUE_WEAK,
47 HASH_TABLE_KEY_CAR_WEAK,
48 HASH_TABLE_VALUE_CAR_WEAK,
49 HASH_TABLE_KEY_CAR_VALUE_WEAK,
53 enum hash_table_test {
66 struct lcrecord_header header;
68 /* the sequence category */
70 /* the dict (aset) category */
77 fpfloat rehash_threshold;
79 hash_table_hash_f hash_function;
80 hash_table_test_f test_function;
82 enum hash_table_weakness weakness;
83 Lisp_Object next_weak; /* Used to chain together all of the weak
84 hash tables. Don't mark through this. */
88 #define HENTRY_CLEAR_P(hentry) ((*(EMACS_UINT*)(&((hentry)->key))) == 0)
91 HENTRY_CLEAR_P(const hentry_t h);
93 HENTRY_CLEAR_P(const hentry_t h)
95 return h->key == Qnull_pointer;
98 #define CLEAR_HENTRY(hentry) \
99 ((*(EMACS_UINT*)(&((hentry)->key))) = 0, \
100 (*(EMACS_UINT*)(&((hentry)->value))) = 0)
102 extern const struct lrecord_description hash_table_description[];
104 EXFUN(Fcopy_hash_table, 1);
105 EXFUN(Fhash_table_count, 1);
111 Lisp_Object make_standard_lisp_hash_table(enum hash_table_test test,
114 fpfloat rehash_threshold,
115 enum hash_table_weakness weakness);
117 Lisp_Object make_general_lisp_hash_table(
118 hash_table_hash_f hash_function,
119 hash_table_test_f test_function,
120 size_t size, fpfloat rehash_size, fpfloat rehash_threshold,
121 enum hash_table_weakness weakness);
123 Lisp_Object make_lisp_hash_table(
125 enum hash_table_weakness weakness,
126 enum hash_table_test test);
128 void elisp_maphash(maphash_f function, Lisp_Object ht, void *extra_arg);
129 void elisp_map_remhash(maphash_f predicate, Lisp_Object ht, void *extra_arg);
131 int finish_marking_weak_hash_tables(void);
132 void prune_weak_hash_tables(void);
134 void pdump_reorganize_hash_table(Lisp_Object);
136 #endif /* INCLUDED_elhash_h_ */