\section{include/sphinxbase/hash\+\_\+table.h File Reference}
\label{hash__table_8h}\index{include/sphinxbase/hash\+\_\+table.\+h@{include/sphinxbase/hash\+\_\+table.\+h}}


Hash table implementation.  


{\ttfamily \#include $<$sphinxbase/sphinxbase\+\_\+export.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/prim\+\_\+type.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/glist.\+h$>$}\newline
\subsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ hash\+\_\+entry\+\_\+s}
\begin{DoxyCompactList}\small\item\em A note by A\+R\+C\+H\+AN at 20050510\+: Technically what we use is so-\/called \char`\"{}hash table with buckets\char`\"{} which is very nice way to deal with external hashing. \end{DoxyCompactList}\item 
struct \textbf{ hash\+\_\+table\+\_\+t}
\item 
struct \textbf{ hash\+\_\+iter\+\_\+s}
\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{hash__table_8h_ac98525ff8ec582358783aecbd388842d}} 
\#define \textbf{ hash\+\_\+entry\+\_\+val}(e)~((e)-\/$>$val)
\begin{DoxyCompactList}\small\item\em Access macros. \end{DoxyCompactList}\item 
\mbox{\label{hash__table_8h_aa9ff378b212469b2ec6dde13b6f0934b}} 
\#define {\bfseries hash\+\_\+entry\+\_\+key}(e)~((e)-\/$>$key)
\item 
\mbox{\label{hash__table_8h_a4c0d92dd662edb83d572dc2fef278816}} 
\#define {\bfseries hash\+\_\+entry\+\_\+len}(e)~((e)-\/$>$len)
\item 
\mbox{\label{hash__table_8h_a47264dff359c0a0d4c144e54d0819ce9}} 
\#define {\bfseries hash\+\_\+table\+\_\+inuse}(h)~((h)-\/$>$inuse)
\item 
\mbox{\label{hash__table_8h_aa0d9d0efddc207e3d7be3c417dcd7128}} 
\#define {\bfseries hash\+\_\+table\+\_\+size}(h)~((h)-\/$>$size)
\item 
\mbox{\label{hash__table_8h_a30fbbcfa2a2d360c2a8960b960ae34a3}} 
\#define {\bfseries H\+A\+S\+H\+\_\+\+C\+A\+S\+E\+\_\+\+Y\+ES}~0
\item 
\mbox{\label{hash__table_8h_aec1a9795611575f717b08d2bad5d6f83}} 
\#define {\bfseries H\+A\+S\+H\+\_\+\+C\+A\+S\+E\+\_\+\+NO}~1
\item 
\#define \textbf{ hash\+\_\+table\+\_\+enter\+\_\+int32}(h,  k,  v)~((int32)(long)\textbf{ hash\+\_\+table\+\_\+enter}((h),(k),(void $\ast$)(long)(v)))
\begin{DoxyCompactList}\small\item\em Add a 32-\/bit integer value to a hash table. \end{DoxyCompactList}\item 
\#define \textbf{ hash\+\_\+table\+\_\+replace\+\_\+int32}(h,  k,  v)~((int32)(long)\textbf{ hash\+\_\+table\+\_\+replace}((h),(k),(void $\ast$)(long)(v)))
\begin{DoxyCompactList}\small\item\em Replace a 32-\/bit integer value in a hash table. \end{DoxyCompactList}\item 
\#define \textbf{ hash\+\_\+table\+\_\+enter\+\_\+bkey\+\_\+int32}(h,  k,  l,  v)~((int32)(long)\textbf{ hash\+\_\+table\+\_\+enter\+\_\+bkey}((h),(k),(l),(void $\ast$)(long)(v)))
\begin{DoxyCompactList}\small\item\em Enter a 32-\/bit integer value in a hash table. \end{DoxyCompactList}\item 
\#define \textbf{ hash\+\_\+table\+\_\+replace\+\_\+bkey\+\_\+int32}(h,  k,  l,  v)~((int32)(long)\textbf{ hash\+\_\+table\+\_\+replace\+\_\+bkey}((h),(k),(l),(void $\ast$)(long)(v)))
\begin{DoxyCompactList}\small\item\em Replace a 32-\/bit integer value in a hash table. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef struct \textbf{ hash\+\_\+entry\+\_\+s} \textbf{ hash\+\_\+entry\+\_\+t}
\begin{DoxyCompactList}\small\item\em A note by A\+R\+C\+H\+AN at 20050510\+: Technically what we use is so-\/called \char`\"{}hash table with buckets\char`\"{} which is very nice way to deal with external hashing. \end{DoxyCompactList}\item 
\mbox{\label{hash__table_8h_a8febad57d856465fb33dd11cabc57dcc}} 
typedef struct \textbf{ hash\+\_\+iter\+\_\+s} {\bfseries hash\+\_\+iter\+\_\+t}
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ hash\+\_\+table\+\_\+t} $\ast$ \textbf{ hash\+\_\+table\+\_\+new} (int32 size, int32 casearg)
\begin{DoxyCompactList}\small\item\em Allocate a new hash table for a given expected size. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ hash\+\_\+table\+\_\+free} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h)
\begin{DoxyCompactList}\small\item\em Free the specified hash table; the caller is responsible for freeing the key strings pointed to by the table entries. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void $\ast$ \textbf{ hash\+\_\+table\+\_\+enter} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h, const char $\ast$key, void $\ast$val)
\begin{DoxyCompactList}\small\item\em Try to add a new entry with given key and associated value to hash table h. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void $\ast$ \textbf{ hash\+\_\+table\+\_\+replace} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h, const char $\ast$key, void $\ast$val)
\begin{DoxyCompactList}\small\item\em Add a new entry with given key and value to hash table h. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void $\ast$ \textbf{ hash\+\_\+table\+\_\+delete} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h, const char $\ast$key)
\begin{DoxyCompactList}\small\item\em Delete an entry with given key and associated value to hash table h. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void $\ast$ \textbf{ hash\+\_\+table\+\_\+delete\+\_\+bkey} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h, const char $\ast$key, size\+\_\+t len)
\begin{DoxyCompactList}\small\item\em Like hash\+\_\+table\+\_\+delete, but with an explicitly specified key length, instead of a N\+U\+L\+L-\/terminated, C-\/style key string. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ hash\+\_\+table\+\_\+empty} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h)
\begin{DoxyCompactList}\small\item\em Delete all entries from a hash\+\_\+table. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void $\ast$ \textbf{ hash\+\_\+table\+\_\+enter\+\_\+bkey} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h, const char $\ast$key, size\+\_\+t len, void $\ast$val)
\begin{DoxyCompactList}\small\item\em Like hash\+\_\+table\+\_\+enter, but with an explicitly specified key length, instead of a N\+U\+L\+L-\/terminated, C-\/style key string. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void $\ast$ \textbf{ hash\+\_\+table\+\_\+replace\+\_\+bkey} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h, const char $\ast$key, size\+\_\+t len, void $\ast$val)
\begin{DoxyCompactList}\small\item\em Like hash\+\_\+table\+\_\+replace, but with an explicitly specified key length, instead of a N\+U\+L\+L-\/terminated, C-\/style key string. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ hash\+\_\+table\+\_\+lookup} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h, const char $\ast$key, void $\ast$$\ast$val)
\begin{DoxyCompactList}\small\item\em Look up a key in a hash table and optionally return the associated value. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ hash\+\_\+table\+\_\+lookup\+\_\+int32} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h, const char $\ast$key, int32 $\ast$val)
\begin{DoxyCompactList}\small\item\em Look up a 32-\/bit integer value in a hash table. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ hash\+\_\+table\+\_\+lookup\+\_\+bkey} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h, const char $\ast$key, size\+\_\+t len, void $\ast$$\ast$val)
\begin{DoxyCompactList}\small\item\em Like hash\+\_\+lookup, but with an explicitly specified key length, instead of a N\+U\+L\+L-\/terminated, C-\/style key string. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ hash\+\_\+table\+\_\+lookup\+\_\+bkey\+\_\+int32} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h, const char $\ast$key, size\+\_\+t len, int32 $\ast$val)
\begin{DoxyCompactList}\small\item\em Look up a 32-\/bit integer value in a hash table. \end{DoxyCompactList}\item 
\mbox{\label{hash__table_8h_aae6e6373d3c371d57861a9a875edb207}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ hash\+\_\+iter\+\_\+t} $\ast$ \textbf{ hash\+\_\+table\+\_\+iter} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h)
\begin{DoxyCompactList}\small\item\em Start iterating over key-\/value pairs in a hash table. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ hash\+\_\+iter\+\_\+t} $\ast$ \textbf{ hash\+\_\+table\+\_\+iter\+\_\+next} (\textbf{ hash\+\_\+iter\+\_\+t} $\ast$itor)
\begin{DoxyCompactList}\small\item\em Get the next key-\/value pair in iteration. \end{DoxyCompactList}\item 
\mbox{\label{hash__table_8h_a7aa43b228d7dc24f5221d281debeb025}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ hash\+\_\+table\+\_\+iter\+\_\+free} (\textbf{ hash\+\_\+iter\+\_\+t} $\ast$itor)
\begin{DoxyCompactList}\small\item\em Delete an unfinished iterator. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ glist\+\_\+t} \textbf{ hash\+\_\+table\+\_\+tolist} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h, int32 $\ast$count)
\begin{DoxyCompactList}\small\item\em Build a glist of valid hash\+\_\+entry\+\_\+t pointers from the given hash table. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ hash\+\_\+table\+\_\+display} (\textbf{ hash\+\_\+table\+\_\+t} $\ast$h, int32 showkey)
\begin{DoxyCompactList}\small\item\em Display a hash-\/with-\/chaining representation on the screen. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Hash table implementation. 

This hash tables are intended for associating a pointer/integer \char`\"{}value\char`\"{} with a char string \char`\"{}key\char`\"{}, (e.\+g., an ID with a word string). Subsequently, one can retrieve the value by providing the string key. (The reverse functionality--obtaining the string given the value--is not provided with the hash table module.) 

\subsection{Macro Definition Documentation}
\mbox{\label{hash__table_8h_ada31c1e0bcf359a7ca934748f4680333}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+enter\+\_\+bkey\+\_\+int32@{hash\+\_\+table\+\_\+enter\+\_\+bkey\+\_\+int32}}
\index{hash\+\_\+table\+\_\+enter\+\_\+bkey\+\_\+int32@{hash\+\_\+table\+\_\+enter\+\_\+bkey\+\_\+int32}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+enter\+\_\+bkey\+\_\+int32}
{\footnotesize\ttfamily \#define hash\+\_\+table\+\_\+enter\+\_\+bkey\+\_\+int32(\begin{DoxyParamCaption}\item[{}]{h,  }\item[{}]{k,  }\item[{}]{l,  }\item[{}]{v }\end{DoxyParamCaption})~((int32)(long)\textbf{ hash\+\_\+table\+\_\+enter\+\_\+bkey}((h),(k),(l),(void $\ast$)(long)(v)))}



Enter a 32-\/bit integer value in a hash table. 

This macro is the clean way to do this and avoid compiler warnings on 64-\/bit platforms. 

Definition at line 315 of file hash\+\_\+table.\+h.

\mbox{\label{hash__table_8h_a393c56322e54607a48e6bc61169d92bf}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+enter\+\_\+int32@{hash\+\_\+table\+\_\+enter\+\_\+int32}}
\index{hash\+\_\+table\+\_\+enter\+\_\+int32@{hash\+\_\+table\+\_\+enter\+\_\+int32}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+enter\+\_\+int32}
{\footnotesize\ttfamily \#define hash\+\_\+table\+\_\+enter\+\_\+int32(\begin{DoxyParamCaption}\item[{}]{h,  }\item[{}]{k,  }\item[{}]{v }\end{DoxyParamCaption})~((int32)(long)\textbf{ hash\+\_\+table\+\_\+enter}((h),(k),(void $\ast$)(long)(v)))}



Add a 32-\/bit integer value to a hash table. 

This macro is the clean way to do this and avoid compiler warnings on 64-\/bit platforms. 

Definition at line 228 of file hash\+\_\+table.\+h.

\mbox{\label{hash__table_8h_ace238b264acacb8e6cb0de14f1035f53}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+replace\+\_\+bkey\+\_\+int32@{hash\+\_\+table\+\_\+replace\+\_\+bkey\+\_\+int32}}
\index{hash\+\_\+table\+\_\+replace\+\_\+bkey\+\_\+int32@{hash\+\_\+table\+\_\+replace\+\_\+bkey\+\_\+int32}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+replace\+\_\+bkey\+\_\+int32}
{\footnotesize\ttfamily \#define hash\+\_\+table\+\_\+replace\+\_\+bkey\+\_\+int32(\begin{DoxyParamCaption}\item[{}]{h,  }\item[{}]{k,  }\item[{}]{l,  }\item[{}]{v }\end{DoxyParamCaption})~((int32)(long)\textbf{ hash\+\_\+table\+\_\+replace\+\_\+bkey}((h),(k),(l),(void $\ast$)(long)(v)))}



Replace a 32-\/bit integer value in a hash table. 

This macro is the clean way to do this and avoid compiler warnings on 64-\/bit platforms. 

Definition at line 338 of file hash\+\_\+table.\+h.

\mbox{\label{hash__table_8h_a4286033aa772a9d1f3aa219469324f5b}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+replace\+\_\+int32@{hash\+\_\+table\+\_\+replace\+\_\+int32}}
\index{hash\+\_\+table\+\_\+replace\+\_\+int32@{hash\+\_\+table\+\_\+replace\+\_\+int32}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+replace\+\_\+int32}
{\footnotesize\ttfamily \#define hash\+\_\+table\+\_\+replace\+\_\+int32(\begin{DoxyParamCaption}\item[{}]{h,  }\item[{}]{k,  }\item[{}]{v }\end{DoxyParamCaption})~((int32)(long)\textbf{ hash\+\_\+table\+\_\+replace}((h),(k),(void $\ast$)(long)(v)))}



Replace a 32-\/bit integer value in a hash table. 

This macro is the clean way to do this and avoid compiler warnings on 64-\/bit platforms. 

Definition at line 257 of file hash\+\_\+table.\+h.



\subsection{Typedef Documentation}
\mbox{\label{hash__table_8h_af70e2b25a853da786ffd99731a5fac5a}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+entry\+\_\+t@{hash\+\_\+entry\+\_\+t}}
\index{hash\+\_\+entry\+\_\+t@{hash\+\_\+entry\+\_\+t}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+entry\+\_\+t}
{\footnotesize\ttfamily typedef struct \textbf{ hash\+\_\+entry\+\_\+s}  \textbf{ hash\+\_\+entry\+\_\+t}}



A note by A\+R\+C\+H\+AN at 20050510\+: Technically what we use is so-\/called \char`\"{}hash table with buckets\char`\"{} which is very nice way to deal with external hashing. 

There are definitely better ways to do internal hashing (i.\+e. when everything is stored in the memory.) In Sphinx 3, this is a reasonable practice because hash table is only used in lookup in initialization or in lookups which is not critical for speed. Another note by A\+R\+C\+H\+AN at 20050703\+: To use this data structure properly, it is very important to realize that the users are required to handle memory allocation of the C-\/style keys. The hash table will not make a copy of the memory allocated for any of the C-\/style key. It will not allocate memory for it. It will not delete memory for it. As a result, the following code sniplet will cause memory leak.

while (1)\{ str=(char$\ast$)\doxyref{ckd\+\_\+calloc(str\+\_\+length,sizeof(char$\ast$))}{p.}{ckd__alloc_8h_aa00ef21903bc4f8a972488417adc8d2e} if(hash\+\_\+enter(ht,str,id)!=id)\{ printf(\char`\"{}fail to add key str \%s with val id \%d\textbackslash{}n\char`\"{},str,id)\} \} A note by dhuggins on 20061010\+: Changed this to use void $\ast$ instead of int32 as the value type, so that arbitrary objects can be inserted into a hash table (in a way that won\textquotesingle{}t crash on 64-\/bit machines ;) The hash table structures. Each hash table is identified by a \doxyref{hash\+\_\+table\+\_\+t}{p.}{structhash__table__t} structure. hash\+\_\+table\+\_\+t.\+table is pre-\/allocated for a user-\/controlled max size, and is initially empty. As new entries are created (using hash\+\_\+enter()), the empty entries get filled. If multiple keys hash to the same entry, new entries are allocated and linked together in a linear list. 

\subsection{Function Documentation}
\mbox{\label{hash__table_8h_af1d87b1b825c302473f2d7c5a3b88475}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+delete@{hash\+\_\+table\+\_\+delete}}
\index{hash\+\_\+table\+\_\+delete@{hash\+\_\+table\+\_\+delete}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+delete()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void$\ast$ hash\+\_\+table\+\_\+delete (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h,  }\item[{const char $\ast$}]{key }\end{DoxyParamCaption})}



Delete an entry with given key and associated value to hash table h. 

Return the value associated with the key (N\+U\+LL if it did not exist) 
\begin{DoxyParams}{Parameters}
{\em h} & In\+: Handle of hash table in which a key will be deleted \\
\hline
{\em key} & In\+: C-\/style N\+U\+L\+L-\/terminated key string for the new entry \\
\hline
\end{DoxyParams}


Definition at line 530 of file hash\+\_\+table.\+c.

\mbox{\label{hash__table_8h_aa2ab1f5eb2f1b4689645d1e1c19dc887}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+delete\+\_\+bkey@{hash\+\_\+table\+\_\+delete\+\_\+bkey}}
\index{hash\+\_\+table\+\_\+delete\+\_\+bkey@{hash\+\_\+table\+\_\+delete\+\_\+bkey}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+delete\+\_\+bkey()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void$\ast$ hash\+\_\+table\+\_\+delete\+\_\+bkey (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h,  }\item[{const char $\ast$}]{key,  }\item[{size\+\_\+t}]{len }\end{DoxyParamCaption})}



Like hash\+\_\+table\+\_\+delete, but with an explicitly specified key length, instead of a N\+U\+L\+L-\/terminated, C-\/style key string. 

So the key string is a binary key (or bkey). Hash tables containing such keys should be created with the H\+A\+S\+H\+\_\+\+C\+A\+S\+E\+\_\+\+Y\+ES option. Otherwise, the results are unpredictable. 
\begin{DoxyParams}{Parameters}
{\em h} & In\+: Handle of hash table in which a key will be deleted \\
\hline
{\em key} & In\+: C-\/style N\+U\+L\+L-\/terminated key string for the new entry \\
\hline
\end{DoxyParams}


Definition at line 568 of file hash\+\_\+table.\+c.

\mbox{\label{hash__table_8h_a2721f6b601c80ceeeae570589fd12e38}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+display@{hash\+\_\+table\+\_\+display}}
\index{hash\+\_\+table\+\_\+display@{hash\+\_\+table\+\_\+display}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+display()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void hash\+\_\+table\+\_\+display (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h,  }\item[{int32}]{showkey }\end{DoxyParamCaption})}



Display a hash-\/with-\/chaining representation on the screen. 

Currently, it will only works for situation where hash\+\_\+enter was used to enter the keys. 
\begin{DoxyParams}{Parameters}
{\em h} & In\+: Hash table to display \\
\hline
{\em showkey} & In\+: Show the string or not, Use 0 if hash\+\_\+enter\+\_\+bkey was used. \\
\hline
\end{DoxyParams}


Definition at line 581 of file hash\+\_\+table.\+c.



References E\+\_\+\+I\+N\+F\+O\+C\+O\+NT, and hash\+\_\+table\+\_\+t\+::size.

\mbox{\label{hash__table_8h_acab374d21e25009d397642e3465308c7}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+empty@{hash\+\_\+table\+\_\+empty}}
\index{hash\+\_\+table\+\_\+empty@{hash\+\_\+table\+\_\+empty}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+empty()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void hash\+\_\+table\+\_\+empty (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h }\end{DoxyParamCaption})}



Delete all entries from a hash\+\_\+table. 


\begin{DoxyParams}{Parameters}
{\em h} & In\+: Handle of hash table \\
\hline
\end{DoxyParams}


Definition at line 490 of file hash\+\_\+table.\+c.



References ckd\+\_\+free(), hash\+\_\+table\+\_\+t\+::inuse, hash\+\_\+entry\+\_\+s\+::next, and hash\+\_\+table\+\_\+t\+::size.

\mbox{\label{hash__table_8h_aebfe63c3869c271b125a8413ee384412}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+enter@{hash\+\_\+table\+\_\+enter}}
\index{hash\+\_\+table\+\_\+enter@{hash\+\_\+table\+\_\+enter}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+enter()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void$\ast$ hash\+\_\+table\+\_\+enter (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h,  }\item[{const char $\ast$}]{key,  }\item[{void $\ast$}]{val }\end{DoxyParamCaption})}



Try to add a new entry with given key and associated value to hash table h. 

If key doesn\textquotesingle{}t already exist in hash table, the addition is successful, and the return value is val. But if key already exists, return its existing associated value. (The hash table is unchanged; it is up to the caller to resolve the conflict.) 
\begin{DoxyParams}{Parameters}
{\em h} & In\+: Handle of hash table in which to create entry \\
\hline
{\em key} & In\+: C-\/style N\+U\+L\+L-\/terminated key string for the new entry \\
\hline
{\em val} & In\+: Value to be associated with above key \\
\hline
\end{DoxyParams}


Definition at line 508 of file hash\+\_\+table.\+c.

\mbox{\label{hash__table_8h_a6f5752fadefe2662adb2c141f1511062}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+enter\+\_\+bkey@{hash\+\_\+table\+\_\+enter\+\_\+bkey}}
\index{hash\+\_\+table\+\_\+enter\+\_\+bkey@{hash\+\_\+table\+\_\+enter\+\_\+bkey}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+enter\+\_\+bkey()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void$\ast$ hash\+\_\+table\+\_\+enter\+\_\+bkey (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h,  }\item[{const char $\ast$}]{key,  }\item[{size\+\_\+t}]{len,  }\item[{void $\ast$}]{val }\end{DoxyParamCaption})}



Like hash\+\_\+table\+\_\+enter, but with an explicitly specified key length, instead of a N\+U\+L\+L-\/terminated, C-\/style key string. 

So the key string is a binary key (or bkey). Hash tables containing such keys should be created with the H\+A\+S\+H\+\_\+\+C\+A\+S\+E\+\_\+\+Y\+ES option. Otherwise, the results are unpredictable. 
\begin{DoxyParams}{Parameters}
{\em h} & In\+: Handle of hash table in which to create entry \\
\hline
{\em key} & In\+: Key buffer \\
\hline
{\em len} & In\+: Length of above key buffer \\
\hline
{\em val} & In\+: Value to be associated with above key \\
\hline
\end{DoxyParams}


Definition at line 542 of file hash\+\_\+table.\+c.

\mbox{\label{hash__table_8h_a0a588c22946f8cc16328973035ed19e3}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+free@{hash\+\_\+table\+\_\+free}}
\index{hash\+\_\+table\+\_\+free@{hash\+\_\+table\+\_\+free}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+free()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void hash\+\_\+table\+\_\+free (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h }\end{DoxyParamCaption})}



Free the specified hash table; the caller is responsible for freeing the key strings pointed to by the table entries. 


\begin{DoxyParams}{Parameters}
{\em h} & In\+: Handle of hash table to free \\
\hline
\end{DoxyParams}


Definition at line 695 of file hash\+\_\+table.\+c.

\mbox{\label{hash__table_8h_ad023321efab26a30bd6d855fbdbe08a3}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+iter\+\_\+next@{hash\+\_\+table\+\_\+iter\+\_\+next}}
\index{hash\+\_\+table\+\_\+iter\+\_\+next@{hash\+\_\+table\+\_\+iter\+\_\+next}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+iter\+\_\+next()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ hash\+\_\+iter\+\_\+t}$\ast$ hash\+\_\+table\+\_\+iter\+\_\+next (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+iter\+\_\+t} $\ast$}]{itor }\end{DoxyParamCaption})}



Get the next key-\/value pair in iteration. 

This function automatically frees the iterator object upon reaching the final entry.

\begin{DoxyReturn}{Returns}
the next entry in the hash table, or N\+U\+LL if done. 
\end{DoxyReturn}


Definition at line 663 of file hash\+\_\+table.\+c.



References hash\+\_\+iter\+\_\+s\+::ent, and hash\+\_\+entry\+\_\+s\+::next.



Referenced by hash\+\_\+table\+\_\+iter().

\mbox{\label{hash__table_8h_a9a1e5ed410eb96f514b00fdce770fbd7}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+lookup@{hash\+\_\+table\+\_\+lookup}}
\index{hash\+\_\+table\+\_\+lookup@{hash\+\_\+table\+\_\+lookup}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+lookup()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 hash\+\_\+table\+\_\+lookup (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h,  }\item[{const char $\ast$}]{key,  }\item[{void $\ast$$\ast$}]{val }\end{DoxyParamCaption})}



Look up a key in a hash table and optionally return the associated value. 

\begin{DoxyReturn}{Returns}
0 if key found in hash table, else -\/1. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em h} & In\+: Handle of hash table being searched \\
\hline
{\em key} & In\+: C-\/style N\+U\+L\+L-\/terminated string whose value is sought \\
\hline
{\em val} & Out\+: $\ast$val = value associated with key. If this is N\+U\+LL, no value will be returned. \\
\hline
\end{DoxyParams}


Definition at line 309 of file hash\+\_\+table.\+c.



References hash\+\_\+entry\+\_\+s\+::val.



Referenced by cmd\+\_\+ln\+\_\+access\+\_\+r(), hash\+\_\+table\+\_\+lookup\+\_\+int32(), huff\+\_\+code\+\_\+encode\+\_\+str(), and jsgf\+\_\+get\+\_\+rule().

\mbox{\label{hash__table_8h_a91f5b3924c0e3a50f94c86bb5fd078e8}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+lookup\+\_\+bkey@{hash\+\_\+table\+\_\+lookup\+\_\+bkey}}
\index{hash\+\_\+table\+\_\+lookup\+\_\+bkey@{hash\+\_\+table\+\_\+lookup\+\_\+bkey}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+lookup\+\_\+bkey()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 hash\+\_\+table\+\_\+lookup\+\_\+bkey (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h,  }\item[{const char $\ast$}]{key,  }\item[{size\+\_\+t}]{len,  }\item[{void $\ast$$\ast$}]{val }\end{DoxyParamCaption})}



Like hash\+\_\+lookup, but with an explicitly specified key length, instead of a N\+U\+L\+L-\/terminated, C-\/style key string. 

So the key string is a binary key (or bkey). Hash tables containing such keys should be created with the H\+A\+S\+H\+\_\+\+C\+A\+S\+E\+\_\+\+Y\+ES option. Otherwise, the results are unpredictable. 
\begin{DoxyParams}{Parameters}
{\em h} & In\+: Handle of hash table being searched \\
\hline
{\em key} & In\+: Key buffer \\
\hline
{\em len} & In\+: Length of above key buffer \\
\hline
{\em val} & Out\+: $\ast$val = value associated with key. If this is N\+U\+LL, no value will be returned. \\
\hline
\end{DoxyParams}


Definition at line 344 of file hash\+\_\+table.\+c.



Referenced by hash\+\_\+table\+\_\+lookup\+\_\+bkey\+\_\+int32(), and huff\+\_\+code\+\_\+encode\+\_\+int().

\mbox{\label{hash__table_8h_acc530eda0b105745cf3a47cc3c1148e4}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+lookup\+\_\+bkey\+\_\+int32@{hash\+\_\+table\+\_\+lookup\+\_\+bkey\+\_\+int32}}
\index{hash\+\_\+table\+\_\+lookup\+\_\+bkey\+\_\+int32@{hash\+\_\+table\+\_\+lookup\+\_\+bkey\+\_\+int32}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+lookup\+\_\+bkey\+\_\+int32()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 hash\+\_\+table\+\_\+lookup\+\_\+bkey\+\_\+int32 (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h,  }\item[{const char $\ast$}]{key,  }\item[{size\+\_\+t}]{len,  }\item[{int32 $\ast$}]{val }\end{DoxyParamCaption})}



Look up a 32-\/bit integer value in a hash table. 

This function is the clean way to do this and avoid compiler warnings on 64-\/bit platforms. 
\begin{DoxyParams}{Parameters}
{\em h} & In\+: Handle of hash table being searched \\
\hline
{\em key} & In\+: Key buffer \\
\hline
{\em len} & In\+: Length of above key buffer \\
\hline
{\em val} & Out\+: $\ast$val = value associated with key. If this is N\+U\+LL, no value will be returned. \\
\hline
\end{DoxyParams}


Definition at line 365 of file hash\+\_\+table.\+c.



References hash\+\_\+table\+\_\+lookup\+\_\+bkey().

\mbox{\label{hash__table_8h_acaf27e8e7e336faf6653649937c42ed8}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+lookup\+\_\+int32@{hash\+\_\+table\+\_\+lookup\+\_\+int32}}
\index{hash\+\_\+table\+\_\+lookup\+\_\+int32@{hash\+\_\+table\+\_\+lookup\+\_\+int32}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+lookup\+\_\+int32()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 hash\+\_\+table\+\_\+lookup\+\_\+int32 (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h,  }\item[{const char $\ast$}]{key,  }\item[{int32 $\ast$}]{val }\end{DoxyParamCaption})}



Look up a 32-\/bit integer value in a hash table. 

This function is the clean way to do this and avoid compiler warnings on 64-\/bit platforms. 
\begin{DoxyParams}{Parameters}
{\em h} & In\+: Handle of hash table being searched \\
\hline
{\em key} & In\+: C-\/style N\+U\+L\+L-\/terminated string whose value is sought \\
\hline
{\em val} & Out\+: $\ast$val = value associated with key. If this is N\+U\+LL, no value will be returned. \\
\hline
\end{DoxyParams}


Definition at line 329 of file hash\+\_\+table.\+c.



References hash\+\_\+table\+\_\+lookup().



Referenced by ngram\+\_\+unknown\+\_\+wid(), and ngram\+\_\+wid().

\mbox{\label{hash__table_8h_a56d93e8c03e066b77377ac6eab50cfae}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+new@{hash\+\_\+table\+\_\+new}}
\index{hash\+\_\+table\+\_\+new@{hash\+\_\+table\+\_\+new}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+new()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ hash\+\_\+table\+\_\+t}$\ast$ hash\+\_\+table\+\_\+new (\begin{DoxyParamCaption}\item[{int32}]{size,  }\item[{int32}]{casearg }\end{DoxyParamCaption})}



Allocate a new hash table for a given expected size. 

\begin{DoxyNote}{Note}
Case sensitivity of hash keys applies to 7-\/bit A\+S\+C\+II characters only, and is not locale-\/dependent.
\end{DoxyNote}
\begin{DoxyReturn}{Returns}
handle to allocated hash table. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em size} & In\+: Expected number of entries in the table \\
\hline
{\em casearg} & In\+: Whether case insensitive for key comparisons. When 1, case is insentitive, 0, case is sensitive. \\
\hline
\end{DoxyParams}


Definition at line 158 of file hash\+\_\+table.\+c.



References ckd\+\_\+calloc, hash\+\_\+table\+\_\+t\+::nocase, and hash\+\_\+table\+\_\+t\+::size.



Referenced by huff\+\_\+code\+\_\+read(), and jsgf\+\_\+grammar\+\_\+new().

\mbox{\label{hash__table_8h_ae61b28ea189a98ef8f2a3c5521482968}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+replace@{hash\+\_\+table\+\_\+replace}}
\index{hash\+\_\+table\+\_\+replace@{hash\+\_\+table\+\_\+replace}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+replace()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void$\ast$ hash\+\_\+table\+\_\+replace (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h,  }\item[{const char $\ast$}]{key,  }\item[{void $\ast$}]{val }\end{DoxyParamCaption})}



Add a new entry with given key and value to hash table h. 

If the key already exists, its value is replaced with the given value, and the previous value is returned, otherwise val is returned.

A very important but subtle point\+: The key pointer in the hash table is {\bfseries replaced} with the pointer passed to this function. In general you should always pass a pointer to \doxyref{hash\+\_\+table\+\_\+enter()}{p.}{hash__table_8h_aebfe63c3869c271b125a8413ee384412} whose lifetime matches or exceeds that of the hash table. In some rare cases it is convenient to initially enter a value with a short-\/lived key, then later replace that with a long-\/lived one. This behaviour allows this to happen. 
\begin{DoxyParams}{Parameters}
{\em h} & In\+: Handle of hash table in which to create entry \\
\hline
{\em key} & In\+: C-\/style N\+U\+L\+L-\/terminated key string for the new entry \\
\hline
{\em val} & In\+: Value to be associated with above key \\
\hline
\end{DoxyParams}


Definition at line 519 of file hash\+\_\+table.\+c.

\mbox{\label{hash__table_8h_a273237d63833e5625c830f421d9463de}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+replace\+\_\+bkey@{hash\+\_\+table\+\_\+replace\+\_\+bkey}}
\index{hash\+\_\+table\+\_\+replace\+\_\+bkey@{hash\+\_\+table\+\_\+replace\+\_\+bkey}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+replace\+\_\+bkey()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void$\ast$ hash\+\_\+table\+\_\+replace\+\_\+bkey (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h,  }\item[{const char $\ast$}]{key,  }\item[{size\+\_\+t}]{len,  }\item[{void $\ast$}]{val }\end{DoxyParamCaption})}



Like hash\+\_\+table\+\_\+replace, but with an explicitly specified key length, instead of a N\+U\+L\+L-\/terminated, C-\/style key string. 

So the key string is a binary key (or bkey). Hash tables containing such keys should be created with the H\+A\+S\+H\+\_\+\+C\+A\+S\+E\+\_\+\+Y\+ES option. Otherwise, the results are unpredictable. 
\begin{DoxyParams}{Parameters}
{\em h} & In\+: Handle of hash table in which to create entry \\
\hline
{\em key} & In\+: Key buffer \\
\hline
{\em len} & In\+: Length of above key buffer \\
\hline
{\em val} & In\+: Value to be associated with above key \\
\hline
\end{DoxyParams}


Definition at line 555 of file hash\+\_\+table.\+c.

\mbox{\label{hash__table_8h_a61f59389f05d8871003da4692a9c2acc}} 
\index{hash\+\_\+table.\+h@{hash\+\_\+table.\+h}!hash\+\_\+table\+\_\+tolist@{hash\+\_\+table\+\_\+tolist}}
\index{hash\+\_\+table\+\_\+tolist@{hash\+\_\+table\+\_\+tolist}!hash\+\_\+table.\+h@{hash\+\_\+table.\+h}}
\subsubsection{hash\+\_\+table\+\_\+tolist()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ glist\+\_\+t} hash\+\_\+table\+\_\+tolist (\begin{DoxyParamCaption}\item[{\textbf{ hash\+\_\+table\+\_\+t} $\ast$}]{h,  }\item[{int32 $\ast$}]{count }\end{DoxyParamCaption})}



Build a glist of valid hash\+\_\+entry\+\_\+t pointers from the given hash table. 

Return the list. 
\begin{DoxyParams}{Parameters}
{\em h} & In\+: Hash table from which list is to be generated \\
\hline
{\em count} & Out\+: Number of entries in the list. If this is N\+U\+LL, no count will be returned. \\
\hline
\end{DoxyParams}


Definition at line 623 of file hash\+\_\+table.\+c.

