[beginnings Panu Kalliokoski **20050223161606 Keywords: (atehwa@sange.fi--2005/hash-srfi--prod--1--patch-1) ] { hunk ./hash-srfi.html 3 - SRFI ?: ??? +SRFI ?: Basic hash tables hunk ./hash-srfi.html 5 - + hunk ./hash-srfi.html 9 -??? From above +Basic hash tables hunk ./hash-srfi.html 13 -??? The author(s) +Panu Kalliokoski hunk ./hash-srfi.html 17 -??? 200-500 word abstract +

This SRFI specifies an API for basic hash tables. Hash tables are +data structures that typically provide a mapping from some set of keys +to some set of values associated to those keys. Hash tables have no +intrinsic order for values, and allow key lookup and destructive +updating in O(1) time. hunk ./hash-srfi.html 25 -??? Optional section that may point out things to be resolved. This - will not appear in the final SRFI. +

There is no single best way to make hash tables. The tables +presented in this SRFI aim at being both conceptually simple and usable +for a wide variety of applications. Even though a portable +implementation is provided, Scheme implementations can speed things up +considerably by e.g. providing an internal hash function for symbols. +Moreover, almost every Scheme implementation already has some kind of +low-level hash table functionality, because that's the natural way to +implement namespaces, and specifically, to provide support for +string->symbol. There might be some benefit in +integration between implementation-specific namespaces and the hash +table API presented here; however, these issues are left open. hunk ./hash-srfi.html 39 -??? detailed rationale +

Hash tables are widely recognised as a fundamental data structure for +many kinds of computational tasks. Every non-minimal Scheme +implementation provides some kind of hash table functionality. hunk ./hash-srfi.html 43 +

Alas, although similar, these hash table APIs have many differences: +some trivial, like the naming of certain functions; some complex, like +revealing different aspects of the internal implementation to the user; +some coarse, like requiring keys to be of some specific type(s); some +subtle, like requiring the user to guess the size of the hash table in +advance to get optimal performance. As a result, the easiest way to +write portable Scheme programs that use hash tables is to implement hash +tables yourself, based on vectors. + +

The primary aim of this SRFI is to provide a simple and generic hash +table API that will answer most of users' needs for basic usage of hash +tables; the reference implementation just shows one way of meeting the +requirements of the API. + hunk ./hash-srfi.html 59 -??? detailed specification +

Names defined in this SRFI: + +

+
Basic type handlers
+
make-hash-table, hash-table?
+
Dealing with single elements
+
hash-table-ref, hash-table-get, hash-table-set!, hash-table-put!, hash-table-delete!, hash-table-remove!, hash-table-exists?
+
Dealing with the whole contents
+
hash-table-count, hash-table-keys, hash-table-values, hash-table-map, hash-table-for-each, hash-table-fold, hash-table->list
+
Hashing
+
hash, string-hash
+
hunk ./hash-srfi.html 87 + +This implementation relies on SRFI-9 for distinctness of the hash table +type. hunk ./hash-srfi.html 123 + }