diff options
author | Richard M. Stallman <rms@gnu.org> | 2001-08-12 21:15:14 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2001-08-12 21:15:14 +0000 |
commit | a9749dabdf94b72b99a3adf3f1bbe88c12fffc31 (patch) | |
tree | d8b585ffe60af485f7dbd6ed435a2cc5a6bf41cd /lispref/hash.texi | |
parent | fafee57973c1e467ee4233a9812e34c8187a0e71 (diff) | |
download | emacs-a9749dabdf94b72b99a3adf3f1bbe88c12fffc31.tar.gz |
Minor cleanups.
Diffstat (limited to 'lispref/hash.texi')
-rw-r--r-- | lispref/hash.texi | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/lispref/hash.texi b/lispref/hash.texi index 3f4e4380be6..4b12160c603 100644 --- a/lispref/hash.texi +++ b/lispref/hash.texi @@ -107,13 +107,14 @@ values from being collected as garbage (if they are not referenced anywhere else); if a particular value does get collected, the corresponding association is removed from the hash table. -If @var{weak} is @code{key-or-value}, associations are removed from the -hash table when either their key or their value part would be collected -as garbage, not counting references to the key and value from weak hash -tables. Likewise, if @var{weak} is @code{key-and-value}, associations -are removed from the hash table when both their key and value would be -collected as garbage, again not considering references to the key and -value from weak hash tables. +If @var{weak} is @code{key-or-value} or @code{t}, the hash table does +not protect either keys or values from garbage collection; if either +one is collected as garbage, the association is removed. + +If @var{weak} is @code{key-and-value}, associations are removed from +the hash table when both their key and value would be collected as +garbage, again not considering references to the key and value from +weak hash tables. The default for @var{weak} is @code{nil}, so that all keys and values referenced in the hash table are preserved from garbage collection. If @@ -242,8 +243,24 @@ including negative integers. The specified functions are stored in the property list of @var{name} under the property @code{hash-table-test}; the property value's form is @code{(@var{test-fn} @var{hash-fn})}. +@end defun + +@tindex sxhash +@defun sxhash obj +This function returns a hash code for Lisp object @var{obj}. +This is an integer which reflects the contents of @var{obj} +and the other Lisp objects it points to. + +If two objects @var{obj1} and @var{obj2} are equal, then @code{(sxhash +@var{obj1})} and @code{(sxhash @var{obj2})} are the same integer. + +If the two objects are not equal, the values returned by @code{sxhash} +are usually different, but not always; but once in a rare while, by +luck, you will encounter two distinct-looking objects that give the same +result from @code{sxhash}. +@end defun -This example creates a hash table whose keys are strings that are + This example creates a hash table whose keys are strings that are compared case-insensitively. @example @@ -258,22 +275,16 @@ compared case-insensitively. (make-hash-table :test 'case-fold) @end example -@end defun -@tindex sxhash -@defun sxhash obj -This function returns a hash code for Lisp object @var{obj}. -This is an integer which reflects the contents of @var{obj} -and the other Lisp objects it points to. + Here is how you could define a hash table test equivalent to the +predefined test value @code{equal}. The keys can be any Lisp object, +and equal-looking objects are considered the same key. -If two objects @var{obj1} and @var{obj2} are equal, then @code{(sxhash -@var{obj1})} and @code{(sxhash @var{obj2})} are the same integer. +@example +(define-hash-table-test 'contents-hash 'equal 'sxhash) -If the two objects are not equal, the values returned by @code{sxhash} -are usually different, but not always; but once in a rare while, by -luck, you will encounter two distinct-looking objects that give the same -result from @code{sxhash}. -@end defun +(make-hash-table :test 'contents-hash) +@end example @node Other Hash @section Other Hash Table Functions |