Changes between Version 64 and Version 65 of HashTablesCowan
 Timestamp:
 06/13/13 22:05:19 (4 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

HashTablesCowan
v64 v65 36 36 * The `hashtablewalk` procedure places the hash table argument first and the walker procedure second. It has been renamed `hashtableforeach` and given the same argument order as `foreach`, `stringforeach`, and so on. However, unlike those procedures it can only accept one hash table: coordinated access to multiple hash tables is meaningless, given that hash tables are unordered. 37 37 38 * The `hashtablefold` procedure places the hash table argument first. For the same reasons as the above, it has been changed to place itlast.38 * The SRFI 69 `hashtablefold` procedure places the hash table argument first. For the same reasons as the above, in this proposal it appears last. 39 39 40 40 * The `hashtablemerge!` procedure has been renamed `hashtableunion!`, since it causes the first hash table to become the union of the two hash table arguments. A third argument specifying how to merge the values has been added. … … 76 76 * The `hashtablefind` procedure is from [http://www.iro.umontreal.ca/~gambit/doc/gambitc.html#Tables Gambit]. 77 77 78 * The procedures `hashtablesetentries!` a nd `hashtablesetentries` are inspired by the [http://clhs.lisp.se/Body/f_pairli.htm Common Lisp] function `pairlis`.78 * The procedures `hashtablesetentries!` are inspired by the [http://clhs.lisp.se/Body/f_pairli.htm Common Lisp] function `pairlis`. 79 79 80 80 * The procedures `hashtableunfold` and `hashtablecount` were suggested by [http://srfi.schemers.org/srfi1/srfi1.html SRFI 1]. … … 96 96 == Specification == 97 97 98 The procedures in the present proposal are in the `(s cheme hashtables)` and `(srfi xxx)` libraries (or `(srfi :xxx)` on R6RS). However, the library in the sample implementation isnamed `(hashtables)`.98 The procedures in the present proposal are in the `(srfi xxx)` library (or `(srfi :xxx)` on R6RS). However, the library in the sample implementation is currently named `(hashtables)`. 99 99 100 100 All references to "executing in expected amortized constant time" presuppose that a satisfactory hash function has been supplied by the user. Arbitrary or nonidempotent hash functions can make a hash of the implementation. 101 101 102 Hash tables are allowed to cache the results of calling the equality and hash functions, so programs cannot rely on the hash function being called exactly once for every primitive hash table operation: it may be called zero, one, or more times.103 104 No procedure passed to `hashtablefind`, `hashtablecount`, `hashtablemap`, `hashtableforeach`, `hashtableupdateeach!`, `hashtablemap>list`, or `hashtablefold` may mutate the hash table being walked , with the exception of changing the value of the association currently being processed.102 Hash tables are allowed to cache the results of calling the equality predicate and hash function, so programs cannot rely on the hash function being called exactly once for every primitive hash table operation: it may be called zero, one, or more times. 103 104 No procedure passed to `hashtablefind`, `hashtablecount`, `hashtablemap`, `hashtableforeach`, `hashtableupdateeach!`, `hashtablemap>list`, or `hashtablefold` may mutate the hash table being walked. 105 105 106 106 Here is an index to the procedures of this specification: … … 187 187 Repeatedly mutates ''hashtable'', setting each ''key'' to the ''value'' that follows it. 188 188 189 `(hashtablesetentries! `''hashtable keys list valueslist''`)`190 191 Repeatedly mutates ''hashtable'', setting each element of ''keys list'' to the corresponding element of ''valueslist'' in the order given.189 `(hashtablesetentries! `''hashtable keyslist valueslist''`)` 190 191 Repeatedly mutates ''hashtable'', setting each element of ''keyslist'' to the corresponding element of ''valueslist'' in the order given. 192 192 193 193 `(hashtablesetalist! `''hashtable alist''`)` … … 199 199 Deletes any association to ''key'' in ''hashtable'' and returns true if there was an association for ''key'', false if not. Must execute in expected amortized constant time. (SRFI 69 `hashtabledelete!`; R6RS `hashtabledelete!`; Common Lisp `remhash`) 200 200 201 `(hashtabledeletekeys! `''hashtable key list''`)`201 `(hashtabledeletekeys! `''hashtable keyslist''`)` 202 202 203 203 Semantically equivalent to, but may be implemented more efficiently than, the following code: 204 204 205 `(foreach (lambda (key) (hashtabledelete `''hashtable''` key)) `''key list''`)`205 `(foreach (lambda (key) (hashtabledelete `''hashtable''` key)) `''keyslist''`)` 206 206 207 207 `(hashtableextend! `''hashtable key'' [ ''failure'' [ ''success'' ] ]`)` … … 302 302 `(hashtableupdateeach! `''proc hashtable''`)` 303 303 304 Calls ''proc'' for every association in ''hashtable'' with two arguments: the key of the association and the value of the association. The value returned by ''proc'' is used to update the association. Returns an unspecified value.304 Calls ''proc'' for every association in ''hashtable'' with two arguments: the key of the association and the value of the association. The value returned by ''proc'' is used to update the value of the association. Returns an unspecified value. 305 305 306 306 `(hashtablemap>list `''proc hashtable''`)` … … 342 342 `(hashtableunion! `''hashtable,,1,, hashtable,,2,,'' [ ''merger'' ]`)` 343 343 344 Adds the associations of ''hashtable,,2,,'' to ''hashtable,,1,,'' and returns ''hashtable,,1,,''. The values are merged using the result of invokingthe ''merger'' procedure, which accepts the arguments ''key,,1,, value,,1,, key,,2,, value,,2,,'' and defaults to `(lambda (key1 value1 key2 value2) value2)`. (SRFI 69 `hashtablemerge!`)344 Adds the associations of ''hashtable,,2,,'' to ''hashtable,,1,,'' and returns ''hashtable,,1,,''. The values of keys that appear in both hash tables are set to the result of the ''merger'' procedure, which accepts the arguments ''key,,1,, value,,1,, key,,2,, value,,2,,'' and defaults to `(lambda (key1 value1 key2 value2) value2)`. (SRFI 69 `hashtablemerge!`) 345 345 346 346 `(hashtableintersection! `''hashtable,,1,, hashtable,,2,,'' [ ''merger'' ]`)` 347 347 348 Deletes the associations from ''hashtable,,1,,'' which don't also appear in ''hashtable,,2,,'' and returns ''hashtable,,1,,'', and merges the values of those that appear in both hash tables usingthe result of invoking the ''merger'' procedure, which accepts the arguments ''key,,1,, value,,1,, key,,2,, value,,2,,'' and defaults to `(lambda (key1 value1 key2 value2) value2)`.348 Deletes the associations from ''hashtable,,1,,'' which don't also appear in ''hashtable,,2,,'' and returns ''hashtable,,1,,'', and sets the values of those keys that appear in both hash tables to the result of invoking the ''merger'' procedure, which accepts the arguments ''key,,1,, value,,1,, key,,2,, value,,2,,'' and defaults to `(lambda (key1 value1 key2 value2) value2)`. 349 349 350 350 `(hashtabledifference! `''hashtable,,1,, hashtable,,2,,''`)`