Minor edits, mostly aesthetic
[clqr.git] / clqr-hash-tables.tex
blobe92c46ff337bc601ea63aa2824383904ad54624e
1 % Copyright (C) 2008, 2009, 2012 Bert Burgemeister
3 % Permission is granted to copy, distribute and/or modify this
4 % document under the terms of the GNU Free Documentation License,
5 % Version 1.2 or any later version published by the Free Software
6 % Foundation; with no Invariant Sections, no Front-Cover Texts and
7 % no Back-Cover Texts. For details see file COPYING.
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 \section{Hash Tables}
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 The Loop Facility provides additional hash table-related
14 functionality; see \kwd{loop}, page \pageref{section:Loop Facility}.
16 Key-value storage similar to hash tables can as well be achieved using
17 association lists and property lists; see
18 pages \pageref{section:Association Lists} and \pageref{:property_lists}.
21 \begin{LIST}{1cm}
23 \IT{(\FU*{HASH-TABLE-P} \VAR{foo})}
25 Return \retval{\T} if \VAR{foo} is of type \kwd{hash-table}.
28 \IT{(\FU*{MAKE-HASH-TABLE}
29 \orGOO{\kwd{:test }\Goo{\FU{eq}\XOR \FU{eql}\XOR
30 \FU{equal} \XOR \FU{equalp}}\DF{\kwd{\#'eql}}\\
31 \kwd{:size} \VAR{ int}\\
32 \kwd{:rehash-size} \VAR{ num}\\
33 \kwd{:rehash-threshold} \VAR{ num}}{\}})}
35 Make a \retval{hash table}.
38 \IT{(\FU*{GETHASH} \VAR{key} \VAR{hash-table} \Op{\VAR{default}\DF{\NIL}})}
40 Return \retval{object} with \VAR{key} if any or \retval{\VAR{default}}
41 otherwise; and \retvalii{\T} if found, \retvalii{\NIL}
42 otherwise. \kwd{setf}able.
45 \IT{(\FU*{HASH-TABLE-COUNT} \VAR{hash-table})}
47 \retval{Number of entries} in \VAR{hash-table}.
50 \IT{(\FU*{REMHASH} \VAR{key} \DES{\VAR{hash-table}})}
52 Remove from \VAR{hash-table} entry with \VAR{key} and return
53 \retval{\T} if it existed. Return \retval{\NIL} otherwise.
56 \IT{(\FU*{CLRHASH} \DES{\VAR{hash-table}})}
58 Empty \retval{\VAR{hash-table}}.
61 \IT{(\FU*{MAPHASH} \VAR{function} \VAR{hash-table})}
63 Iterate over \VAR{hash-table} calling \VAR{function} on key
64 and value. Return \retval{\NIL}.
67 \IT{(\MC*{WITH-HASH-TABLE-ITERATOR} (\VAR{foo} \VAR{hash-table})
68 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
70 Return \retval{values of \VAR{form}s}. In \VAR{form}s,
71 invocations of (\VAR{foo}) return: \T\ if an entry is returned;
72 its key; its value.
75 \IT{(\FU*{HASH-TABLE-TEST} \VAR{hash-table})}
77 \retval{Test function} used in \VAR{hash-table}.
80 \IT{\arrGOO{(\FU*{HASH-TABLE-SIZE} \VAR{ hash-table})\\
81 (\FU*{HASH-TABLE-REHASH-SIZE} \VAR{ hash-table})\\
82 (\FU*{HASH-TABLE-REHASH-THRESHOLD} \VAR{ hash-table})}{.}}
84 Current \retval{size}, \retval{rehash-size}, or
85 \retval{rehash-threshold}, respectively, as used in \FU{make-hash-table}.
88 \IT{(\FU*{SXHASH} \VAR{foo})}
90 \retval{Hash code} unique for any argument \FU{equal} \VAR{foo}.
93 \end{LIST}
97 %%% Local Variables:
98 %%% mode: latex
99 %%% TeX-master: "clqr"
100 %%% End: