⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hashtable_8h.html

📁 常用的数据结构和算法函数库
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>C Algorithms: hashtable.h File Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.4 --><div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div><h1>hashtable.h File Reference</h1>Hash table. <a href="#_details">More...</a><p><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr><tr><td colspan="2"><br><h2>Typedefs</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0"></a><!-- doxytag: member="hashtable.h::HashTable" ref="a0" args="" -->typedef _HashTable&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a0">HashTable</a></td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A hash table structure. <br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">typedef unsigned long(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a1">HashTableHashFunc</a> )(void *data)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Hash function used to generate hash values for keys used in a hash table.  <a href="#a1"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">typedef int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a2">HashTableEqualFunc</a> )(void *data1, void *data2)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Function used to compare two keys for equality.  <a href="#a2"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a3"></a><!-- doxytag: member="hashtable.h::HashTableFreeFunc" ref="a3" args=")(void *data)" -->typedef void(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a3">HashTableFreeFunc</a> )(void *data)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Type of function used to free keys and values when entries are removed from a hash table. <br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">typedef void(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a4">HashTableIterator</a> )(void *key, void *value, void *user_data)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Type of function used as a callback when iterating over data.  <a href="#a4"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">typedef int(*&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a5">HashTableRemoveIterator</a> )(void *key, void *value, void *user_data)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Type of function used as a callback when iterating over a hash table, selectively removing entries.  <a href="#a5"></a><br></td></tr><tr><td colspan="2"><br><h2>Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="hashtable_8h.html#a0">HashTable</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a6">hash_table_new</a> (<a class="el" href="hashtable_8h.html#a1">HashTableHashFunc</a> hash_func, <a class="el" href="hashtable_8h.html#a2">HashTableEqualFunc</a> equal_func)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Create a new hash table.  <a href="#a6"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a7">hash_table_free</a> (<a class="el" href="hashtable_8h.html#a0">HashTable</a> *hashtable)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Destroy a hash table.  <a href="#a7"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a8">hash_table_register_free_functions</a> (<a class="el" href="hashtable_8h.html#a0">HashTable</a> *hashtable, <a class="el" href="hashtable_8h.html#a3">HashTableFreeFunc</a> key_free_func, <a class="el" href="hashtable_8h.html#a3">HashTableFreeFunc</a> value_free_func)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Register functions used to free the key and value when an entry is removed from a hash table.  <a href="#a8"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a9">hash_table_insert</a> (<a class="el" href="hashtable_8h.html#a0">HashTable</a> *hashtable, void *key, void *value)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Insert a value into a hash table, overwriting any existing entry using the same key.  <a href="#a9"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a10">hash_table_lookup</a> (<a class="el" href="hashtable_8h.html#a0">HashTable</a> *hashtable, void *key)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Look up a value in a hash table by key.  <a href="#a10"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a11">hash_table_remove</a> (<a class="el" href="hashtable_8h.html#a0">HashTable</a> *hashtable, void *key)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Remove a value from a hash table.  <a href="#a11"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a12">hash_table_num_entries</a> (<a class="el" href="hashtable_8h.html#a0">HashTable</a> *hashtable)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Retrieve the number of entries in a hash table.  <a href="#a12"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a13">hash_table_foreach</a> (<a class="el" href="hashtable_8h.html#a0">HashTable</a> *hashtable, <a class="el" href="hashtable_8h.html#a4">HashTableIterator</a> iterator, void *user_data)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Iterate over all key-value pairs in a hash table.  <a href="#a13"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="hashtable_8h.html#a14">hash_table_foreach_remove</a> (<a class="el" href="hashtable_8h.html#a0">HashTable</a> *hashtable, <a class="el" href="hashtable_8h.html#a5">HashTableRemoveIterator</a> iterator, void *user_data)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Iterate over all key-value pairs in a hash table, selectively removing entries.  <a href="#a14"></a><br></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>Hash table. <p>A hash table stores a set of values which can be addressed by a key. Given the key, the corresponding value can be looked up quickly.<p>To create a hash table, use <a class="el" href="hashtable_8h.html#a6">hash_table_new</a>. To destroy a hash table, use <a class="el" href="hashtable_8h.html#a7">hash_table_free</a>.<p>To insert a value into a hash table, use <a class="el" href="hashtable_8h.html#a9">hash_table_insert</a>.<p>To remove a value from a hash table, use <a class="el" href="hashtable_8h.html#a11">hash_table_remove</a>.<p>To look up a value by its key, use <a class="el" href="hashtable_8h.html#a10">hash_table_lookup</a>.<hr><h2>Typedef Documentation</h2><a class="anchor" name="a2"></a><!-- doxytag: member="hashtable.h::HashTableEqualFunc" ref="a2" args=")(void *data1, void *data2)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">typedef int(* <a class="el" href="hashtable_8h.html#a2">HashTableEqualFunc</a>)(void *data1, void *data2)          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Function used to compare two keys for equality. <p><dl compact><dt><b>Returns:</b></dt><dd>Non-zero if the two keys are equal, zero if the keys are not equal.</dd></dl>    </td>  </tr></table><a class="anchor" name="a1"></a><!-- doxytag: member="hashtable.h::HashTableHashFunc" ref="a1" args=")(void *data)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">typedef unsigned long(* <a class="el" href="hashtable_8h.html#a1">HashTableHashFunc</a>)(void *data)          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Hash function used to generate hash values for keys used in a hash table. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>The value to generate a hash value for. </td></tr>  </table></dl><dl compact><dt><b>Returns:</b></dt><dd>The hash value.</dd></dl>    </td>  </tr></table><a class="anchor" name="a4"></a><!-- doxytag: member="hashtable.h::HashTableIterator" ref="a4" args=")(void *key, void *value, void *user_data)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">typedef void(* <a class="el" href="hashtable_8h.html#a4">HashTableIterator</a>)(void *key, void *value, void *user_data)          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Type of function used as a callback when iterating over data. <p>See <a class="el" href="hashtable_8h.html#a13">hash_table_foreach</a>.<p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>key</em>&nbsp;</td><td>The key to the current element being iterated over. </td></tr>    <tr><td valign="top"></td><td valign="top"><em>value</em>&nbsp;</td><td>The value of the current element being iterated over. </td></tr>    <tr><td valign="top"></td><td valign="top"><em>user_data</em>&nbsp;</td><td>Extra data passed to the <a class="el" href="hashtable_8h.html#a13">hash_table_foreach</a> function.</td></tr>  </table></dl>    </td>  </tr></table><a class="anchor" name="a5"></a><!-- doxytag: member="hashtable.h::HashTableRemoveIterator" ref="a5" args=")(void *key, void *value, void *user_data)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">typedef int(* <a class="el" href="hashtable_8h.html#a5">HashTableRemoveIterator</a>)(void *key, void *value, void *user_data)          </td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Type of function used as a callback when iterating over a hash table, selectively removing entries. <p>See <a class="el" href="hashtable_8h.html#a14">hash_table_foreach_remove</a>.<p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>key</em>&nbsp;</td><td>The key to the current element being iterated over. </td></tr>    <tr><td valign="top"></td><td valign="top"><em>value</em>&nbsp;</td><td>The value of the current element being iterated over. </td></tr>    <tr><td valign="top"></td><td valign="top"><em>user_data</em>&nbsp;</td><td>Extra data passed to the <a class="el" href="hashtable_8h.html#a13">hash_table_foreach</a> function. </td></tr>  </table></dl><dl compact><dt><b>Returns:</b></dt><dd>Non-zero (true) if the entry should be removed from the hash table. Zero (false) if the entry should not be removed from the hash table.</dd></dl>    </td>  </tr></table><hr><h2>Function Documentation</h2><a class="anchor" name="a13"></a><!-- doxytag: member="hashtable.h::hash_table_foreach" ref="a13" args="(HashTable *hashtable, HashTableIterator iterator, void *user_data)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">void hash_table_foreach           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="hashtable_8h.html#a0">HashTable</a> *&nbsp;</td>          <td class="mdname" nowrap> <em>hashtable</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td class="md"></td>          <td class="md" nowrap><a class="el" href="hashtable_8h.html#a4">HashTableIterator</a>&nbsp;</td>          <td class="mdname" nowrap> <em>iterator</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td class="md"></td>          <td class="md" nowrap>void *&nbsp;</td>          <td class="mdname" nowrap> <em>user_data</em></td>        </tr>        <tr>          <td class="md"></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Iterate over all key-value pairs in a hash table. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>hashtable</em>&nbsp;</td><td>The hash table. </td></tr>    <tr><td valign="top"></td><td valign="top"><em>iterator</em>&nbsp;</td><td>Callback function to invoke for each element. </td></tr>    <tr><td valign="top"></td><td valign="top"><em>user_data</em>&nbsp;</td><td>Extra data to pass to the iterator function as context.</td></tr>  </table></dl>    </td>  </tr></table><a class="anchor" name="a14"></a><!-- doxytag: member="hashtable.h::hash_table_foreach_remove" ref="a14" args="(HashTable *hashtable, HashTableRemoveIterator iterator, void *user_data)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">int hash_table_foreach_remove           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="hashtable_8h.html#a0">HashTable</a> *&nbsp;</td>          <td class="mdname" nowrap> <em>hashtable</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td class="md"></td>          <td class="md" nowrap><a class="el" href="hashtable_8h.html#a5">HashTableRemoveIterator</a>&nbsp;</td>          <td class="mdname" nowrap> <em>iterator</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td class="md"></td>          <td class="md" nowrap>void *&nbsp;</td>          <td class="mdname" nowrap> <em>user_data</em></td>        </tr>        <tr>          <td class="md"></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"></td>        </tr>      </table>    </td>  </tr></table><table cellspacing="5" cellpadding="0" border="0">  <tr>    <td>      &nbsp;    </td>    <td><p>Iterate over all key-value pairs in a hash table, selectively removing entries. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>hashtable</em>&nbsp;</td><td>The hash table. </td></tr>    <tr><td valign="top"></td><td valign="top"><em>iterator</em>&nbsp;</td><td>Callback function to invoke for each element. </td></tr>    <tr><td valign="top"></td><td valign="top"><em>user_data</em>&nbsp;</td><td>Extra data to pass to the iterator function as context. </td></tr>  </table></dl><dl compact><dt><b>Returns:</b></dt><dd>The total number of entries removed from the hash table.</dd></dl>    </td>  </tr></table><a class="anchor" name="a7"></a><!-- doxytag: member="hashtable.h::hash_table_free" ref="a7" args="(HashTable *hashtable)" --><p><table class="mdTable" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">        <tr>          <td class="md" nowrap valign="top">void hash_table_free           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="hashtable_8h.html#a0">HashTable</a> *&nbsp;</td>          <td class="mdname1" valign="top" nowrap> <em>hashtable</em>          </td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -