XEmacs 21.2.20 "Yoko".
[chise/xemacs-chise.git.1] / src / elhash.h
1 /* Lisp interface to hash tables -- include file.
2    Copyright (C) 1995, 1996 Ben Wing.
3
4 This file is part of XEmacs.
5
6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
10
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING.  If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 /* Synched up with: Not in FSF. */
22
23 #ifndef _XEMACS_ELHASH_H_
24 #define _XEMACS_ELHASH_H_
25
26 DECLARE_LRECORD (hash_table, struct Lisp_Hash_Table);
27
28 #define XHASH_TABLE(x) XRECORD (x, hash_table, struct Lisp_Hash_Table)
29 #define XSETHASH_TABLE(x, p) XSETRECORD (x, p, hash_table)
30 #define HASH_TABLEP(x) RECORDP (x, hash_table)
31 #define CHECK_HASH_TABLE(x) CHECK_RECORD (x, hash_table)
32 #define CONCHECK_HASH_TABLE(x) CONCHECK_RECORD (x, hash_table)
33
34 enum hash_table_weakness
35 {
36   HASH_TABLE_NON_WEAK,
37   HASH_TABLE_KEY_WEAK,
38   HASH_TABLE_VALUE_WEAK,
39   HASH_TABLE_KEY_CAR_WEAK,
40   HASH_TABLE_VALUE_CAR_WEAK,
41   HASH_TABLE_WEAK
42 };
43
44 enum hash_table_test
45 {
46   HASH_TABLE_EQ,
47   HASH_TABLE_EQL,
48   HASH_TABLE_EQUAL
49 };
50
51 extern const struct lrecord_description hash_table_description[];
52
53 EXFUN (Fcopy_hash_table, 1);
54 EXFUN (Fhash_table_count, 1);
55 EXFUN (Fgethash, 3);
56 EXFUN (Fputhash, 3);
57 EXFUN (Fremhash, 2);
58 EXFUN (Fclrhash, 1);
59
60 typedef unsigned long hashcode_t;
61 typedef int (*hash_table_test_function_t) (Lisp_Object obj1, Lisp_Object obj2);
62 typedef unsigned long (*hash_table_hash_function_t) (Lisp_Object obj);
63 typedef int (*maphash_function_t) (Lisp_Object key, Lisp_Object value,
64                                    void* extra_arg);
65
66 struct Lisp_Hash_Table;
67
68 Lisp_Object make_general_lisp_hash_table (enum hash_table_test test,
69                                           size_t size,
70                                           double rehash_size,
71                                           double rehash_threshold,
72                                           enum hash_table_weakness weakness);
73
74 Lisp_Object make_lisp_hash_table (size_t size,
75                                   enum hash_table_weakness weakness,
76                                   enum hash_table_test test);
77
78 void elisp_maphash (maphash_function_t function,
79                     Lisp_Object hash_table, void *extra_arg);
80
81 void elisp_map_remhash (maphash_function_t predicate,
82                         Lisp_Object hash_table, void *extra_arg);
83
84 int finish_marking_weak_hash_tables (void);
85 void prune_weak_hash_tables (void);
86
87 void reorganize_hash_table (struct Lisp_Hash_Table *ht);
88
89 #endif /* _XEMACS_ELHASH_H_ */