Previous: Double-Key Hash Tables, Up: Dictionaries


22.7.5 New Hash Mappings

To create and use new hash table mappings, evaluate the form:

     (use-modules (ice-9 mapping))
— Scheme Procedure: hash-table-mapping [options...]

Return a mapping object, configured by options.

options are alternating keywords and values, passed to make-hash-table. Two keywords are handled specially:

#:hash2 hash2
hash2 is a procedure that takes two arguments, a key and an integer n. It should return an integer modulo n. If unspecified, the default is hash.
#:equal equal
equal is a procedure that takes two arguments and returns non-#f if they are considered to represent the same key. If unspecified, the default is equal?.

The mapping object prints using hash notation:

          (hash-table-mapping #:size 3 #:equal string-ci=?)
          ⇒ #<mapping hash/string-ci=? 3 4022fcf8>
— Scheme Procedure: mapping-get-handle map key

Return the handle from mapping map for key, or #f if key is not in map.

— Scheme Procedure: mapping-create-handle! map key [default]

Return the handle from mapping map for key, or if key is not in map, create a new handle with value default and return the new handle.

— Scheme Procedure: mapping-remove! map key

Remove key and its associated value from mappping map. Return the handle.

— Scheme Procedure: mapping-ref map key [default]

Return the value associated with key in mapping map, or default if there is no such association.

— Scheme Procedure: mapping-set! map key val

Associate key with val in mapping map. Return val.