comparison man/lispref/hash-tables.texi @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 3ecd8885ac67
children e6dec75ded0e
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
87 the factor by which to increase the size of the hash table when enlarging. 87 the factor by which to increase the size of the hash table when enlarging.
88 88
89 Keyword @code{:rehash-threshold} must be a float between 0.0 and 1.0, 89 Keyword @code{:rehash-threshold} must be a float between 0.0 and 1.0,
90 and specifies the load factor of the hash table which triggers enlarging. 90 and specifies the load factor of the hash table which triggers enlarging.
91 91
92 Keyword @code{:weakness} can be @code{nil} (default), @code{t}, 92 Non-standard keyword @code{:weakness} can be @code{nil} (default),
93 @code{key} or @code{value}. 93 @code{t}, @code{key-and-value}, @code{key}, @code{value} or
94 94 @code{key-or-value}. @code{t} is an alias for @code{key-and-value}.
95 A weak hash table is one whose pointers do not count as GC referents: 95
96 for any key-value pair in the hash table, if the only remaining pointer 96 A key-and-value-weak hash table, also known as a fully-weak or simply
97 to either the key or the value is in a weak hash table, then the pair 97 as a weak hash table, is one whose pointers do not count as GC
98 will be removed from the hash table, and the key and value collected. 98 referents: for any key-value pair in the hash table, if the only
99 A non-weak hash table (or any other pointer) would prevent the object 99 remaining pointer to either the key or the value is in a weak hash
100 from being collected. 100 table, then the pair will be removed from the hash table, and the key
101 and value collected. A non-weak hash table (or any other pointer)
102 would prevent the object from being collected.
101 103
102 A key-weak hash table is similar to a fully-weak hash table except that 104 A key-weak hash table is similar to a fully-weak hash table except that
103 a key-value pair will be removed only if the key remains unmarked 105 a key-value pair will be removed only if the key remains unmarked
104 outside of weak hash tables. The pair will remain in the hash table if 106 outside of weak hash tables. The pair will remain in the hash table if
105 the key is pointed to by something other than a weak hash table, even 107 the key is pointed to by something other than a weak hash table, even
108 A value-weak hash table is similar to a fully-weak hash table except 110 A value-weak hash table is similar to a fully-weak hash table except
109 that a key-value pair will be removed only if the value remains 111 that a key-value pair will be removed only if the value remains
110 unmarked outside of weak hash tables. The pair will remain in the 112 unmarked outside of weak hash tables. The pair will remain in the
111 hash table if the value is pointed to by something other than a weak 113 hash table if the value is pointed to by something other than a weak
112 hash table, even if the key is not. 114 hash table, even if the key is not.
115
116 A key-or-value-weak hash table is similar to a fully-weak hash table except
117 that a key-value pair will be removed only if the value and the key remain
118 unmarked outside of weak hash tables. The pair will remain in the
119 hash table if the value or key are pointed to by something other than a weak
120 hash table, even if the other is not.
113 @end defun 121 @end defun
114 122
115 @defun copy-hash-table hash-table 123 @defun copy-hash-table hash-table
116 This function returns a new hash table which contains the same keys and 124 This function returns a new hash table which contains the same keys and
117 values as @var{hash-table}. The keys and values will not themselves be 125 values as @var{hash-table}. The keys and values will not themselves be
202 table ensures that these objects are collected normally rather than 210 table ensures that these objects are collected normally rather than
203 remaining around forever, long past their actual period of use. 211 remaining around forever, long past their actual period of use.
204 (Otherwise, you'd have to explicitly map over the hash table every so 212 (Otherwise, you'd have to explicitly map over the hash table every so
205 often and remove unnecessary elements.) 213 often and remove unnecessary elements.)
206 214
207 There are three types of weak hash tables: 215 There are four types of weak hash tables:
208 216
209 @table @asis 217 @table @asis
210 @item fully weak hash tables 218 @item key-and-value-weak hash tables
211 In these hash tables, a pair disappears if either the key or the value 219 In these hash tables, also known as fully weak or simply as weak hash
212 is unreferenced outside of the table. 220 tables, a pair disappears if either the key or the value is unreferenced
221 outside of the table.
213 @item key-weak hash tables 222 @item key-weak hash tables
214 In these hash tables, a pair disappears if the key is unreferenced outside 223 In these hash tables, a pair disappears if the key is unreferenced outside
215 of the table, regardless of how the value is referenced. 224 of the table, regardless of how the value is referenced.
216 @item value-weak hash tables 225 @item value-weak hash tables
217 In these hash tables, a pair disappears if the value is unreferenced outside 226 In these hash tables, a pair disappears if the value is unreferenced outside
218 of the table, regardless of how the key is referenced. 227 of the table, regardless of how the key is referenced.
228 @item key-or-value-weak hash tables
229 In these hash tables, a pair disappears if both the key and the value
230 are unreferenced outside of the table.
219 @end table 231 @end table
220 232
221 Also see @ref{Weak Lists}. 233 Also see @ref{Weak Lists}.
222 234
223 Weak hash tables are created by specifying the @code{:weakness} keyword to 235 Weak hash tables are created by specifying the @code{:weakness} keyword to