71 lines
7.9 KiB
HTML
71 lines
7.9 KiB
HTML
|
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
||
|
<HTML>
|
||
|
<HEAD>
|
||
|
<TITLE>CLHS: Function MAKE-HASH-TABLE</TITLE>
|
||
|
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
|
||
|
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
|
||
|
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
|
||
|
<LINK REL=TOP HREF="../Front/index.htm">
|
||
|
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
|
||
|
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
|
||
|
<LINK REL=PREV HREF="t_hash_t.htm">
|
||
|
<LINK REL=UP HREF="c_hash_t.htm">
|
||
|
<LINK REL=NEXT HREF="f_hash_t.htm">
|
||
|
</HEAD>
|
||
|
<BODY>
|
||
|
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="t_hash_t.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_hash_t.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="f_hash_t.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
||
|
|
||
|
<HR>
|
||
|
|
||
|
<A NAME="make-hash-table"><I>Function</I> <B>MAKE-HASH-TABLE</B></A> <P>
|
||
|
<P><B>Syntax:</B><P>
|
||
|
<P>
|
||
|
|
||
|
<B>make-hash-table</B> <I><TT>&key</TT> test size rehash-size rehash-threshold</I> => <I>hash-table</I><P>
|
||
|
<P>
|
||
|
<P><B>Arguments and Values:</B><P>
|
||
|
<P>
|
||
|
<I>test</I>---a <A REL=DEFINITION HREF="26_glo_d.htm#designator"><I>designator</I></A> for one of the <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>functions</I></A> <A REL=DEFINITION HREF="f_eq.htm#eq"><B>eq</B></A>, <A REL=DEFINITION HREF="f_eql.htm#eql"><B>eql</B></A>, <A REL=DEFINITION HREF="f_equal.htm#equal"><B>equal</B></A>, or <A REL=DEFINITION HREF="f_equalp.htm#equalp"><B>equalp</B></A>. The default is <A REL=DEFINITION HREF="f_eql.htm#eql"><B>eql</B></A>. <P>
|
||
|
<I>size</I>---a non-negative <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>. The default is <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A>. <P>
|
||
|
<I>rehash-size</I>---a <A REL=DEFINITION HREF="t_real.htm#real"><I>real</I></A> of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <TT>(or (integer 1 *) (float (1.0) *))</TT>. The default is <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A>. <P>
|
||
|
<I>rehash-threshold</I>---a <A REL=DEFINITION HREF="t_real.htm#real"><I>real</I></A> of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <TT>(real 0 1)</TT>. The default is <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A>. <P>
|
||
|
<I>hash-table</I>---a <A REL=DEFINITION HREF="26_glo_h.htm#hash_table"><I>hash table</I></A>. <P>
|
||
|
<P><B>Description:</B><P>
|
||
|
<P>
|
||
|
Creates and returns a new <A REL=DEFINITION HREF="26_glo_h.htm#hash_table"><I>hash table</I></A>. <P>
|
||
|
<I>test</I> determines how <A REL=DEFINITION HREF="26_glo_k.htm#key"><I>keys</I></A> are compared. An <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> is said to be present in the <I>hash-table</I> if that <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> is the <A REL=DEFINITION HREF="26_glo_s.htm#same"><I>same</I></A> under the <I>test</I> as the <A REL=DEFINITION HREF="26_glo_k.htm#key"><I>key</I></A> for some entry in the <I>hash-table</I>. <P>
|
||
|
<I>size</I> is a hint to the <A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>implementation</I></A> about how much initial space to allocate in the <I>hash-table</I>. This information, taken together with the <I>rehash-threshold</I>, controls the approximate number of entries which it should be possible to insert before the table has to grow. The actual size might be rounded up from <I>size</I> to the next `good' size; for example, some <A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>implementations</I></A> might round to the next prime number. <P>
|
||
|
<I>rehash-size</I> specifies a minimum amount to increase the size of the <I>hash-table</I> when it becomes full enough to require rehashing; see <I>rehash-theshold</I> below. If <I>rehash-size</I> is an <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>, the expected growth rate for the table is additive and the <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A> is the number of entries to add; if it is a <A REL=DEFINITION HREF="26_glo_f.htm#float"><I>float</I></A>, the expected growth rate for the table is multiplicative and the <A REL=DEFINITION HREF="26_glo_f.htm#float"><I>float</I></A> is the ratio of the new size to the old size. As with <I>size</I>, the actual size of the increase might be rounded up. <P>
|
||
|
<I>rehash-threshold</I> specifies how full the <I>hash-table</I> can get before it must grow. It specifies the maximum desired hash-table occupancy level. <P>
|
||
|
The <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>values</I></A> of <I>rehash-size</I> and <I>rehash-threshold</I> do not constrain the <A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>implementation</I></A> to use any particular method for computing when and by how much the size of <I>hash-table</I> should be enlarged. Such decisions are <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A>, and these <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>values</I></A> only hints from the <A REL=DEFINITION HREF="26_glo_p.htm#programmer"><I>programmer</I></A> to the <A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>implementation</I></A>, and the <A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>implementation</I></A> is permitted to ignore them. <P>
|
||
|
<P><B>Examples:</B><P>
|
||
|
<P>
|
||
|
<PRE>
|
||
|
(setq table (make-hash-table)) => #<HASH-TABLE EQL 0/120 46142754>
|
||
|
(setf (gethash "one" table) 1) => 1
|
||
|
(gethash "one" table) => NIL, <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
||
|
(setq table (make-hash-table :test 'equal)) => #<HASH-TABLE EQUAL 0/139 46145547>
|
||
|
(setf (gethash "one" table) 1) => 1
|
||
|
(gethash "one" table) => 1, T
|
||
|
(make-hash-table :rehash-size 1.5 :rehash-threshold 0.7)
|
||
|
=> #<HASH-TABLE EQL 0/120 46156620>
|
||
|
</PRE>
|
||
|
</TT> <P>
|
||
|
<P>
|
||
|
<P><B>Affected By:</B> None.
|
||
|
<P>
|
||
|
<P><B>Exceptional Situations:</B> None.
|
||
|
<P>
|
||
|
<P><B>See Also:</B><P>
|
||
|
<P>
|
||
|
<A REL=DEFINITION HREF="f_gethas.htm#gethash"><B>gethash</B></A>, <A REL=DEFINITION HREF="t_hash_t.htm#hash-table"><B>hash-table</B></A> <P>
|
||
|
<P><B>Notes:</B> None.
|
||
|
<P>
|
||
|
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss189.htm">HASH-TABLE-REHASH-SIZE-INTEGER</A><LI> <A REL=CHILD HREF="../Issues/iss190.htm">HASH-TABLE-SIZE:INTENDED-ENTRIES</A><LI> <A REL=CHILD HREF="../Issues/iss013.htm">ARGUMENTS-UNDERSPECIFIED:SPECIFY</A><LI> <A REL=CHILD HREF="../Issues/iss191.htm">HASH-TABLE-TESTS:ADD-EQUALP</A><P></UL><HR>
|
||
|
|
||
|
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
|
||
|
|
||
|
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
|
||
|
</BODY>
|
||
|
</HTML>
|