48 |
|
|
49 |
#include "libguile/__scm.h" |
#include "libguile/__scm.h" |
50 |
|
|
51 |
|
#include "weaks.h" |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
#define SCM_HASHTABLEF_WEAK_CAR SCM_WVECTF_WEAK_KEY |
56 |
|
#define SCM_HASHTABLEF_WEAK_CDR SCM_WVECTF_WEAK_VALUE |
57 |
|
|
58 |
|
#define SCM_HASHTABLE_P(x) SCM_TYP16_PREDICATE (scm_tc16_hashtable, x) |
59 |
|
#define SCM_VALIDATE_HASHTABLE(pos, arg) \ |
60 |
|
SCM_MAKE_VALIDATE_MSG (pos, arg, HASHTABLE_P, "hash-table") |
61 |
|
#define SCM_HASHTABLE_VECTOR(h) SCM_CELL_OBJECT_1 (h) |
62 |
|
#define SCM_SET_HASHTABLE_VECTOR(x, v) SCM_SET_CELL_OBJECT_1 (x, v) |
63 |
|
#define SCM_HASHTABLE(x) ((scm_t_hashtable *) SCM_CELL_WORD_2 (x)) |
64 |
|
#define SCM_HASHTABLE_NEXT(x) SCM_CELL_OBJECT_3 (x) |
65 |
|
#define SCM_HASHTABLE_NEXTLOC(x) ((SCM *) SCM_CELL_WORD_LOC (x, 3)) |
66 |
|
#define SCM_SET_HASHTABLE_NEXT(x, n) SCM_SET_CELL_OBJECT_3 (x, n) |
67 |
|
#define SCM_HASHTABLE_FLAGS(x) (SCM_HASHTABLE (x)->flags) |
68 |
|
#define SCM_HASHTABLE_WEAK_KEY_P(x) \ |
69 |
|
(SCM_HASHTABLE_FLAGS (x) & SCM_HASHTABLEF_WEAK_CAR) |
70 |
|
#define SCM_HASHTABLE_WEAK_VALUE_P(x) \ |
71 |
|
(SCM_HASHTABLE_FLAGS (x) & SCM_HASHTABLEF_WEAK_CDR) |
72 |
|
#define SCM_HASHTABLE_DOUBLY_WEAK_P(x) \ |
73 |
|
((SCM_HASHTABLE_FLAGS (x) \ |
74 |
|
& (SCM_HASHTABLEF_WEAK_CAR | SCM_HASHTABLEF_WEAK_CDR)) \ |
75 |
|
== (SCM_HASHTABLEF_WEAK_CAR | SCM_HASHTABLEF_WEAK_CDR)) |
76 |
|
#define SCM_HASHTABLE_WEAK_P(x) SCM_HASHTABLE_FLAGS (x) |
77 |
|
#define SCM_HASHTABLE_N_ITEMS(x) (SCM_HASHTABLE (x)->n_items) |
78 |
|
#define SCM_SET_HASHTABLE_N_ITEMS(x, n) (SCM_HASHTABLE (x)->n_items = n) |
79 |
|
#define SCM_HASHTABLE_INCREMENT(x) (SCM_HASHTABLE_N_ITEMS(x)++) |
80 |
|
#define SCM_HASHTABLE_DECREMENT(x) (SCM_HASHTABLE_N_ITEMS(x)--) |
81 |
|
#define SCM_HASHTABLE_UPPER(x) (SCM_HASHTABLE (x)->upper) |
82 |
|
#define SCM_HASHTABLE_LOWER(x) (SCM_HASHTABLE (x)->lower) |
83 |
|
|
84 |
|
#define SCM_HASHTABLE_N_BUCKETS(h) \ |
85 |
|
SCM_VECTOR_LENGTH (SCM_HASHTABLE_VECTOR (h)) |
86 |
|
#define SCM_HASHTABLE_BUCKETS(h) SCM_VELTS (SCM_HASHTABLE_VECTOR (h)) |
87 |
|
#define SCM_SET_HASHTABLE_BUCKET(h, i, x) \ |
88 |
|
SCM_VECTOR_SET (SCM_HASHTABLE_VECTOR (h), i, x) |
89 |
|
|
90 |
|
typedef struct scm_t_hashtable { |
91 |
|
int flags; /* properties of table */ |
92 |
|
unsigned long n_items; /* number of items in table */ |
93 |
|
unsigned long lower; /* when to shrink */ |
94 |
|
unsigned long upper; /* when to grow */ |
95 |
|
int size_index; /* index into hashtable_size */ |
96 |
|
int min_size_index; /* minimum size_index */ |
97 |
|
unsigned long (*hash_fn) (); |
98 |
|
void *closure; |
99 |
|
} scm_t_hashtable; |
100 |
|
|
101 |
|
|
102 |
|
|
103 |
#if 0 |
#if 0 |
108 |
|
|
109 |
SCM_API SCM scm_vector_to_hash_table (SCM vector); |
SCM_API SCM scm_vector_to_hash_table (SCM vector); |
110 |
SCM_API SCM scm_c_make_hash_table (unsigned long k); |
SCM_API SCM scm_c_make_hash_table (unsigned long k); |
|
SCM_API SCM scm_c_make_resizing_hash_table (void); |
|
111 |
SCM_API SCM scm_make_hash_table (SCM n); |
SCM_API SCM scm_make_hash_table (SCM n); |
112 |
|
SCM_API SCM scm_make_weak_key_hash_table (SCM k); |
113 |
|
SCM_API SCM scm_make_weak_value_hash_table (SCM k); |
114 |
|
SCM_API SCM scm_make_doubly_weak_hash_table (SCM k); |
115 |
|
|
116 |
|
SCM_API SCM scm_hash_table_p (SCM h); |
117 |
|
SCM_API SCM scm_weak_key_hash_table_p (SCM h); |
118 |
|
SCM_API SCM scm_weak_value_hash_table_p (SCM h); |
119 |
|
SCM_API SCM scm_doubly_weak_hash_table_p (SCM h); |
120 |
|
|
121 |
|
SCM_API void scm_i_rehash (SCM table, unsigned long (*hash_fn)(), void *closure, const char*func_name); |
122 |
|
|
123 |
SCM_API SCM scm_hash_fn_get_handle (SCM table, SCM obj, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); |
SCM_API SCM scm_hash_fn_get_handle (SCM table, SCM obj, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); |
124 |
SCM_API SCM scm_hash_fn_create_handle_x (SCM table, SCM obj, SCM init, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); |
SCM_API SCM scm_hash_fn_create_handle_x (SCM table, SCM obj, SCM init, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); |
126 |
SCM_API SCM scm_hash_fn_set_x (SCM table, SCM obj, SCM val, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); |
SCM_API SCM scm_hash_fn_set_x (SCM table, SCM obj, SCM val, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), void * closure); |
127 |
SCM_API SCM scm_hash_fn_remove_x (SCM table, SCM obj, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), SCM (*delete_fn) (), void * closure); |
SCM_API SCM scm_hash_fn_remove_x (SCM table, SCM obj, unsigned long (*hash_fn) (), SCM (*assoc_fn) (), SCM (*delete_fn) (), void * closure); |
128 |
SCM_API SCM scm_internal_hash_fold (SCM (*fn) (), void *closure, SCM init, SCM table); |
SCM_API SCM scm_internal_hash_fold (SCM (*fn) (), void *closure, SCM init, SCM table); |
129 |
|
SCM_API SCM scm_hash_clear_x (SCM table); |
130 |
|
|
131 |
SCM_API SCM scm_hashq_get_handle (SCM table, SCM obj); |
SCM_API SCM scm_hashq_get_handle (SCM table, SCM obj); |
132 |
SCM_API SCM scm_hashq_create_handle_x (SCM table, SCM obj, SCM init); |
SCM_API SCM scm_hashq_create_handle_x (SCM table, SCM obj, SCM init); |
149 |
SCM_API SCM scm_hashx_set_x (SCM hash, SCM assoc, SCM table, SCM obj, SCM val); |
SCM_API SCM scm_hashx_set_x (SCM hash, SCM assoc, SCM table, SCM obj, SCM val); |
150 |
SCM_API SCM scm_hashx_remove_x (SCM hash, SCM assoc, SCM del, SCM table, SCM obj); |
SCM_API SCM scm_hashx_remove_x (SCM hash, SCM assoc, SCM del, SCM table, SCM obj); |
151 |
SCM_API SCM scm_hash_fold (SCM proc, SCM init, SCM hash); |
SCM_API SCM scm_hash_fold (SCM proc, SCM init, SCM hash); |
152 |
|
SCM_API SCM scm_hash_for_each (SCM proc, SCM hash); |
153 |
|
SCM_API SCM scm_hash_map (SCM proc, SCM hash); |
154 |
|
SCM_API void scm_hashtab_prehistory (void); |
155 |
SCM_API void scm_init_hashtab (void); |
SCM_API void scm_init_hashtab (void); |
156 |
|
|
157 |
#endif /* SCM_HASHTAB_H */ |
#endif /* SCM_HASHTAB_H */ |