@c This file is part of the MIT/GNU Scheme Reference Manual.
-@c $Id: associations.texi,v 1.1 2003/04/15 03:29:22 cph Exp $
+@c $Id: associations.texi,v 1.2 2004/06/07 19:48:33 cph Exp $
@c Copyright 1991,1992,1993,1994,1995 Massachusetts Institute of Technology
@c Copyright 1996,1997,1999,2000,2001 Massachusetts Institute of Technology
-@c Copyright 2002,2003 Massachusetts Institute of Technology
+@c Copyright 2002,2003,2004 Massachusetts Institute of Technology
@c See file scheme.texinfo for copying conditions.
@node Associations, Procedures, Miscellaneous Datatypes, Top
* Basic Hash Table Operations::
* Resizing of Hash Tables::
* Address Hashing::
-* Low-Level Hash Table Operations::
@end menu
@node Construction of Hash Tables, Basic Hash Table Operations, Hash Tables, Hash Tables
causes the table to be rehashed.
@end deffn
-@node Address Hashing, Low-Level Hash Table Operations, Resizing of Hash Tables, Hash Tables
+@node Address Hashing, , Resizing of Hash Tables, Hash Tables
@subsection Address Hashing
@cindex address hashing
@code{make-equal-hash-table}.
@end deffn
-@node Low-Level Hash Table Operations, , Address Hashing, Hash Tables
-@subsection Low-Level Hash Table Operations
-
-The procedures in this section allow the programmer to control some of
-the internal structure of a hash table. Normally, hash tables maintain
-associations between keys and datums using pairs or weak pairs. These
-procedures allow the programmer to specify the use of some other data
-structure to maintain the association. In this section, the data
-structure that represents an association in a hash table is called an
-@dfn{entry}.
-
-@deffn procedure hash-table/constructor key-hash key=? make-entry entry-valid? entry-key entry-datum set-entry-datum! [rehash-after-gc?]
-Creates and returns a hash-table constructor procedure
-(@pxref{Construction of Hash Tables}). The arguments define the
-characteristics of the hash table as follows:
-
-@table @var
-@item key-hash
-The hashing procedure. A procedure that accepts two arguments, a key and
-an exact positive integer (the @dfn{modulus}), and returns an exact
-non-negative integer that is less than the modulus.
-
-@item key=?
-A equivalence predicate that accepts two keys and is true iff they are
-the same key. If this predicate is true of two keys, then
-@var{key-hash} must return the same value for each of these keys (given
-the same modulus in both cases).
-
-@item make-entry
-A procedure that accepts a key and a datum as arguments and returns a
-newly allocated entry.
-
-@item entry-valid?
-A procedure that accepts an entry and returns @code{#f} iff the entry's
-key has been reclaimed by the garbage collector. Instead of a
-procedure, this may be @code{#t}, which is equivalent to @code{(lambda
-(entry) #t)}.
-@findex weak-pair/car?
-
-@item entry-key
-A procedure that accepts an entry as an argument and returns the entry's
-key.
-
-@item entry-datum
-A procedure that accepts an entry as an argument and returns the entry's
-datum.
-
-@item set-entry-datum!
-A procedure that accepts an entry and an object as arguments, modifies
-the entry's datum to be the object, and returns an unspecified
-result.
-
-@item rehash-after-gc?
-An optional argument that, if true, says the values returned by
-@var{key-hash} might change after a garbage collection. If so, the
-hash-table implementation arranges for the table to be rehashed when
-necessary. (@xref{Address Hashing}, for information about hash
-procedures that have this property.) Otherwise, it is assumed that
-@var{key-hash} always returns the same value for the same arguments.
-The default value of this argument is @code{#f}.
-@end table
-@end deffn
-
-@noindent
-For example, here is how the constructors for ordinary hash tables could
-be defined:
-
-@example
-@group
-(define (strong-hash-table/constructor key-hash key=?
- #!optional rehash-after-gc?)
- (hash-table/constructor key-hash key=?
- cons #t car cdr set-cdr!
- (if (default-object? rehash-after-gc?)
- #f
- rehash-after-gc?)))
-@end group
-
-@group
-(define (weak-hash-table/constructor key-hash key=?
- #!optional rehash-after-gc?)
- (hash-table/constructor key-hash key=? weak-cons weak-pair/car?
- weak-car weak-cdr weak-set-cdr!
- (if (default-object? rehash-after-gc?)
- #f
- rehash-after-gc?)))
-@end group
-@end example
-
-@deffn procedure hash-table/key-hash hash-table
-@deffnx procedure hash-table/key=? hash-table
-@deffnx procedure hash-table/make-entry hash-table
-@deffnx procedure hash-table/entry-valid? hash-table
-@deffnx procedure hash-table/entry-key hash-table
-@deffnx procedure hash-table/entry-datum hash-table
-@deffnx procedure hash-table/set-entry-datum! hash-table
-Each procedure returns the value of the corresponding argument that was
-used to construct @var{hash-table}.
-@end deffn
-
-The following procedures return the contents of a hash table as a
-collection of entries. While the data structure holding the entries is
-newly allocated, the entries themselves are not copied. Since hash
-table operations can modify these entries, the entries should be copied
-if it is desired to keep them while continuing to modify the table.
-
-@deffn procedure hash-table/entries-list hash-table
-Returns a newly allocated list of the entries in @var{hash-table}.
-@end deffn
-
-@deffn procedure hash-table/entries-vector hash-table
-Returns a newly allocated vector of the entries in @var{hash-table}.
-Equivalent to
-
-@example
-(list->vector (hash-table/entries-list @var{hash-table}))
-@end example
-@end deffn
-
@node Object Hashing, Red-Black Trees, Hash Tables, Associations
@section Object Hashing
#| -*-Scheme-*-
-$Id: nntp.scm,v 1.28 2004/02/17 05:52:20 cph Exp $
+$Id: nntp.scm,v 1.29 2004/06/07 19:49:38 cph Exp $
Copyright 1995,1996,1997,1998,1999,2003 Massachusetts Institute of Technology
Copyright 2004 Massachusetts Institute of Technology
(change-hook #f read-only #t)
(port #f)
(banner #f)
- (group-table (make-group-hash-table) read-only #t)
+ (group-table (make-string-hash-table) read-only #t)
(reader-hook #f)
(current-group #f))
\f
;;;; Group Cache
-(define make-group-hash-table
- (hash-table/constructor string-hash-mod
- string=?
- (lambda (name group) name group)
- (lambda (group) group #t)
- (lambda (group) (news-group:name group))
- (lambda (group) group)
- (lambda (group group*)
- group group*
- (error "Can't redefine a named group:" group*))
- #f))
-
(define (find-news-group connection name)
(hash-table/get (nntp-connection:group-table connection) name #f))
table)))
(define make-header-hash-table
- (hash-table/constructor remainder
- =
- (lambda (number header) number header)
- (lambda (header) header #t)
- (lambda (header) (news-header:number header))
- (lambda (header) header)
- (lambda (header header*)
- header header*
- (error "Can't redefine a numbered header:"
- header*))
- #f))
+ (strong-hash-table/constructor remainder = #f))
(define (news-group:header group number)
(let ((table (news-group:header-table group)))
#| -*-Scheme-*-
-$Id: pcscobl.scm,v 1.4 2003/02/14 18:28:31 cph Exp $
+$Id: pcscobl.scm,v 1.5 2004/06/07 19:54:30 cph Exp $
-Copyright (c) 1993, 1999 Massachusetts Institute of Technology
+Copyright 1993,1999,2004 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
(define (purified-proc-cobl-profile-table)
(purified-code-block-profile-buffer/flush)
- (hash-table/entries-vector *purified-proc-cobl-profile-table*))
+ (hash-table->alist *purified-proc-cobl-profile-table*))
(define ( heathen-proc-cobl-profile-table)
( heathen-code-block-profile-buffer/flush)
- (hash-table/entries-vector *heathen-proc-cobl-profile-table*))
+ (hash-table->alist *heathen-proc-cobl-profile-table*))
(define (purified-dbg-cobl-profile-table)
(purified-code-block-profile-buffer/flush)
- (hash-table/entries-vector *purified-dbg-cobl-profile-table*))
+ (hash-table->alist *purified-dbg-cobl-profile-table*))
(define ( heathen-dbg-cobl-profile-table)
( heathen-code-block-profile-buffer/flush)
- (hash-table/entries-vector *heathen-dbg-cobl-profile-table*))
+ (hash-table->alist *heathen-dbg-cobl-profile-table*))
(define (purified-raw-cobl-profile-table)
(purified-code-block-profile-buffer/flush)
- (hash-table/entries-vector *purified-raw-cobl-profile-table*))
+ (hash-table->alist *purified-raw-cobl-profile-table*))
(define ( heathen-raw-cobl-profile-table)
( heathen-code-block-profile-buffer/flush)
- (hash-table/entries-vector *heathen-raw-cobl-profile-table*))
+ (hash-table->alist *heathen-raw-cobl-profile-table*))
(define (purified-trampoline-profile-table)
(purified-code-block-profile-buffer/flush)
- (hash-table/entries-vector *purified-trampoline-profile-table*))
+ (hash-table->alist *purified-trampoline-profile-table*))
(define ( heathen-trampoline-profile-table)
( heathen-code-block-profile-buffer/flush)
- (hash-table/entries-vector *heathen-trampoline-profile-table*))
+ (hash-table->alist *heathen-trampoline-profile-table*))
(define (code-block-profile-table/old)