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

📄 group__gdsl__hash.html

📁 一个通用的C语言实现的数据结构
💻 HTML
📖 第 1 页 / 共 5 页
字号:
  </tr></table><a class="anchor" name="g98ae1fcdb6908b699056e131357d837b"></a><!-- doxytag: member="gdsl_hash.h::gdsl_hash_insert" ref="g98ae1fcdb6908b699056e131357d837b" args="(gdsl_hash_t H, void *VALUE)" --><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"><a class="el" href="group__gdsl__types.html#g0e2b9d7fb5ca9e6d50100e5d9e4bcae7">gdsl_element_t</a> gdsl_hash_insert           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="group__gdsl__hash.html#ge145ec3ea3d118dcc593ab7902162cd2">gdsl_hash_t</a>&nbsp;</td>          <td class="mdname" nowrap> <em>H</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>VALUE</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>Insert an element into a hashtable (PUSH). <p>Allocate a new element E by calling H's ALLOC_F function on VALUE. The key K of the new element E is computed using KEY_F called on E. If the value of gdsl_hash_get_lists_max_size(H) is not reached, or if it is equal to zero, then the insertion is simple. Otherwise, H is re-organized as follow:<ul><li>its actual gdsl_hash_get_entries_number(H) (say N) is modified as N * 2 + 1</li><li>its actual gdsl_hash_get_lists_max_size(H) (say M) is modified as M * 2 The element E is then inserted into H at the entry computed by HASH_F( K ) modulo gdsl_hash_get_entries_number(H). ALLOC_F, KEY_F and HASH_F are the function pointers passed to <a class="el" href="group__gdsl__hash.html#ge19c5647d31f3d8f88b988e89609049c">gdsl_hash_alloc()</a>.</li></ul><p><dl compact><dt><b>Note:</b></dt><dd>Complexity: O( 1 ) if gdsl_hash_get_lists_max_size(H) is not reached or if it is equal to zero <p>Complexity: O ( gdsl_hash_modify (H) ) if gdsl_hash_get_lists_max_size(H) is reached, so H needs to grow </dd></dl><dl compact><dt><b>Precondition:</b></dt><dd>H must be a valid gdsl_hash_t </dd></dl><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>H</em>&nbsp;</td><td>The hashtable to modify </td></tr>    <tr><td valign="top"></td><td valign="top"><em>VALUE</em>&nbsp;</td><td>The value used to make the new element to insert into H </td></tr>  </table></dl><dl compact><dt><b>Returns:</b></dt><dd>the inserted element E in case of success. <p>NULL in case of insufficient memory. </dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__gdsl__hash.html#ge19c5647d31f3d8f88b988e89609049c">gdsl_hash_alloc()</a> <p><a class="el" href="group__gdsl__hash.html#g2e7d31f45b959fe14badc3b620a8de5e">gdsl_hash_remove()</a> <p><a class="el" href="group__gdsl__hash.html#g94dfde405aae321e2c3d02d3c260bfcb">gdsl_hash_delete()</a> <p><a class="el" href="group__gdsl__hash.html#g9f9bd328f3237d333a7d7bab5285aa2d">gdsl_hash_get_size()</a> <p><a class="el" href="group__gdsl__hash.html#gd87fd81a7853bdcfe2cc7fdd142556f0">gdsl_hash_get_entries_number()</a> <p><a class="el" href="group__gdsl__hash.html#g56acbd8af54ef98000d1749afbb28234">gdsl_hash_modify()</a> </dd></dl>    </td>  </tr></table><a class="anchor" name="g2e7d31f45b959fe14badc3b620a8de5e"></a><!-- doxytag: member="gdsl_hash.h::gdsl_hash_remove" ref="g2e7d31f45b959fe14badc3b620a8de5e" args="(gdsl_hash_t H, const char *KEY)" --><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"><a class="el" href="group__gdsl__types.html#g0e2b9d7fb5ca9e6d50100e5d9e4bcae7">gdsl_element_t</a> gdsl_hash_remove           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="group__gdsl__hash.html#ge145ec3ea3d118dcc593ab7902162cd2">gdsl_hash_t</a>&nbsp;</td>          <td class="mdname" nowrap> <em>H</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td class="md"></td>          <td class="md" nowrap>const char *&nbsp;</td>          <td class="mdname" nowrap> <em>KEY</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>Remove an element from a hashtable (POP). <p>Search into the hashtable H for the first element E equal to KEY. If E is found, it is removed from H and then returned.<p><dl compact><dt><b>Note:</b></dt><dd>Complexity: O( M ), where M is the average size of H's lists </dd></dl><dl compact><dt><b>Precondition:</b></dt><dd>H must be a valid gdsl_hash_t </dd></dl><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>H</em>&nbsp;</td><td>The hashtable to modify </td></tr>    <tr><td valign="top"></td><td valign="top"><em>KEY</em>&nbsp;</td><td>The key used to find the element to remove </td></tr>  </table></dl><dl compact><dt><b>Returns:</b></dt><dd>the first founded element equal to KEY in H in case is found. <p>NULL in case no element equal to KEY is found in H. </dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__gdsl__hash.html#g98ae1fcdb6908b699056e131357d837b">gdsl_hash_insert()</a> <p><a class="el" href="group__gdsl__hash.html#gb8713e392d660458f514a8489c25c7c0">gdsl_hash_search()</a> <p><a class="el" href="group__gdsl__hash.html#g94dfde405aae321e2c3d02d3c260bfcb">gdsl_hash_delete()</a> </dd></dl>    </td>  </tr></table><a class="anchor" name="g94dfde405aae321e2c3d02d3c260bfcb"></a><!-- doxytag: member="gdsl_hash.h::gdsl_hash_delete" ref="g94dfde405aae321e2c3d02d3c260bfcb" args="(gdsl_hash_t H, const char *KEY)" --><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"><a class="el" href="group__gdsl__hash.html#ge145ec3ea3d118dcc593ab7902162cd2">gdsl_hash_t</a> gdsl_hash_delete           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="group__gdsl__hash.html#ge145ec3ea3d118dcc593ab7902162cd2">gdsl_hash_t</a>&nbsp;</td>          <td class="mdname" nowrap> <em>H</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td class="md"></td>          <td class="md" nowrap>const char *&nbsp;</td>          <td class="mdname" nowrap> <em>KEY</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>Delete an element from a hashtable. <p>Remove from he hashtable H the first founded element E equal to KEY. If E is found, it is removed from H and E is deallocated using H's FREE_F function passed to <a class="el" href="group__gdsl__hash.html#ge19c5647d31f3d8f88b988e89609049c">gdsl_hash_alloc()</a>, then H is returned.<p><dl compact><dt><b>Note:</b></dt><dd>Complexity: O( M ), where M is the average size of H's lists </dd></dl><dl compact><dt><b>Precondition:</b></dt><dd>H must be a valid gdsl_hash_t </dd></dl><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>H</em>&nbsp;</td><td>The hashtable to modify </td></tr>    <tr><td valign="top"></td><td valign="top"><em>KEY</em>&nbsp;</td><td>The key used to find the element to remove </td></tr>  </table></dl><dl compact><dt><b>Returns:</b></dt><dd>the modified hashtable after removal of E if E was found. <p>NULL if no element equal to KEY was found. </dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__gdsl__hash.html#g98ae1fcdb6908b699056e131357d837b">gdsl_hash_insert()</a> <p><a class="el" href="group__gdsl__hash.html#gb8713e392d660458f514a8489c25c7c0">gdsl_hash_search()</a> <p><a class="el" href="group__gdsl__hash.html#g2e7d31f45b959fe14badc3b620a8de5e">gdsl_hash_remove()</a> </dd></dl>    </td>  </tr></table><a class="anchor" name="g56acbd8af54ef98000d1749afbb28234"></a><!-- doxytag: member="gdsl_hash.h::gdsl_hash_modify" ref="g56acbd8af54ef98000d1749afbb28234" args="(gdsl_hash_t H, ushort NEW_ENTRIES_NB, ushort NEW_LISTS_MAX_SIZE)" --><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"><a class="el" href="group__gdsl__hash.html#ge145ec3ea3d118dcc593ab7902162cd2">gdsl_hash_t</a> gdsl_hash_modify           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top"><a class="el" href="group__gdsl__hash.html#ge145ec3ea3d118dcc593ab7902162cd2">gdsl_hash_t</a>&nbsp;</td>          <td class="mdname" nowrap> <em>H</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td class="md"></td>          <td class="md" nowrap>ushort&nbsp;</td>          <td class="mdname" nowrap> <em>NEW_ENTRIES_NB</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td class="md"></td>          <td class="md" nowrap>ushort&nbsp;</td>          <td class="mdname" nowrap> <em>NEW_LISTS_MAX_SIZE</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>Increase the dimensions of a hashtable. <p>The hashtable H is re-organized to have NEW_ENTRIES_NB lists entries. Each entry is limited to NEW_LISTS_MAX_SIZE elements. After a call to this function, all insertions into H will make H automatically growing if needed. The grow is needed each time an insertion makes an entry list to reach NEW_LISTS_MAX_SIZE elements. In this case, H will be reorganized automatically by <a class="el" href="group__gdsl__hash.html#g98ae1fcdb6908b699056e131357d837b">gdsl_hash_insert()</a>.<p><dl compact><dt><b>Note:</b></dt><dd>Complexity: O( |H| ) </dd></dl><dl compact><dt><b>Precondition:</b></dt><dd>H must be a valid gdsl_hash_t &amp; NEW_ENTRIES_NB &gt; gdsl_hash_get_entries_number(H) &amp; NEW_LISTS_MAX_SIZE &gt; gdsl_hash_get_lists_max_size(H) </dd></dl><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>H</em>&nbsp;</td><td>The hashtable to modify </td></tr>    <tr><td valign="top"></td><td valign="top"><em>NEW_ENTRIES_NB</em>&nbsp;</td><td></td></tr>    <tr><td valign="top"></td><td valign="top"><em>NEW_LISTS_MAX_SIZE</em>&nbsp;</td><td></td></tr>  </table></dl><dl compact><dt><b>Returns:</b></dt><dd>the modified hashtable H in case of success <p>NULL in case of failure, or in case NEW_ENTRIES_NB &lt;= gdsl_hash_get_entries_number(H) or in case NEW_LISTS_MAX_SIZE &lt;= gdsl_hash_get_lists_max_size(H) in these cases, H is not modified </dd></dl><dl compact><dt><b>See also:</b></dt><dd><a class="el" href="group__gdsl__hash.html#g98ae1fcdb6908b699056e131357d837b">gdsl_hash_insert()</a> <p><a class="el" href="group__gdsl__hash.html#gd87fd81a7853bdcfe2cc7fdd142556f0">gdsl_hash_get_entries_number()</a> <p><a class="el" href="group__gdsl__hash.html#g6c858e792ee64ce14bfeb0e7c03d3e42">gdsl_hash_get_fill_factor()</a> <p><a class="el" href="group__gdsl__hash.html#gd89e4fe4756aa34a0f47948819e53682">gdsl_hash_get_longest_list_size()</a> <p><a class="el" href="group__gdsl__hash.html#g5d9b8da0f4ad5e60b7fdb38156ce48f3">gdsl_hash_get_lists_max_size()</a> </dd></dl>    </td>  </tr>

⌨️ 快捷键说明

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