Tables

T3.0 contains generalized hash tables. A table associates a key with a value. make-hash-table is the most general way to make a hash table. In addition, the most common types of tables have been predefined.


$\textstyle \parbox{.75in}{\sc Note:}$ $\textstyle \parbox{\notewidth}{\em Tables should be used in place of property lists.}$


(make-hash-tabletype? hash comparator gc? id) procedure
$\Longrightarrow$ table

make-hash-table creates a table which associates keys to values. Any object may be a key or a value.

type?
— is a predicate. All keys in the table must answer true to the predicate type?.

hash
— is a procedure from keys to fixnums which is used to hash the table entries.

comparator
— is an equality predicate on keys.

gc?
— is a boolean value which specifies whether the hash procedure is dependent on the memory location(s) occupied by the object, i.e. whether or not the table must be rehashed after a garbage collection.

id
— is an identifier used by the print method of the table.


(hash-table?object) predicate
$\Longrightarrow$ boolean

hash-table returns true if the object is a hash table.


(table-entrytable key) settable
$\Longrightarrow$ object

table-entry returns the object associated with the key in the table if there is an entry for key, otherwise returns false.


(walk-tableproc table) procedure
$\Longrightarrow$ undefined

walk-table invokes procedure, a procedure of two arguments, on each key, value association in the table. Note that it is an error to perform any operations on the table while walking it.

The following common table types have been predefined as follows:


(make-table. id) procedure
$\Longrightarrow$ table

make-table creates a table in which any object can be a key and eqv? is used as the equality predicate on keys.


(table?object) procedure
$\Longrightarrow$ boolean

table? returns true if the object is an eq? table.


(make-string-table. id) procedure
$\Longrightarrow$ table

make-string-table creates a table in which the keys must be strings and string-equal? is used as the equality predicate on keys.


(string-table?object) procedure
$\Longrightarrow$ boolean

string-table? returns true if the object is a string-table.


(make-symbol-table. id) procedure
$\Longrightarrow$ symbol-table

make-symbol-table creates a table in which the keys must be symbols and eq? is used as the equality predicate on keys.


(symbol-table?object) procedure
$\Longrightarrow$ boolean

symbol-table? returns true if the object is a symbol-table.