annotate lispref/hash.texi @ 82853:64745654ddea

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Sun, 26 Aug 2007 03:41:50 +0000
parents 6a22a38ae2d2
children a1e16e813aed 4ef881a120fe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 @c -*-texinfo-*-
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 @c This is part of the GNU Emacs Lisp Reference Manual.
75250
6d19c76d81c5 Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents: 71957
diff changeset
3 @c Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005,
6d19c76d81c5 Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents: 71957
diff changeset
4 @c 2006, 2007 Free Software Foundation, Inc.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 @c See the file elisp.texi for copying conditions.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 @setfilename ../info/hash
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 @node Hash Tables, Symbols, Sequences Arrays Vectors, Top
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 @chapter Hash Tables
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 @cindex hash tables
76833
8c3661f15764 Improve indexing.
Eli Zaretskii <eliz@gnu.org>
parents: 75250
diff changeset
10 @cindex lookup tables
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
76833
8c3661f15764 Improve indexing.
Eli Zaretskii <eliz@gnu.org>
parents: 75250
diff changeset
12 A hash table is a very fast kind of lookup table, somewhat like an
8c3661f15764 Improve indexing.
Eli Zaretskii <eliz@gnu.org>
parents: 75250
diff changeset
13 alist (@pxref{Association Lists}) in that it maps keys to
8c3661f15764 Improve indexing.
Eli Zaretskii <eliz@gnu.org>
parents: 75250
diff changeset
14 corresponding values. It differs from an alist in these ways:
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 @itemize @bullet
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 @item
26710
ed440ffea308 (Hash Tables): Note that alists win for small tables.
Dave Love <fx@gnu.org>
parents: 26303
diff changeset
18 Lookup in a hash table is extremely fast for large tables---in fact, the
ed440ffea308 (Hash Tables): Note that alists win for small tables.
Dave Love <fx@gnu.org>
parents: 26303
diff changeset
19 time required is essentially @emph{independent} of how many elements are
ed440ffea308 (Hash Tables): Note that alists win for small tables.
Dave Love <fx@gnu.org>
parents: 26303
diff changeset
20 stored in the table. For smaller tables (a few tens of elements)
ed440ffea308 (Hash Tables): Note that alists win for small tables.
Dave Love <fx@gnu.org>
parents: 26303
diff changeset
21 alists may still be faster because hash tables have a more-or-less
ed440ffea308 (Hash Tables): Note that alists win for small tables.
Dave Love <fx@gnu.org>
parents: 26303
diff changeset
22 constant overhead.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 @item
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 The correspondences in a hash table are in no particular order.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 @item
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 There is no way to share structure between two hash tables,
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 the way two alists can share a common tail.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 @end itemize
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
60446
b26c30e5d770 (Hash Tables): Get rid of "Emacs 21".
Richard M. Stallman <rms@gnu.org>
parents: 60039
diff changeset
32 Emacs Lisp provides a general-purpose hash table data type, along
b26c30e5d770 (Hash Tables): Get rid of "Emacs 21".
Richard M. Stallman <rms@gnu.org>
parents: 60039
diff changeset
33 with a series of functions for operating on them. Hash tables have no
b26c30e5d770 (Hash Tables): Get rid of "Emacs 21".
Richard M. Stallman <rms@gnu.org>
parents: 60039
diff changeset
34 read syntax, and print in hash notation, like this:
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 @example
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 (make-hash-table)
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 @result{} #<hash-table 'eql nil 0/65 0x83af980>
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 @end example
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
26303
9b25d0ffe4ec Patch from rms.
Gerd Moellmann <gerd@gnu.org>
parents: 26182
diff changeset
41 @noindent
9b25d0ffe4ec Patch from rms.
Gerd Moellmann <gerd@gnu.org>
parents: 26182
diff changeset
42 (The term ``hash notation'' refers to the initial @samp{#}
9b25d0ffe4ec Patch from rms.
Gerd Moellmann <gerd@gnu.org>
parents: 26182
diff changeset
43 character---@pxref{Printed Representation}---and has nothing to do with
9b25d0ffe4ec Patch from rms.
Gerd Moellmann <gerd@gnu.org>
parents: 26182
diff changeset
44 the term ``hash table.'')
9b25d0ffe4ec Patch from rms.
Gerd Moellmann <gerd@gnu.org>
parents: 26182
diff changeset
45
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 Obarrays are also a kind of hash table, but they are a different type
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 of object and are used only for recording interned symbols
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (@pxref{Creating Symbols}).
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 @menu
60039
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
51 * Creating Hash:: Functions to create hash tables.
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
52 * Hash Access:: Reading and writing the hash table contents.
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
53 * Defining Hash:: Defining new comparison methods
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
54 * Other Hash:: Miscellaneous.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 @end menu
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 @node Creating Hash
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 @section Creating Hash Tables
77008
6a22a38ae2d2 (Creating Hash): Improve index entry.
Richard M. Stallman <rms@gnu.org>
parents: 76837
diff changeset
59 @cindex creating hash tables
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 The principal function for creating a hash table is
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 @code{make-hash-table}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 @defun make-hash-table &rest keyword-args
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 This function creates a new hash table according to the specified
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 arguments. The arguments should consist of alternating keywords
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (particular symbols recognized specially) and values corresponding to
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 them.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 Several keywords make sense in @code{make-hash-table}, but the only two
26182
3264a26ae355 Fix some typos.
Gerd Moellmann <gerd@gnu.org>
parents: 25875
diff changeset
71 that you really need to know about are @code{:test} and @code{:weakness}.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 @table @code
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 @item :test @var{test}
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 This specifies the method of key lookup for this hash table. The
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 default is @code{eql}; @code{eq} and @code{equal} are other
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 alternatives:
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 @table @code
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 @item eql
53025
53be3d7fa5da (Creating Hash): Clarify description of `eql'. `makehash' is obsolete.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
81 Keys which are numbers are ``the same'' if they are @code{equal}, that
53be3d7fa5da (Creating Hash): Clarify description of `eql'. `makehash' is obsolete.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
82 is, if they are equal in value and either both are integers or both
53037
9958d8677feb *** empty log message ***
Luc Teirlinck <teirllm@auburn.edu>
parents: 53025
diff changeset
83 are floating point numbers; otherwise, two distinct objects are never
71957
61cb5aae3bc3 Put period and comma inside quotes.
Richard M. Stallman <rms@gnu.org>
parents: 71922
diff changeset
84 ``the same.''
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 @item eq
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 Any two distinct Lisp objects are ``different'' as keys.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 @item equal
71957
61cb5aae3bc3 Put period and comma inside quotes.
Richard M. Stallman <rms@gnu.org>
parents: 71922
diff changeset
90 Two Lisp objects are ``the same,'' as keys, if they are equal
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 according to @code{equal}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 @end table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 You can use @code{define-hash-table-test} (@pxref{Defining Hash}) to
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 define additional possibilities for @var{test}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 @item :weakness @var{weak}
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 The weakness of a hash table specifies whether the presence of a key or
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 value in the hash table preserves it from garbage collection.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 The value, @var{weak}, must be one of @code{nil}, @code{key},
30524
62ed067637af *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 26710
diff changeset
102 @code{value}, @code{key-or-value}, @code{key-and-value}, or @code{t}
54263
41fd82e27495 (Creating Hash): Correct the meaning of t for WEAK in make-hash-table.
Richard M. Stallman <rms@gnu.org>
parents: 54031
diff changeset
103 which is an alias for @code{key-and-value}. If @var{weak} is @code{key}
30524
62ed067637af *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 26710
diff changeset
104 then the hash table does not prevent its keys from being collected as
62ed067637af *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 26710
diff changeset
105 garbage (if they are not referenced anywhere else); if a particular key
62ed067637af *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 26710
diff changeset
106 does get collected, the corresponding association is removed from the
62ed067637af *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 26710
diff changeset
107 hash table.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108
30524
62ed067637af *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 26710
diff changeset
109 If @var{weak} is @code{value}, then the hash table does not prevent
62ed067637af *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 26710
diff changeset
110 values from being collected as garbage (if they are not referenced
62ed067637af *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 26710
diff changeset
111 anywhere else); if a particular value does get collected, the
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 corresponding association is removed from the hash table.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
54031
fcad69b9ff7b (Creating Hash): Correct and clarify doc of WEAK values.
Richard M. Stallman <rms@gnu.org>
parents: 53480
diff changeset
114 If @var{weak} is @code{key-and-value} or @code{t}, both the key and
fcad69b9ff7b (Creating Hash): Correct and clarify doc of WEAK values.
Richard M. Stallman <rms@gnu.org>
parents: 53480
diff changeset
115 the value must be live in order to preserve the association. Thus,
fcad69b9ff7b (Creating Hash): Correct and clarify doc of WEAK values.
Richard M. Stallman <rms@gnu.org>
parents: 53480
diff changeset
116 the hash table does not protect either keys or values from garbage
fcad69b9ff7b (Creating Hash): Correct and clarify doc of WEAK values.
Richard M. Stallman <rms@gnu.org>
parents: 53480
diff changeset
117 collection; if either one is collected as garbage, that removes the
fcad69b9ff7b (Creating Hash): Correct and clarify doc of WEAK values.
Richard M. Stallman <rms@gnu.org>
parents: 53480
diff changeset
118 association.
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
119
54031
fcad69b9ff7b (Creating Hash): Correct and clarify doc of WEAK values.
Richard M. Stallman <rms@gnu.org>
parents: 53480
diff changeset
120 If @var{weak} is @code{key-or-value}, either the key or
fcad69b9ff7b (Creating Hash): Correct and clarify doc of WEAK values.
Richard M. Stallman <rms@gnu.org>
parents: 53480
diff changeset
121 the value can preserve the association. Thus, associations are
fcad69b9ff7b (Creating Hash): Correct and clarify doc of WEAK values.
Richard M. Stallman <rms@gnu.org>
parents: 53480
diff changeset
122 removed from the hash table when both their key and value would be
fcad69b9ff7b (Creating Hash): Correct and clarify doc of WEAK values.
Richard M. Stallman <rms@gnu.org>
parents: 53480
diff changeset
123 collected as garbage (if not for references from weak hash tables).
30524
62ed067637af *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents: 26710
diff changeset
124
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 The default for @var{weak} is @code{nil}, so that all keys and values
54031
fcad69b9ff7b (Creating Hash): Correct and clarify doc of WEAK values.
Richard M. Stallman <rms@gnu.org>
parents: 53480
diff changeset
126 referenced in the hash table are preserved from garbage collection.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 @item :size @var{size}
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 This specifies a hint for how many associations you plan to store in the
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 hash table. If you know the approximate number, you can make things a
26182
3264a26ae355 Fix some typos.
Gerd Moellmann <gerd@gnu.org>
parents: 25875
diff changeset
131 little more efficient by specifying it this way. If you specify too
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 small a size, the hash table will grow automatically when necessary, but
26303
9b25d0ffe4ec Patch from rms.
Gerd Moellmann <gerd@gnu.org>
parents: 26182
diff changeset
133 doing that takes some extra time.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 The default size is 65.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 @item :rehash-size @var{rehash-size}
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 When you add an association to a hash table and the table is ``full,''
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 it grows automatically. This value specifies how to make the hash table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 larger, at that time.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
25875
6a17c48b52ef *** empty log message ***
Phillip Rulon <pjr@gnu.org>
parents: 25634
diff changeset
142 If @var{rehash-size} is an integer, it should be positive, and the hash
6a17c48b52ef *** empty log message ***
Phillip Rulon <pjr@gnu.org>
parents: 25634
diff changeset
143 table grows by adding that much to the nominal size. If
6a17c48b52ef *** empty log message ***
Phillip Rulon <pjr@gnu.org>
parents: 25634
diff changeset
144 @var{rehash-size} is a floating point number, it had better be greater
6a17c48b52ef *** empty log message ***
Phillip Rulon <pjr@gnu.org>
parents: 25634
diff changeset
145 than 1, and the hash table grows by multiplying the old size by that
6a17c48b52ef *** empty log message ***
Phillip Rulon <pjr@gnu.org>
parents: 25634
diff changeset
146 number.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 The default value is 1.5.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 @item :rehash-threshold @var{threshold}
60039
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
151 This specifies the criterion for when the hash table is ``full'' (so
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
152 it should be made larger). The value, @var{threshold}, should be a
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
153 positive floating point number, no greater than 1. The hash table is
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
154 ``full'' whenever the actual number of entries exceeds this fraction
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
155 of the nominal size. The default for @var{threshold} is 0.8.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 @end table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 @defun makehash &optional test
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 This is equivalent to @code{make-hash-table}, but with a different style
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 argument list. The argument @var{test} specifies the method
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 of key lookup.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
53025
53be3d7fa5da (Creating Hash): Clarify description of `eql'. `makehash' is obsolete.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
164 This function is obsolete. Use @code{make-hash-table} instead.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 @node Hash Access
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 @section Hash Table Access
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 This section describes the functions for accessing and storing
60039
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
171 associations in a hash table. In general, any Lisp object can be used
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
172 as a hash key, unless the comparison method imposes limits. Any Lisp
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
173 object can also be used as the value.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 @defun gethash key table &optional default
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 This function looks up @var{key} in @var{table}, and returns its
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 associated @var{value}---or @var{default}, if @var{key} has no
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 association in @var{table}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 38786
diff changeset
181 @defun puthash key value table
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 This function enters an association for @var{key} in @var{table}, with
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 value @var{value}. If @var{key} already has an association in
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 @var{table}, @var{value} replaces the old associated value.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 @defun remhash key table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 This function removes the association for @var{key} from @var{table}, if
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 there is one. If @var{key} has no association, @code{remhash} does
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 nothing.
53025
53be3d7fa5da (Creating Hash): Clarify description of `eql'. `makehash' is obsolete.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
191
53be3d7fa5da (Creating Hash): Clarify description of `eql'. `makehash' is obsolete.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
192 @b{Common Lisp note:} In Common Lisp, @code{remhash} returns
53be3d7fa5da (Creating Hash): Clarify description of `eql'. `makehash' is obsolete.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
193 non-@code{nil} if it actually removed an association and @code{nil}
53be3d7fa5da (Creating Hash): Clarify description of `eql'. `makehash' is obsolete.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
194 otherwise. In Emacs Lisp, @code{remhash} always returns @code{nil}.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 @defun clrhash table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 This function removes all the associations from hash table @var{table},
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 so that it becomes empty. This is also called @dfn{clearing} the hash
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 table.
53025
53be3d7fa5da (Creating Hash): Clarify description of `eql'. `makehash' is obsolete.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
201
53be3d7fa5da (Creating Hash): Clarify description of `eql'. `makehash' is obsolete.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
202 @b{Common Lisp note:} In Common Lisp, @code{clrhash} returns the empty
53be3d7fa5da (Creating Hash): Clarify description of `eql'. `makehash' is obsolete.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
203 @var{table}. In Emacs Lisp, it returns @code{nil}.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205
56215
c9aa4127a482 Reposition @anchor's.
Luc Teirlinck <teirllm@auburn.edu>
parents: 54263
diff changeset
206 @defun maphash function table
53480
879f6aa2d2c7 (Hash Access): Add anchor.
Luc Teirlinck <teirllm@auburn.edu>
parents: 53037
diff changeset
207 @anchor{Definition of maphash}
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 This function calls @var{function} once for each of the associations in
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 @var{table}. The function @var{function} should accept two
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 arguments---a @var{key} listed in @var{table}, and its associated
60039
d1e57e5b8403 (Hash Tables): Add desc to menu items.
Richard M. Stallman <rms@gnu.org>
parents: 56215
diff changeset
211 @var{value}. @code{maphash} returns @code{nil}.
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 @node Defining Hash
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 @section Defining Hash Comparisons
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 @cindex hash code
76837
4f96f3f74c69 Improve indexing.
Eli Zaretskii <eliz@gnu.org>
parents: 76833
diff changeset
217 @cindex define hash comparisons
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 You can define new methods of key lookup by means of
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 @code{define-hash-table-test}. In order to use this feature, you need
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 to understand how hash tables work, and what a @dfn{hash code} means.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 You can think of a hash table conceptually as a large array of many
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 slots, each capable of holding one association. To look up a key,
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 @code{gethash} first computes an integer, the hash code, from the key.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 It reduces this integer modulo the length of the array, to produce an
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 index in the array. Then it looks in that slot, and if necessary in
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 other nearby slots, to see if it has found the key being sought.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 Thus, to define a new method of key lookup, you need to specify both a
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 function to compute the hash code from a key, and a function to compare
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 two keys directly.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 @defun define-hash-table-test name test-fn hash-fn
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 This function defines a new hash table test, named @var{name}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 After defining @var{name} in this way, you can use it as the @var{test}
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 argument in @code{make-hash-table}. When you do that, the hash table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 will use @var{test-fn} to compare key values, and @var{hash-fn} to compute
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 a ``hash code'' from a key value.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 The function @var{test-fn} should accept two arguments, two keys, and
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 return non-@code{nil} if they are considered ``the same.''
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 The function @var{hash-fn} should accept one argument, a key, and return
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 an integer that is the ``hash code'' of that key. For good results, the
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 function should use the whole range of integer values for hash codes,
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 including negative integers.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 The specified functions are stored in the property list of @var{name}
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 under the property @code{hash-table-test}; the property value's form is
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 @code{(@var{test-fn} @var{hash-fn})}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 @defun sxhash obj
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 This function returns a hash code for Lisp object @var{obj}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 This is an integer which reflects the contents of @var{obj}
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 and the other Lisp objects it points to.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 If two objects @var{obj1} and @var{obj2} are equal, then @code{(sxhash
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 @var{obj1})} and @code{(sxhash @var{obj2})} are the same integer.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 If the two objects are not equal, the values returned by @code{sxhash}
53025
53be3d7fa5da (Creating Hash): Clarify description of `eql'. `makehash' is obsolete.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
264 are usually different, but not always; once in a rare while, by luck,
53be3d7fa5da (Creating Hash): Clarify description of `eql'. `makehash' is obsolete.
Luc Teirlinck <teirllm@auburn.edu>
parents: 52401
diff changeset
265 you will encounter two distinct-looking objects that give the same
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 result from @code{sxhash}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
269 This example creates a hash table whose keys are strings that are
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
270 compared case-insensitively.
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
271
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
272 @example
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
273 (defun case-fold-string= (a b)
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
274 (compare-strings a nil nil b nil nil t))
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
275 (defun case-fold-string-hash (a)
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
276 (sxhash (upcase a)))
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
277
64842
0021965e29a2 (Defining Hash): Delete stray paren in example.
Richard M. Stallman <rms@gnu.org>
parents: 60446
diff changeset
278 (define-hash-table-test 'case-fold
0021965e29a2 (Defining Hash): Delete stray paren in example.
Richard M. Stallman <rms@gnu.org>
parents: 60446
diff changeset
279 'case-fold-string= 'case-fold-string-hash)
38786
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
280
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
281 (make-hash-table :test 'case-fold)
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
282 @end example
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
283
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
284 Here is how you could define a hash table test equivalent to the
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
285 predefined test value @code{equal}. The keys can be any Lisp object,
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
286 and equal-looking objects are considered the same key.
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
287
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
288 @example
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
289 (define-hash-table-test 'contents-hash 'equal 'sxhash)
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
290
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
291 (make-hash-table :test 'contents-hash)
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
292 @end example
4d3fd773cd30 Minor cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 30524
diff changeset
293
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 @node Other Hash
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 @section Other Hash Table Functions
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 Here are some other functions for working with hash tables.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 @defun hash-table-p table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 This returns non-@code{nil} if @var{table} is a hash table object.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
301 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 @defun copy-hash-table table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 This function creates and returns a copy of @var{table}. Only the table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 itself is copied---the keys and values are shared.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 @defun hash-table-count table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 This function returns the actual number of entries in @var{table}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311
26182
3264a26ae355 Fix some typos.
Gerd Moellmann <gerd@gnu.org>
parents: 25875
diff changeset
312 @defun hash-table-test table
25875
6a17c48b52ef *** empty log message ***
Phillip Rulon <pjr@gnu.org>
parents: 25634
diff changeset
313 This returns the @var{test} value that was given when @var{table} was
6a17c48b52ef *** empty log message ***
Phillip Rulon <pjr@gnu.org>
parents: 25634
diff changeset
314 created, to specify how to hash and compare keys. See
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 @code{make-hash-table} (@pxref{Creating Hash}).
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 @defun hash-table-weakness table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 This function returns the @var{weak} value that was specified for hash
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 table @var{table}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 @defun hash-table-rehash-size table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 This returns the rehash size of @var{table}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 @defun hash-table-rehash-threshold table
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 This returns the rehash threshold of @var{table}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 @end defun
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330
26182
3264a26ae355 Fix some typos.
Gerd Moellmann <gerd@gnu.org>
parents: 25875
diff changeset
331 @defun hash-table-size table
25634
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 This returns the current nominal size of @var{table}.
0d3bc0a437c4 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 @end defun
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51585
diff changeset
334
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51585
diff changeset
335 @ignore
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51585
diff changeset
336 arch-tag: 3b5107f9-d2f0-47d5-ad61-3498496bea0e
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51585
diff changeset
337 @end ignore