From 7cce5c98a35a5875df085a7241477b939af712f1 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 8 Nov 2009 19:06:57 +0000 Subject: [PATCH] further clarify performance guarantee of immutable hash tables svn: r16620 --- collects/scribblings/reference/hashes.scrbl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/collects/scribblings/reference/hashes.scrbl b/collects/scribblings/reference/hashes.scrbl index 56f8da31cb..4555878bae 100644 --- a/collects/scribblings/reference/hashes.scrbl +++ b/collects/scribblings/reference/hashes.scrbl @@ -21,11 +21,16 @@ A @deftech{hash table} (or simply @deftech{hash}) maps each of its keys to a single value. For a given hash table, keys are equivalent via @scheme[equal?], @scheme[eqv?], or @scheme[eq?], and keys are retained either strongly or weakly (see @secref["weakbox"]). A hash -table is also either mutable or immutable. Immutable tables support -constant-time access and update, just like mutable hash tables; the -constant on immutable operations is usually larger, but the -functional nature of immutable hash tables can pay off in certain -algorithms. +table is also either mutable or immutable. Immutable hash tables +support effectively constant-time access and update, just like mutable +hash tables; the constant on immutable operations is usually larger, +but the functional nature of immutable hash tables can pay off in +certain algorithms. + +@margin-note{Immutable hash tables actually provide @math{O(log N)} +access and update. Since @math{N} is limited by the address space so +that @math{log N} is limited to less than 30 or 62 (depending on the +platform), @math{log N} can be treated reasonably as a constant.} A hash table can be used as a two-valued @tech{sequence} (see @secref["sequences"]). The keys and values of the hash table serve as @@ -51,7 +56,7 @@ a table-specific semaphore as needed. Three caveats apply, however: @item{If a thread is terminated while applying @scheme[hash-ref], @scheme[hash-set!], @scheme[hash-remove!], @scheme[hash-ref!], - or @scheme[has-update!] to a hash table that + or @scheme[hash-update!] to a hash table that uses @scheme[equal?] or @scheme[eqv?] key comparisons, all current and future operations on the hash table may block indefinitely.}