Previous: , Up: Hash Tables   [Contents][Index]


11.4.4 Address Hashing

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.

procedure: eq-hash object
procedure: eqv-hash object
procedure: equal-hash object

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.

procedure: hash-by-identity key [modulus]

This SRFI 69 procedure returns the same value as eq-hash, optionally limited by modulus.

procedure: hash key [modulus]

This SRFI 69 procedure returns the same value as equal-hash, optionally limited by modulus.

obsolete procedure: hash-by-eqv key [modulus]

This procedure returns the same value as eqv-hash, optionally limited by modulus.

obsolete procedure: eq-hash-mod object modulus

This procedure is the key-hashing procedure used by make-strong-eq-hash-table.

obsolete procedure: eqv-hash-mod object modulus

This procedure is the key-hashing procedure used by make-strong-eqv-hash-table.

obsolete procedure: equal-hash-mod object modulus

This procedure is the key-hashing procedure used by make-equal-hash-table.


Previous: Resizing of Hash Tables, Up: Hash Tables   [Contents][Index]