From a3b49c17e2b5700fb886ab4cf71e2a964dce891e Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Mon, 7 Jun 2004 19:54:30 +0000 Subject: [PATCH] Reflect new hash-table implementation. --- v7/doc/ref-manual/associations.texi | 126 +--------------------------- v7/src/edwin/nntp.scm | 28 +------ v7/src/edwin/snr.scm | 7 +- v7/src/pcsample/pcscobl.scm | 20 ++--- v7/src/win32/win_ffi.scm | 11 +-- 5 files changed, 23 insertions(+), 169 deletions(-) diff --git a/v7/doc/ref-manual/associations.texi b/v7/doc/ref-manual/associations.texi index b6cc797bf..982d8070c 100644 --- a/v7/doc/ref-manual/associations.texi +++ b/v7/doc/ref-manual/associations.texi @@ -1,9 +1,9 @@ @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 @@ -397,7 +397,6 @@ necessary to call @code{load-option} prior to using hash tables.) * 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 @@ -783,7 +782,7 @@ the table, but it usually changes the physical size of the table, which 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 @@ -833,125 +832,6 @@ This procedure is the key-hashing procedure used by @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 diff --git a/v7/src/edwin/nntp.scm b/v7/src/edwin/nntp.scm index f8c64d859..5a3287427 100644 --- a/v7/src/edwin/nntp.scm +++ b/v7/src/edwin/nntp.scm @@ -1,6 +1,6 @@ #| -*-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 @@ -51,7 +51,7 @@ USA. (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)) @@ -183,18 +183,6 @@ USA. ;;;; 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)) @@ -549,17 +537,7 @@ USA. 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))) diff --git a/v7/src/edwin/snr.scm b/v7/src/edwin/snr.scm index 0f117115b..1826b82da 100644 --- a/v7/src/edwin/snr.scm +++ b/v7/src/edwin/snr.scm @@ -1,8 +1,9 @@ #| -*-Scheme-*- -$Id: snr.scm,v 1.64 2003/02/14 18:28:13 cph Exp $ +$Id: snr.scm,v 1.65 2004/06/07 19:49:55 cph Exp $ -Copyright 1995-2001 Massachusetts Institute of Technology +Copyright 1995,1996,1997,1998,1999,2000 Massachusetts Institute of Technology +Copyright 2001,2003,2004 Massachusetts Institute of Technology This file is part of MIT/GNU Scheme. @@ -3268,7 +3269,7 @@ C-c C-q mail-fill-yanked-message (fill what was yanked)." (and (pair? (news-group:ignored-subjects group)) (news-group:get-ignored-subjects group #f)))) (and table - (let ((entries (hash-table/entries-list table)) + (let ((entries (hash-table->alist table)) (t (- (get-universal-time) (* (ref-variable news-group-ignored-subject-retention #f) diff --git a/v7/src/pcsample/pcscobl.scm b/v7/src/pcsample/pcscobl.scm index 4d18a552b..45a6bf61f 100644 --- a/v7/src/pcsample/pcscobl.scm +++ b/v7/src/pcsample/pcscobl.scm @@ -1,8 +1,8 @@ #| -*-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. @@ -715,31 +715,31 @@ USA. (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) diff --git a/v7/src/win32/win_ffi.scm b/v7/src/win32/win_ffi.scm index 1f7653110..d72c9e72c 100644 --- a/v7/src/win32/win_ffi.scm +++ b/v7/src/win32/win_ffi.scm @@ -1,8 +1,9 @@ #| -*-Scheme-*- -$Id: win_ffi.scm,v 1.13 2003/04/25 03:54:44 cph Exp $ +$Id: win_ffi.scm,v 1.14 2004/06/07 19:49:15 cph Exp $ Copyright 1993,1994,1998,2001,2002,2003 Massachusetts Institute of Technology +Copyright 2004 Massachusetts Institute of Technology This file is part of MIT/GNU Scheme. @@ -145,13 +146,7 @@ USA. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define make-integer-hash-table - (hash-table/constructor modulo - int:= - cons - true - car - cdr - set-cdr!)) + (strong-hash-table/constructor modulo int:= #f)) (define (initialize-wndproc-registry) (set! wndproc-registry (make-integer-hash-table))) -- 2.25.1