source: project/wiki/man/3/Unit srfi-69 @ 14108

Last change on this file since 14108 was 14108, checked in by sjamaan, 11 years ago

Part one of the move; move all manual 3 files tagged 'manual' to man/3

File size: 7.6 KB
Line 
1[[tags: manual]]
2[[toc:]]
3
4== Unit srfi-69
5
6CHICKEN implements SRFI 69 with SRFI 90 extensions. For more information, see
7[[http://srfi.schemers.org/srfi-69/srfi-69.html|SRFI-69]] and
8[[http://srfi.schemers.org/srfi-90/srfi-90.html|SRFI-90]].
9
10
11=== Hash Table Procedures
12
13==== make-hash-table
14
15 [procedure] (make-hash-table [TEST HASH SIZE] #:TEST #:HASH #:SIZE #:INITIAL #:MIN-LOAD #:MAX-LOAD #:WEAK-KEYS #:WEAK-VALUES)
16
17Returns a new {{HASH-TABLE}} with the supplied configuration.
18
19; {{TEST}} : The equivalence function.
20; {{HASH}} : The hash function.
21; {{SIZE}} : The expected number of table elements.
22; {{INITIAL}} : The default initial value.
23; {{MIN-LOAD}} : The minimum load factor. A {{flonum}} in (0.0 1.0).
24; {{MAX-LOAD}} : The maximum load factor. A {{flonum}} in (0.0 1.0).
25; {{WEAK-KEYS}} : Use weak references for keys. (Ignored)
26; {{WEAK-VALUES}} : Use weak references for values. (Ignored)
27
28(No, the keyword parameters are not uppercase.)
29
30
31==== hash-table?
32
33 [procedure] (hash-table? OBJECT)
34
35Is the {{OBJECT}} a {{hash-table}}?
36
37
38==== hash-table-size
39
40 [procedure] (hash-table-size HASH-TABLE)
41
42The {{HASH-TABLE}} size.
43
44
45==== hash-table-equivalence-function
46
47 [procedure] (hash-table-equivalence-function HASH-TABLE)
48
49The {{HASH-TABLE}} {{equivalence-function}}.
50
51
52==== hash-table-hash-function
53
54 [procedure] (hash-table-hash-function HASH-TABLE)
55
56The {{HASH-TABLE}} {{hash-function}}.
57
58
59==== hash-table-min-load
60
61 [procedure] (hash-table-min-load HASH-TABLE)
62
63The {{HASH-TABLE}} minimum load factor.
64
65
66==== hash-table-max-load
67
68 [procedure] (hash-table-max-load HASH-TABLE)
69
70The {{HASH-TABLE}} maximum load factor.
71
72
73==== hash-table-weak-keys
74
75 [procedure] (hash-table-weak-keys HASH-TABLE)
76
77Does the {{HASH-TABLE}} weak references for keys?
78
79
80==== hash-table-weak-values
81
82 [procedure] (hash-table-weak-values HASH-TABLE)
83
84Does the {{HASH-TABLE}} weak references for values?
85
86
87==== hash-table-has-initial?
88
89 [procedure] (hash-table-has-initial? HASH-TABLE)
90
91Does the {{HASH-TABLE}} have a default initial value?
92
93
94==== hash-table-initial
95
96 [procedure] (hash-table-initial HASH-TABLE)
97
98The {{HASH-TABLE}} default initial value.
99
100
101==== hash-table-keys
102
103 [procedure] (hash-table-keys HASH-TABLE)
104
105Returns a list of the keys in the {{HASH-TABLE}} population.
106
107
108==== hash-table-values
109
110 [procedure] (hash-table-values HASH-TABLE)
111
112Returns a list of the values in the {{HASH-TABLE}} population.
113
114
115==== hash-table->alist
116
117 [procedure] (hash-table->alist HASH-TABLE)
118
119Returns the population of the {{HASH-TABLE}} as an {{association-list}}.
120
121
122==== alist->hash-table
123
124 [procedure] (alist->hash-table ASSOCIATION-LIST [MAKE-HASH-TABLE-PARAMETER ...])
125
126Returns a new {{HASH-TABLE}}, configured using the optional
127{{MAKE-HASH-TABLE-PARAMETER ...}}. The {{HASH-TABLE}} is populated from the
128{{ASSOCIATION-LIST}}.
129
130
131==== hash-table-ref
132
133 [procedure] (hash-table-ref HASH-TABLE KEY)
134
135Returns the {{VALUE}} for the {{KEY}} in the {{HASH-TABLE}}.
136
137Aborts with an exception when the {{KEY}} is missing.
138
139
140==== hash-table-ref/default
141
142 [procedure] (hash-table-ref/default HASH-TABLE KEY DEFAULT)
143
144Returns the {{VALUE}} for the {{KEY}} in the {{HASH-TABLE}}, or the {{DEFAULT}}
145when the {{KEY}} is missing.
146
147
148==== hash-table-exists?
149
150 [procedure] (hash-table-exists? HASH-TABLE KEY)
151
152Does the {{KEY}} exist in the {{HASH-TABLE}}?
153
154
155==== hash-table-set!
156
157 [procedure] (hash-table-set! HASH-TABLE KEY VALUE)
158
159Set the {{VALUE}} for the {{KEY}} in the {{HASH-TABLE}}.
160
161A setter for {{hash-table-ref}} is defined, so
162
163<enscript highlight=scheme>
164(set! (hash-table-ref HASH-TABLE KEY) VALUE)
165</enscript>
166
167is equivalent to
168
169<enscript highlight=scheme>
170(hash-table-set! HASH-TABLE KEY VALUE)
171</enscript>
172
173
174==== hash-table-update!
175
176 [procedure] (hash-table-update! HASH-TABLE KEY [UPDATE-FUNCTION [DEFAULT-VALUE-FUNCTION]])
177
178Sets or replaces the {{VALUE}} for {{KEY}} in the {{HASH-TABLE}}.
179
180The {{UPDATE-FUNCTION}} takes the existing {{VALUE}} for {{KEY}} and returns
181the new {{VALUE}}. The default is {{identity}}
182
183The {{DEFAULT-VALUE-FUNCTION}} is called when the entry for {{KEY}} is missing.
184The default uses the {{(hash-table-initial-value)}}, if provided. Otherwise
185aborts with an exception.
186
187Returns the new {{VALUE}}.
188
189
190==== hash-table-update!/default
191
192 [procedure] (hash-table-update! HASH-TABLE KEY UPDATE-FUNCTION DEFAULT-VALUE)
193
194Sets or replaces the {{VALUE}} for {{KEY}} in the {{HASH-TABLE}}.
195
196The {{UPDATE-FUNCTION}} takes the existing {{VALUE}} for {{KEY}} and returns
197the new {{VALUE}}.
198
199The {{DEFAULT-VALUE}} is used when the entry for {{KEY}} is missing.
200
201Returns the new {{VALUE}}.
202
203
204==== hash-table-copy
205
206 [procededure] (hash-table-copy HASH-TABLE)
207
208Returns a shallow copy of the {{HASH-TABLE}}.
209
210
211==== hash-table-delete!
212
213 [procedure] (hash-table-delete! HASH-TABLE KEY)
214
215Deletes the entry for {{KEY}} in the {{HASH-TABLE}}.
216
217
218==== hash-table-remove!
219
220 [procedure] (hash-table-remove! HASH-TABLE PROC)
221
222Calls {{PROC}} for all entries in {{HASH-TABLE}} with the key and value of each
223entry. If {{PROC}} returns true, then that entry is removed.
224
225
226==== hash-table-clear!
227
228 [procedure] (hash-table-clear! HASH-TABLE)
229
230Deletes all entries in {{HASH-TABLE}}.
231
232
233==== hash-table-merge
234
235 [procedure] (hash-table-merge HASH-TABLE-1 HASH-TABLE-2)
236
237Returns a new {{HASH-TABLE}} with the union of {{HASH-TABLE-1}} and
238{{HASH-TABLE-2}}.
239
240
241==== hash-table-merge!
242
243 [procedure] (hash-table-merge! HASH-TABLE-1 HASH-TABLE-2)
244
245Returns {{HASH-TABLE-1}} as the union of {{HASH-TABLE-1}} and
246{{HASH-TABLE-2}}.
247
248
249==== hash-table-map
250
251 [procedure] (hash-table-map HASH-TABLE FUNC)
252
253Calls {{FUNC}} for all entries in {{HASH-TABLE}} with the key and value of each
254entry.
255
256Returns a list of the results of each call.
257
258
259==== hash-table-fold
260
261 [procedure] (hash-table-fold HASH-TABLE FUNC INIT)
262
263Calls {{FUNC}} for all entries in {{HASH-TABLE}} with the key and value of each
264entry, and the current folded value. The initial folded value is {{INIT}}.
265
266Returns the final folded value.
267
268
269==== hash-table-for-each
270
271 [procedure] (hash-table-for-each HASH-TABLE PROC)
272
273Calls {{PROC}} for all entries in {{HASH-TABLE}} with the key and value of each
274entry.
275
276
277==== hash-table-walk
278
279 [procedure] (hash-table-walk HASH-TABLE PROC)
280
281Calls {{PROC}} for all entries in {{HASH-TABLE}} with the key and value of each
282entry.
283
284
285=== Hashing Functions
286
287All hash functions return a {{fixnum}} in the range [0 {{BOUND}}).
288
289
290==== number-hash
291
292 [procedure] (number-hash NUMBER [BOUND])
293
294For use with {{=}} as a {{hash-table-equivalence-function}}.
295
296
297==== object-uid-hash
298
299 [procedure] (object-uid-hash OBJECT [BOUND])
300
301Currently a synonym for {{equal?-hash}}.
302
303
304==== symbol-hash
305
306 [procedure] (symbol-hash SYMBOL [BOUND])
307
308For use with {{eq?}} as a {{hash-table-equivalence-function}}.
309
310
311==== keyword-hash
312
313 [procedure] (keyword-hash KEYWORD [BOUND])
314
315For use with {{eq?}} as a {{hash-table-equivalence-function}}.
316
317
318==== string-hash
319
320 [procedure] (string-hash STRING [BOUND])
321
322For use with {{string=?}} as a {{hash-table-equivalence-function}}.
323
324
325==== string-ci-hash
326
327 [procedure] (string-ci-hash STRING [BOUND])
328
329For use with {{string-ci=?}} as a {{hash-table-equivalence-function}}.
330
331
332==== eq?-hash
333
334 [procedure] (eq?-hash OBJECT [BOUND])
335
336For use with {{eq?}} as a {{hash-table-equivalence-function}}.
337
338
339==== eqv?-hash
340
341 [procedure] (eqv?-hash OBJECT [BOUND])
342
343For use with {{eqv?}} as a {{hash-table-equivalence-function}}.
344
345
346==== equal?-hash
347
348 [procedure] (equal?-hash OBJECT [BOUND])
349
350For use with {{equal?}} as a {{hash-table-equivalence-function}}.
351
352
353==== hash
354
355 [procedure] (hash OBJECT [BOUND])
356
357Synonym for {{equal?-hash}}.
358
359
360==== hash-by-identity
361
362 [procedure] (hash-by-identity OBJECT [BOUND])
363
364Synonym for {{eq?-hash}}.
365
366Previous: [[Unit srfi-14]]
367Next: [[Unit match]]
368
Note: See TracBrowser for help on using the repository browser.