\doxysection{hash\+\_\+entry\+\_\+s Struct Reference}
\label{structhash__entry__s}\index{hash\_entry\_s@{hash\_entry\_s}}


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




{\ttfamily \#include $<$hash\+\_\+table.\+h$>$}

\doxysubsubsection*{Data Fields}
\begin{DoxyCompactItemize}
\item 
const char $\ast$ \textbf{ key}
\item 
size\+\_\+t \textbf{ len}
\begin{DoxyCompactList}\small\item\em Key string, NULL if this is an empty slot. \end{DoxyCompactList}\item 
void $\ast$ \textbf{ val}
\begin{DoxyCompactList}\small\item\em Key-\/length; the key string does not have to be a C-\/style NULL terminated string; it can have arbitrary binary bytes. \end{DoxyCompactList}\item 
struct \textbf{ hash\+\_\+entry\+\_\+s} $\ast$ \textbf{ next}
\begin{DoxyCompactList}\small\item\em Value associated with above key. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
A note by ARCHAN at 20050510\+: Technically what we use is so-\/called "{}hash table with buckets"{} 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 ARCHAN 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. ~\newline


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("{}fail to add key str \%s with val id \%d\textbackslash{}n"{},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. 

Definition at line \textbf{ 149} of file \textbf{ hash\+\_\+table.\+h}.



\doxysubsection{Field Documentation}
\label{structhash__entry__s_a2566ac1233761789585363a283385321} 
\index{hash\_entry\_s@{hash\_entry\_s}!key@{key}}
\index{key@{key}!hash\_entry\_s@{hash\_entry\_s}}
\doxysubsubsection{key}
{\footnotesize\ttfamily const char$\ast$ hash\+\_\+entry\+\_\+s\+::key}



Definition at line \textbf{ 150} of file \textbf{ hash\+\_\+table.\+h}.

\label{structhash__entry__s_af1ec5f16059ced6d9a8ae4d36ca7e2b3} 
\index{hash\_entry\_s@{hash\_entry\_s}!len@{len}}
\index{len@{len}!hash\_entry\_s@{hash\_entry\_s}}
\doxysubsubsection{len}
{\footnotesize\ttfamily size\+\_\+t hash\+\_\+entry\+\_\+s\+::len}



Key string, NULL if this is an empty slot. 

NOTE that the key must not be changed once the entry has been made. 

Definition at line \textbf{ 153} of file \textbf{ hash\+\_\+table.\+h}.



Referenced by \textbf{ hash\+\_\+table\+\_\+display()}.

\label{structhash__entry__s_aa855ac854b9c36cf23f60d9ac8093e7f} 
\index{hash\_entry\_s@{hash\_entry\_s}!next@{next}}
\index{next@{next}!hash\_entry\_s@{hash\_entry\_s}}
\doxysubsubsection{next}
{\footnotesize\ttfamily struct \textbf{ hash\+\_\+entry\+\_\+s}$\ast$ hash\+\_\+entry\+\_\+s\+::next}



Value associated with above key. 



Definition at line \textbf{ 156} of file \textbf{ hash\+\_\+table.\+h}.



Referenced by \textbf{ hash\+\_\+table\+\_\+display()}, \textbf{ hash\+\_\+table\+\_\+empty()}, \textbf{ hash\+\_\+table\+\_\+free()}, and \textbf{ hash\+\_\+table\+\_\+iter\+\_\+next()}.

\label{structhash__entry__s_a0d57012963084fed93886681108aa636} 
\index{hash\_entry\_s@{hash\_entry\_s}!val@{val}}
\index{val@{val}!hash\_entry\_s@{hash\_entry\_s}}
\doxysubsubsection{val}
{\footnotesize\ttfamily void$\ast$ hash\+\_\+entry\+\_\+s\+::val}



Key-\/length; the key string does not have to be a C-\/style NULL terminated string; it can have arbitrary binary bytes. 



Definition at line \textbf{ 155} of file \textbf{ hash\+\_\+table.\+h}.



Referenced by \textbf{ cmd\+\_\+ln\+\_\+free\+\_\+r()}, \textbf{ hash\+\_\+table\+\_\+display()}, \textbf{ hash\+\_\+table\+\_\+lookup()}, \textbf{ hash\+\_\+table\+\_\+lookup\+\_\+bkey()}, \textbf{ jsgf\+\_\+grammar\+\_\+free()}, \textbf{ ngram\+\_\+model\+\_\+read\+\_\+classdef()}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+read()}.



The documentation for this struct was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
include/sphinxbase/\textbf{ hash\+\_\+table.\+h}\end{DoxyCompactItemize}
