Next: Structures
Up: Basic Data Extensions
Previous: Promises
MzScheme provides efficient built-in hash tables. Key comparisons use
eq?.
- (make-hash-table) creates and
returns a new hash table.
- (make-hash-table-weak) creates
a hash table with weakly-held keys (see section 12.1).
- (hash-table? v) returns
#t if v was created by make-hash-table or
make-hash-table-weak, #f otherwise.
- (hash-table-put! table key value) maps key to value in table,
overwriting any existing mapping for key.
- (hash-table-get table key [failure-thunk]) returns the value for key in table. If no
value is found for key, then the result of invoking failure-thunk
(a procedure of no argments) is returned. If failure-thunk
is not provided, the exn:misc:hash-table exception is raised if no
value is found for key.
- (hash-table-remove! table key) removes the value mapping for key if it
exists in table.
- (hash-table-map table f)
applies the procedure f to each element in table, accumulating
the results into a list. The procedure f must take two arguments: a key and
its value.
- (hash-table-for-each table f) applies the procedure f to each element in table
(for the side-effects of f) and returns void. The
procedure f must take two arguments: a key and its value.
PLT