<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>libthai: /builddir/build/BUILD/libthai-0.1.14/libdatrie/datrie/trie.h File Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.3 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">libthai <span id="projectnumber">0.1.14</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> </div> <div class="header"> <div class="summary"> <a href="#define-members">Defines</a> | <a href="#typedef-members">Typedefs</a> | <a href="#func-members">Functions</a> </div> <div class="headertitle"> <h1>/builddir/build/BUILD/libthai-0.1.14/libdatrie/datrie/trie.h File Reference</h1> </div> </div> <div class="contents"> <p>Trie data type and functions. <a href="#_details">More...</a></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="define-members"></a> Defines</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#adfbfb4a5252ad25e5e24e59a125b12de">trie_state_is_terminal</a>(s)   trie_state_is_walkable((s),TRIE_CHAR_TERM)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Check for terminal state. <a href="#adfbfb4a5252ad25e5e24e59a125b12de"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a94151b9c8f39285d21dd141bbf54a388">trie_state_is_leaf</a>(s)   (trie_state_is_single(s) && trie_state_is_terminal(s))</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Check for leaf state. <a href="#a94151b9c8f39285d21dd141bbf54a388"></a><br/></td></tr> <tr><td colspan="2"><h2><a name="typedef-members"></a> Typedefs</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af5808be7fb71b1ef0b1dcbe55da603ce"></a><!-- doxytag: member="trie.h::Trie" ref="af5808be7fb71b1ef0b1dcbe55da603ce" args="" --> typedef struct <a class="el" href="struct__Trie.html">_Trie</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#af5808be7fb71b1ef0b1dcbe55da603ce">Trie</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Trie data type. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">typedef Bool(* </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#adce3d0413daa244406bb37bd6db74e5c">TrieEnumFunc</a> )(const <a class="el" href="triedefs_8h.html#acae969caa2057c6accde0e977546a5be">AlphaChar</a> *key, <a class="el" href="triedefs_8h.html#ab29d7be15a1627450c0591317f56162e">TrieData</a> key_data, void *user_data)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Trie enumeration function. <a href="#adce3d0413daa244406bb37bd6db74e5c"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2b6aa870c546b566c3f3a4d13f74d066"></a><!-- doxytag: member="trie.h::TrieState" ref="a2b6aa870c546b566c3f3a4d13f74d066" args="" --> typedef struct <a class="el" href="struct__TrieState.html">_TrieState</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a2b6aa870c546b566c3f3a4d13f74d066">TrieState</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Trie walking state. <br/></td></tr> <tr><td colspan="2"><h2><a name="func-members"></a> Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__Trie.html">Trie</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a33fad5408b54070b8c1ee27ee1d1e5c3">trie_new</a> (const <a class="el" href="alpha-map_8h.html#ab369cb9c893b9f233b97173e0c63d25e">AlphaMap</a> *alpha_map)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Create a new trie. <a href="#a33fad5408b54070b8c1ee27ee1d1e5c3"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__Trie.html">Trie</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a035aebcfa3b8f61404a1735bc62b8ca6">trie_new_from_file</a> (const char *path)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Create a new trie by loading from a file. <a href="#a035aebcfa3b8f61404a1735bc62b8ca6"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a7fe9ae638ae3f97e27e089bff41ab27a">trie_free</a> (<a class="el" href="struct__Trie.html">Trie</a> *trie)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Free a trie object. <a href="#a7fe9ae638ae3f97e27e089bff41ab27a"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a5e3ad1b0542305e5047d3f29bd309581">trie_save</a> (<a class="el" href="struct__Trie.html">Trie</a> *trie, const char *path)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Save a trie to file. <a href="#a5e3ad1b0542305e5047d3f29bd309581"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">Bool </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a320eb50f7393401f8a5159a1c858c0ba">trie_is_dirty</a> (const <a class="el" href="struct__Trie.html">Trie</a> *trie)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Check pending changes. <a href="#a320eb50f7393401f8a5159a1c858c0ba"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">Bool </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a38ad6c891f2825d525db8c33c61329f4">trie_retrieve</a> (const <a class="el" href="struct__Trie.html">Trie</a> *trie, const <a class="el" href="triedefs_8h.html#acae969caa2057c6accde0e977546a5be">AlphaChar</a> *key, <a class="el" href="triedefs_8h.html#ab29d7be15a1627450c0591317f56162e">TrieData</a> *o_data)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Retrieve an entry from trie. <a href="#a38ad6c891f2825d525db8c33c61329f4"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">Bool </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#af15c00ee43980d7cbd15614c068b0061">trie_store</a> (<a class="el" href="struct__Trie.html">Trie</a> *trie, const <a class="el" href="triedefs_8h.html#acae969caa2057c6accde0e977546a5be">AlphaChar</a> *key, <a class="el" href="triedefs_8h.html#ab29d7be15a1627450c0591317f56162e">TrieData</a> data)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Store a value for an entry to trie. <a href="#af15c00ee43980d7cbd15614c068b0061"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">Bool </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a83f43538cea08a52baa7aed728332923">trie_delete</a> (<a class="el" href="struct__Trie.html">Trie</a> *trie, const <a class="el" href="triedefs_8h.html#acae969caa2057c6accde0e977546a5be">AlphaChar</a> *key)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Delete an entry from trie. <a href="#a83f43538cea08a52baa7aed728332923"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">Bool </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a0b199a9fdcbbba88dd5009fde6b25bca">trie_enumerate</a> (const <a class="el" href="struct__Trie.html">Trie</a> *trie, <a class="el" href="trie_8h.html#adce3d0413daa244406bb37bd6db74e5c">TrieEnumFunc</a> enum_func, void *user_data)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Enumerate entries in trie. <a href="#a0b199a9fdcbbba88dd5009fde6b25bca"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__TrieState.html">TrieState</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a77ab422ee6a301e8569a9cbb3befcde3">trie_root</a> (const <a class="el" href="struct__Trie.html">Trie</a> *trie)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Get root state of a trie. <a href="#a77ab422ee6a301e8569a9cbb3befcde3"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="struct__TrieState.html">TrieState</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a59c254bb5e1d69031f2fa6203418b576">trie_state_clone</a> (const <a class="el" href="struct__TrieState.html">TrieState</a> *s)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Clone a trie state. <a href="#a59c254bb5e1d69031f2fa6203418b576"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a2b5a16f4c3f2b4dbd2062002c94008b0">trie_state_copy</a> (<a class="el" href="struct__TrieState.html">TrieState</a> *dst, const <a class="el" href="struct__TrieState.html">TrieState</a> *src)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Copy trie state to another. <a href="#a2b5a16f4c3f2b4dbd2062002c94008b0"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#ac0cebb9a610314c2bb8348c73c4303ce">trie_state_free</a> (<a class="el" href="struct__TrieState.html">TrieState</a> *s)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Free a trie state. <a href="#ac0cebb9a610314c2bb8348c73c4303ce"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a84e7cb79d0bf4d078a762cdec6be9419">trie_state_rewind</a> (<a class="el" href="struct__TrieState.html">TrieState</a> *s)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Rewind a trie state. <a href="#a84e7cb79d0bf4d078a762cdec6be9419"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">Bool </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#a1c8768dc722b3a4ed526b1ccc5280fbb">trie_state_walk</a> (<a class="el" href="struct__TrieState.html">TrieState</a> *s, <a class="el" href="triedefs_8h.html#acae969caa2057c6accde0e977546a5be">AlphaChar</a> c)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Walk the trie from the state. <a href="#a1c8768dc722b3a4ed526b1ccc5280fbb"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">Bool </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#aa55cd635e4a6d84c2b9f1bfd2a10e9b5">trie_state_is_walkable</a> (const <a class="el" href="struct__TrieState.html">TrieState</a> *s, <a class="el" href="triedefs_8h.html#acae969caa2057c6accde0e977546a5be">AlphaChar</a> c)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Test walkability of character from state. <a href="#aa55cd635e4a6d84c2b9f1bfd2a10e9b5"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">Bool </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#ae0376122b287b023478efdc3d4754f9c">trie_state_is_single</a> (const <a class="el" href="struct__TrieState.html">TrieState</a> *s)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Check for single path. <a href="#ae0376122b287b023478efdc3d4754f9c"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="triedefs_8h.html#ab29d7be15a1627450c0591317f56162e">TrieData</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="trie_8h.html#ad4716911c7afa919b0e20132e19b7baf">trie_state_get_data</a> (const <a class="el" href="struct__TrieState.html">TrieState</a> *s)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Get data from leaf state. <a href="#ad4716911c7afa919b0e20132e19b7baf"></a><br/></td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <div class="textblock"><p>Trie data type and functions. </p> </div><hr/><h2>Define Documentation</h2> <a class="anchor" id="a94151b9c8f39285d21dd141bbf54a388"></a><!-- doxytag: member="trie.h::trie_state_is_leaf" ref="a94151b9c8f39285d21dd141bbf54a388" args="(s)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define trie_state_is_leaf</td> <td>(</td> <td class="paramtype"> </td> <td class="paramname">s</td><td>)</td> <td>   (trie_state_is_single(s) && trie_state_is_terminal(s))</td> </tr> </table> </div> <div class="memdoc"> <p>Check for leaf state. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">s</td><td>: the state to check</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>boolean value indicating whether it is a leaf state</dd></dl> <p>Check if the given state is a leaf state. A leaf state is a terminal state that has no other branch. </p> </div> </div> <a class="anchor" id="adfbfb4a5252ad25e5e24e59a125b12de"></a><!-- doxytag: member="trie.h::trie_state_is_terminal" ref="adfbfb4a5252ad25e5e24e59a125b12de" args="(s)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">#define trie_state_is_terminal</td> <td>(</td> <td class="paramtype"> </td> <td class="paramname">s</td><td>)</td> <td>   trie_state_is_walkable((s),TRIE_CHAR_TERM)</td> </tr> </table> </div> <div class="memdoc"> <p>Check for terminal state. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">s</td><td>: the state to check</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>boolean value indicating whether it is a terminal state</dd></dl> <p>Check if the given state is a terminal state. A terminal state is a trie state that terminates a key, and stores a value associated with it. </p> </div> </div> <hr/><h2>Typedef Documentation</h2> <a class="anchor" id="adce3d0413daa244406bb37bd6db74e5c"></a><!-- doxytag: member="trie.h::TrieEnumFunc" ref="adce3d0413daa244406bb37bd6db74e5c" args=")(const AlphaChar *key, TrieData key_data, void *user_data)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">typedef Bool(* <a class="el" href="trie_8h.html#adce3d0413daa244406bb37bd6db74e5c">TrieEnumFunc</a>)(const <a class="el" href="triedefs_8h.html#acae969caa2057c6accde0e977546a5be">AlphaChar</a> *key, <a class="el" href="triedefs_8h.html#ab29d7be15a1627450c0591317f56162e">TrieData</a> key_data, void *user_data)</td> </tr> </table> </div> <div class="memdoc"> <p>Trie enumeration function. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">key</td><td>: the key of the entry </td></tr> <tr><td class="paramname">data</td><td>: the data of the entry</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>TRUE to continue enumeration, FALSE to stop </dd></dl> </div> </div> <hr/><h2>Function Documentation</h2> <a class="anchor" id="a83f43538cea08a52baa7aed728332923"></a><!-- doxytag: member="trie.h::trie_delete" ref="a83f43538cea08a52baa7aed728332923" args="(Trie *trie, const AlphaChar *key)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Bool trie_delete </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__Trie.html">Trie</a> * </td> <td class="paramname"><em>trie</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="triedefs_8h.html#acae969caa2057c6accde0e977546a5be">AlphaChar</a> * </td> <td class="paramname"><em>key</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Delete an entry from trie. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">trie</td><td>: the trie </td></tr> <tr><td class="paramname">key</td><td>: the key for the entry to delete</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>boolean value indicating whether the key exists and is removed</dd></dl> <p>Delete an entry for the given <em>key</em> from <em>trie</em>. </p> </div> </div> <a class="anchor" id="a0b199a9fdcbbba88dd5009fde6b25bca"></a><!-- doxytag: member="trie.h::trie_enumerate" ref="a0b199a9fdcbbba88dd5009fde6b25bca" args="(const Trie *trie, TrieEnumFunc enum_func, void *user_data)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Bool trie_enumerate </td> <td>(</td> <td class="paramtype">const <a class="el" href="struct__Trie.html">Trie</a> * </td> <td class="paramname"><em>trie</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="trie_8h.html#adce3d0413daa244406bb37bd6db74e5c">TrieEnumFunc</a> </td> <td class="paramname"><em>enum_func</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">void * </td> <td class="paramname"><em>user_data</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Enumerate entries in trie. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">trie</td><td>: the trie </td></tr> <tr><td class="paramname">enum_func</td><td>: the callback function to be called on each key </td></tr> <tr><td class="paramname">user_data</td><td>: user-supplied data to send as an argument to <em>enum_func</em> </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>boolean value indicating whether all the keys are visited</dd></dl> <p>Enumerate all entries in trie. For each entry, the user-supplied <em>enum_func</em> callback function is called, with the entry key and data. Returning FALSE from such callback will stop enumeration and return FALSE. </p> </div> </div> <a class="anchor" id="a7fe9ae638ae3f97e27e089bff41ab27a"></a><!-- doxytag: member="trie.h::trie_free" ref="a7fe9ae638ae3f97e27e089bff41ab27a" args="(Trie *trie)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void trie_free </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__Trie.html">Trie</a> * </td> <td class="paramname"><em>trie</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Free a trie object. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">trie</td><td>: the trie object to free</td></tr> </table> </dd> </dl> <p>Destruct the <em>trie</em> and free its allocated memory. </p> </div> </div> <a class="anchor" id="a320eb50f7393401f8a5159a1c858c0ba"></a><!-- doxytag: member="trie.h::trie_is_dirty" ref="a320eb50f7393401f8a5159a1c858c0ba" args="(const Trie *trie)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Bool trie_is_dirty </td> <td>(</td> <td class="paramtype">const <a class="el" href="struct__Trie.html">Trie</a> * </td> <td class="paramname"><em>trie</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Check pending changes. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">trie</td><td>: the trie object</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>TRUE if there are pending changes, FALSE otherwise</dd></dl> <p>Check if the <em>trie</em> is dirty with some pending changes and needs saving to synchronize with the file. </p> </div> </div> <a class="anchor" id="a33fad5408b54070b8c1ee27ee1d1e5c3"></a><!-- doxytag: member="trie.h::trie_new" ref="a33fad5408b54070b8c1ee27ee1d1e5c3" args="(const AlphaMap *alpha_map)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="struct__Trie.html">Trie</a>* trie_new </td> <td>(</td> <td class="paramtype">const <a class="el" href="alpha-map_8h.html#ab369cb9c893b9f233b97173e0c63d25e">AlphaMap</a> * </td> <td class="paramname"><em>alpha_map</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Create a new trie. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">alpha_map</td><td>: the alphabet set for the trie</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>a pointer to the newly created trie, NULL on failure</dd></dl> <p>Create a new empty trie object based on the given <em>alpha_map</em> alphabet set. The trie contents can then be added and deleted with <a class="el" href="trie_8h.html#af15c00ee43980d7cbd15614c068b0061" title="Store a value for an entry to trie.">trie_store()</a> and <a class="el" href="trie_8h.html#a83f43538cea08a52baa7aed728332923" title="Delete an entry from trie.">trie_delete()</a> respectively.</p> <p>The created object must be freed with <a class="el" href="trie_8h.html#a7fe9ae638ae3f97e27e089bff41ab27a" title="Free a trie object.">trie_free()</a>. </p> </div> </div> <a class="anchor" id="a035aebcfa3b8f61404a1735bc62b8ca6"></a><!-- doxytag: member="trie.h::trie_new_from_file" ref="a035aebcfa3b8f61404a1735bc62b8ca6" args="(const char *path)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="struct__Trie.html">Trie</a>* trie_new_from_file </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>path</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Create a new trie by loading from a file. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">path</td><td>: the path to the file</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>a pointer to the created trie, NULL on failure</dd></dl> <p>Create a new trie and initialize its contents by loading from the file at given <em>path</em>.</p> <p>The created object must be freed with <a class="el" href="trie_8h.html#a7fe9ae638ae3f97e27e089bff41ab27a" title="Free a trie object.">trie_free()</a>. </p> </div> </div> <a class="anchor" id="a38ad6c891f2825d525db8c33c61329f4"></a><!-- doxytag: member="trie.h::trie_retrieve" ref="a38ad6c891f2825d525db8c33c61329f4" args="(const Trie *trie, const AlphaChar *key, TrieData *o_data)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Bool trie_retrieve </td> <td>(</td> <td class="paramtype">const <a class="el" href="struct__Trie.html">Trie</a> * </td> <td class="paramname"><em>trie</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="triedefs_8h.html#acae969caa2057c6accde0e977546a5be">AlphaChar</a> * </td> <td class="paramname"><em>key</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="triedefs_8h.html#ab29d7be15a1627450c0591317f56162e">TrieData</a> * </td> <td class="paramname"><em>o_data</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Retrieve an entry from trie. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">trie</td><td>: the trie </td></tr> <tr><td class="paramname">key</td><td>: the key for the entry to retrieve </td></tr> <tr><td class="paramname">o_data</td><td>: the storage for storing the entry data on return</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>boolean value indicating the existence of the entry.</dd></dl> <p>Retrieve an entry for the given <em>key</em> from <em>trie</em>. On return, if <em>key</em> is found and <em>o_data</em> is not NULL, <em>*o_data</em> is set to the data associated to <em>key</em>. </p> </div> </div> <a class="anchor" id="a77ab422ee6a301e8569a9cbb3befcde3"></a><!-- doxytag: member="trie.h::trie_root" ref="a77ab422ee6a301e8569a9cbb3befcde3" args="(const Trie *trie)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="struct__TrieState.html">TrieState</a>* trie_root </td> <td>(</td> <td class="paramtype">const <a class="el" href="struct__Trie.html">Trie</a> * </td> <td class="paramname"><em>trie</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Get root state of a trie. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">trie</td><td>: the trie</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>the root state of the trie</dd></dl> <p>Get root state of <em>trie</em>, for stepwise walking.</p> <p>The returned state is allocated and must be freed with <a class="el" href="trie_8h.html#ac0cebb9a610314c2bb8348c73c4303ce" title="Free a trie state.">trie_state_free()</a> </p> </div> </div> <a class="anchor" id="a5e3ad1b0542305e5047d3f29bd309581"></a><!-- doxytag: member="trie.h::trie_save" ref="a5e3ad1b0542305e5047d3f29bd309581" args="(Trie *trie, const char *path)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int trie_save </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__Trie.html">Trie</a> * </td> <td class="paramname"><em>trie</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>path</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Save a trie to file. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">trie</td><td>: the trie</td></tr> <tr><td class="paramname">path</td><td>: the path to the file</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, non-zero on failure</dd></dl> <p>Create a new file at the given <em>path</em> and write <em>trie</em> data to it. If <em>path</em> already exists, its contents will be replaced. </p> </div> </div> <a class="anchor" id="a59c254bb5e1d69031f2fa6203418b576"></a><!-- doxytag: member="trie.h::trie_state_clone" ref="a59c254bb5e1d69031f2fa6203418b576" args="(const TrieState *s)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="struct__TrieState.html">TrieState</a>* trie_state_clone </td> <td>(</td> <td class="paramtype">const <a class="el" href="struct__TrieState.html">TrieState</a> * </td> <td class="paramname"><em>s</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Clone a trie state. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">s</td><td>: the state to clone</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>an duplicated instance of <em>s</em> </dd></dl> <p>Make a copy of trie state.</p> <p>The returned state is allocated and must be freed with <a class="el" href="trie_8h.html#ac0cebb9a610314c2bb8348c73c4303ce" title="Free a trie state.">trie_state_free()</a> </p> </div> </div> <a class="anchor" id="a2b5a16f4c3f2b4dbd2062002c94008b0"></a><!-- doxytag: member="trie.h::trie_state_copy" ref="a2b5a16f4c3f2b4dbd2062002c94008b0" args="(TrieState *dst, const TrieState *src)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void trie_state_copy </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__TrieState.html">TrieState</a> * </td> <td class="paramname"><em>dst</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="struct__TrieState.html">TrieState</a> * </td> <td class="paramname"><em>src</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Copy trie state to another. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">dst</td><td>: the destination state </td></tr> <tr><td class="paramname">src</td><td>: the source state</td></tr> </table> </dd> </dl> <p>Copy trie state data from <em>src</em> to <em>dst</em>. All existing data in <em>dst</em> is overwritten. </p> </div> </div> <a class="anchor" id="ac0cebb9a610314c2bb8348c73c4303ce"></a><!-- doxytag: member="trie.h::trie_state_free" ref="ac0cebb9a610314c2bb8348c73c4303ce" args="(TrieState *s)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void trie_state_free </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__TrieState.html">TrieState</a> * </td> <td class="paramname"><em>s</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Free a trie state. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">s</td><td>: the state to free</td></tr> </table> </dd> </dl> <p>Free the trie state. </p> </div> </div> <a class="anchor" id="ad4716911c7afa919b0e20132e19b7baf"></a><!-- doxytag: member="trie.h::trie_state_get_data" ref="ad4716911c7afa919b0e20132e19b7baf" args="(const TrieState *s)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="triedefs_8h.html#ab29d7be15a1627450c0591317f56162e">TrieData</a> trie_state_get_data </td> <td>(</td> <td class="paramtype">const <a class="el" href="struct__TrieState.html">TrieState</a> * </td> <td class="paramname"><em>s</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Get data from leaf state. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">s</td><td>: a leaf state</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>the data associated with the leaf state <em>s</em>, or TRIE_DATA_ERROR if <em>s</em> is not a leaf state</dd></dl> <p>Get value from a leaf state of trie. Getting value from a non-leaf state will result in TRIE_DATA_ERROR. </p> </div> </div> <a class="anchor" id="ae0376122b287b023478efdc3d4754f9c"></a><!-- doxytag: member="trie.h::trie_state_is_single" ref="ae0376122b287b023478efdc3d4754f9c" args="(const TrieState *s)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Bool trie_state_is_single </td> <td>(</td> <td class="paramtype">const <a class="el" href="struct__TrieState.html">TrieState</a> * </td> <td class="paramname"><em>s</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Check for single path. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">s</td><td>: the state to check</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>boolean value indicating whether it is in a single path</dd></dl> <p>Check if the given state is in a single path, that is, there is no other branch from it to leaf. </p> </div> </div> <a class="anchor" id="aa55cd635e4a6d84c2b9f1bfd2a10e9b5"></a><!-- doxytag: member="trie.h::trie_state_is_walkable" ref="aa55cd635e4a6d84c2b9f1bfd2a10e9b5" args="(const TrieState *s, AlphaChar c)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Bool trie_state_is_walkable </td> <td>(</td> <td class="paramtype">const <a class="el" href="struct__TrieState.html">TrieState</a> * </td> <td class="paramname"><em>s</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="triedefs_8h.html#acae969caa2057c6accde0e977546a5be">AlphaChar</a> </td> <td class="paramname"><em>c</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Test walkability of character from state. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">s</td><td>: the state to check </td></tr> <tr><td class="paramname">c</td><td>: the input character</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>boolean indicating walkability</dd></dl> <p>Test if there is a transition from state <em>s</em> with input character <em>c</em>. </p> </div> </div> <a class="anchor" id="a84e7cb79d0bf4d078a762cdec6be9419"></a><!-- doxytag: member="trie.h::trie_state_rewind" ref="a84e7cb79d0bf4d078a762cdec6be9419" args="(TrieState *s)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">void trie_state_rewind </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__TrieState.html">TrieState</a> * </td> <td class="paramname"><em>s</em></td><td>)</td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Rewind a trie state. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">s</td><td>: the state to rewind</td></tr> </table> </dd> </dl> <p>Put the state at root. </p> </div> </div> <a class="anchor" id="a1c8768dc722b3a4ed526b1ccc5280fbb"></a><!-- doxytag: member="trie.h::trie_state_walk" ref="a1c8768dc722b3a4ed526b1ccc5280fbb" args="(TrieState *s, AlphaChar c)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Bool trie_state_walk </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__TrieState.html">TrieState</a> * </td> <td class="paramname"><em>s</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="triedefs_8h.html#acae969caa2057c6accde0e977546a5be">AlphaChar</a> </td> <td class="paramname"><em>c</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Walk the trie from the state. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">s</td><td>: current state </td></tr> <tr><td class="paramname">c</td><td>: key character for walking</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>boolean value indicating the success of the walk</dd></dl> <p>Walk the trie stepwise, using a given character <em>c</em>. On return, the state <em>s</em> is updated to the new state if successfully walked. </p> </div> </div> <a class="anchor" id="af15c00ee43980d7cbd15614c068b0061"></a><!-- doxytag: member="trie.h::trie_store" ref="af15c00ee43980d7cbd15614c068b0061" args="(Trie *trie, const AlphaChar *key, TrieData data)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Bool trie_store </td> <td>(</td> <td class="paramtype"><a class="el" href="struct__Trie.html">Trie</a> * </td> <td class="paramname"><em>trie</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="triedefs_8h.html#acae969caa2057c6accde0e977546a5be">AlphaChar</a> * </td> <td class="paramname"><em>key</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="triedefs_8h.html#ab29d7be15a1627450c0591317f56162e">TrieData</a> </td> <td class="paramname"><em>data</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Store a value for an entry to trie. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">trie</td><td>: the trie </td></tr> <tr><td class="paramname">key</td><td>: the key for the entry to retrieve </td></tr> <tr><td class="paramname">data</td><td>: the data associated to the entry</td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>boolean value indicating the success of the process</dd></dl> <p>Store a <em>data</em> for the given <em>key</em> in <em>trie</em>. If <em>key</em> does not exist in <em>trie</em>, it will be appended. If it does, its current data will be overwritten. </p> </div> </div> </div> <hr size="1"><address style="text-align: right;"><small> Generated for libthai by <a href="http://www.doxygen.org/ index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.7.3</small></address> </body> </html>