Previous: Resizing of Hash Tables, Up: Hash Tables [Contents][Index]
The procedures described in this section may be used to make very efficient key-hashing procedures for arbitrary objects. All of these procedures are based on address hashing, which uses the address of an object as its hash number. The great advantage of address hashing is that converting an arbitrary object to a hash number is extremely fast and takes the same amount of time for any object.
The disadvantage of address hashing is that the garbage collector changes the addresses of most objects. The hash-table implementation compensates for this disadvantage by automatically rehashing tables that use address hashing when garbage collections occur. Thus, in order to use these procedures for key hashing, it is necessary to tell the hash-table implementation (by means of the rehash-after-gc? argument to the hash-table type constructors) that the hash numbers computed by your key-hashing procedure must be recomputed after a garbage collection.
These procedures return a hash number for object. The result is
always a non-negative integer, and in the case of eq-hash
, a
non-negative fixnum. Two objects that are equivalent according to
eq?
, eqv?
, or equal?
, respectively, will produce the
same hash number when passed as arguments to these procedures, provided
that the garbage collector does not run during or between the two calls.
The following procedures are the hash functions specified by SRFI 69.
This procedure returns the same value as eq-hash
, optionally
limited by modulus.
This procedure returns the same value as eqv-hash
, optionally
limited by modulus.
This procedure is not specified by SRFI 69.
This procedure returns the same value as equal-hash
, optionally
limited by modulus.
This procedure is called hash
by SRFI 69, but that name was
used for a different purpose by MIT/GNU Scheme long before SRFI 69
was written. The previous use of hash
has been deprecated, but
it will be some time until it can be removed.
The following procedures are the key-hashing procedures used by the standard address-hash-based hash tables. They are
This procedure is the key-hashing procedure used by
make-strong-eq-hash-table
.
This procedure is the key-hashing procedure used by
make-strong-eqv-hash-table
.
This procedure is the key-hashing procedure used by
make-equal-hash-table
.
Previous: Resizing of Hash Tables, Up: Hash Tables [Contents][Index]