Like the association list functions, the hash table functions come
in several varieties:
hashq functions use
eq? to determine whether two
keys match. The
hashv functions use
eqv?, and the
hash functions use
In each of the functions that follow, the table argument must be a vector. The key and value arguments may be any Scheme object.
#fif no default argument is supplied).
The standard hash table functions may be too limited for some applications. For example, you may want a hash table to store strings in a case-insensitive manner, so that references to keys named "foobar", "FOOBAR" and "FooBaR" will all yield the same item. Guile provides you with extended hash tables that permit you to specify a hash function and associator function of your choosing. The functions described in the rest of this section can be used to implement such custom hash table structures.
If you are unfamiliar with the inner workings of hash tables, then this facility will probably be a little too abstract for you to use comfortably. If you are interested in learning more, see an introductory textbook on data structures or algorithms for an explanation of how hash tables are implemented.
set!functions described above, but use hasher as a hash function and assoc to compare keys.
hashermust be a function that takes two arguments, a key to be hashed and a table size.
assocmust be an associator function, like
By way of illustration,
hashq-ref table key is equivalent
hashx-ref hashq assq table key.
-refcousins, but return a handle from the hash table rather than the value associated with key. By convention, a handle in a hash table is the pair which associates a key with a value. Where
hashq-ref table keyreturns only a
hashq-get-handle table keyreturns the pair
(key . value).
Go to the first, previous, next, last section, table of contents.