Next: , Previous: Hash Tables, Up: Dictionaries


22.7.4 Double-Key Hash Tables

To use double-key hash tables, evaluate the form:

     (use-modules (ice-9 hcons))
Eq? hash-consing

A hash conser maintains a private universe of pairs s.t. if
two cons calls pass eq? arguments, the pairs returned are eq?.

A hash conser does not contribute life to the pairs it returns.
— Scheme Procedure: hashq-cons-hash pair n

Return the hash of pair modulo n. Use an eq? hash of the car and cdr of pair for the computation.

— Scheme Procedure: hashq-cons-assoc key alist

Return the first element in alist whose car and cdr are eq? to that of the pair key. Return #f if no match exists.

— Scheme Procedure: hashq-cons-get-handle table key

Return the handle from hash table whose car and cdr are eq? to that of the pair key.

— Scheme Procedure: hashq-cons-create-handle! table key init

Create a handle in hash table for pair key and store the initial value init there. Return the handle.

— Scheme Procedure: hashq-cons-ref table key

Return the value associated with pair key in hash table, or #f if key is not to be found.

— Scheme Procedure: hashq-cons-set! table key val

In hash table, associate with pair key the value val.

— Scheme Procedure: hashq-cons table a d

Add to hash table an entry for the double-key a and d. The associated value is #f. Return the combined key (pair).

— Scheme Procedure: hashq-conser hash-tab-or-size

Return a procedure that does hashq-cons on hash-tab-or-size. If hash-tab-or-size is a number, allocate and a hash table of that size and use it. The procedure takes two args, a and d, the same as the latter two args of hashq-cons.

[The following proc really doesn't belong here. –ttn]

— Scheme Procedure: make-gc-buffer n

Construct a private ring (circular list) of n elements and return a procedure proc that updates it. proc takes one argument, next, which is added to the ring and also returned. An element added in this way remains referenced for the next n − 1 invocations of proc. To “clear” the ring, consecutively call proc with arg #f at least n times.