
Next: Weak Boxes
Up: Programming Constructs
Previous: Directories
MzScheme provides efficient built-in hash tables. Key comparisons
use eq?.
- (make-hash-table) creates and
returns a new hash table.
item (make-hash-table-weak) creates
a hash table with weakly-held keys (see section 2.21). - (hash-table? v) returns
#t if v was created by make-hash-table or
#f otherwise.
- (hash-table-put! table
key value) puts the specified value in the table, overwriting
any existing assignments for the key.
- (hash-table-get table key
failure-thunk) gets the value for the specified key. If no
value is found for key, then failure-thunk is invoked. The
failure-thunk argument is optional; if it is not specified, the
exn:misc:hash-table exception is raised when no value is found for key.
- (hash-table-remove! table
key) removes the value assignment of key if it
exists in the 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
a 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 a value.
PLT