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

📄 glib-hash-tables.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
  <a class="link" href="glib-Hash-Tables.html#g-str-hash"><code class="function">g_str_hash()</code></a> functions are provided for some common types of keys.  If hash_func is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, <a class="link" href="glib-Hash-Tables.html#g-direct-hash"><code class="function">g_direct_hash()</code></a> is used.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>key_equal_func</code></em>&#160;:</span></p></td><td> a function to check two keys for equality.  This is  used when looking up keys in the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.  The <a class="link" href="glib-Hash-Tables.html#g-direct-equal"><code class="function">g_direct_equal()</code></a>,  <a class="link" href="glib-Hash-Tables.html#g-int-equal"><code class="function">g_int_equal()</code></a> and <a class="link" href="glib-Hash-Tables.html#g-str-equal"><code class="function">g_str_equal()</code></a> functions are provided for the most  common types of keys. If <em class="parameter"><code>key_equal_func</code></em> is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, keys are compared  directly in a similar fashion to <a class="link" href="glib-Hash-Tables.html#g-direct-equal"><code class="function">g_direct_equal()</code></a>, but without the  overhead of a function call.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> a new <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3288786"></a><h3><a name="g-hash-table-new-full"></a>g_hash_table_new_full ()</h3><a class="indexterm" name="id3288799"></a><pre class="programlisting"><a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a>*         g_hash_table_new_full               (<a class="link" href="glib-Hash-Tables.html#GHashFunc">GHashFunc</a> hash_func,                                                         <a class="link" href="glib-Hash-Tables.html#GEqualFunc">GEqualFunc</a> key_equal_func,                                                         <a class="link" href="glib-Datasets.html#GDestroyNotify">GDestroyNotify</a> key_destroy_func,                                                         <a class="link" href="glib-Datasets.html#GDestroyNotify">GDestroyNotify</a> value_destroy_func);</pre><p>Creates a new <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a> like <a class="link" href="glib-Hash-Tables.html#g-hash-table-new"><code class="function">g_hash_table_new()</code></a> with a reference countof 1 and allows to specify functions to free the memory allocated for thekey and value that get called when removing the entry from the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>hash_func</code></em>&#160;:</span></p></td><td> a function to create a hash value from a key.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>key_equal_func</code></em>&#160;:</span></p></td><td> a function to check two keys for equality.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>key_destroy_func</code></em>&#160;:</span></p></td><td> a function to free the memory allocated for the key  used when removing the entry from the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a> or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if you  don't want to supply such a function.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>value_destroy_func</code></em>&#160;:</span></p></td><td> a function to free the memory allocated for the  value used when removing the entry from the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a> or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if  you don't want to supply such a function.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> a new <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3289005"></a><h3><a name="GHashFunc"></a>GHashFunc ()</h3><a class="indexterm" name="id3289017"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint">guint</a>               (*GHashFunc)                        (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> key);</pre><p>Specifies the type of the hash function which is passed to<a class="link" href="glib-Hash-Tables.html#g-hash-table-new"><code class="function">g_hash_table_new()</code></a> when a <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a> is created.</p><p>The function is passed a key and should return a <a class="link" href="glib-Basic-Types.html#guint"><span class="type">guint</span></a> hash value.The functions <a class="link" href="glib-Hash-Tables.html#g-direct-hash"><code class="function">g_direct_hash()</code></a>, <a class="link" href="glib-Hash-Tables.html#g-int-hash"><code class="function">g_int_hash()</code></a> and <a class="link" href="glib-Hash-Tables.html#g-str-hash"><code class="function">g_str_hash()</code></a> providehash functions which can be used when the key is a <a class="link" href="glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a>, <a class="link" href="glib-Basic-Types.html#gint"><span class="type">gint</span></a>, and <a class="link" href="glib-Basic-Types.html#gchar"><span class="type">gchar</span></a>* respectively.</p><p>The hash values should be evenly distributed over a fairly large range?The modulus is taken with the hash table size (a prime number)to find the 'bucket' to place each key into.The function should also be very fast, since it is called for each keylookup.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>key</code></em>&#160;:</span></p></td><td>a key.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td>the hash value corresponding to the key.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3289174"></a><h3><a name="GEqualFunc"></a>GEqualFunc ()</h3><a class="indexterm" name="id3289185"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            (*GEqualFunc)                       (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> a,                                                         <a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> b);</pre><p>Specifies the type of a function used to test two values forequality. The function should return <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if both values are equal and<a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>a</code></em>&#160;:</span></p></td><td>a value.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>b</code></em>&#160;:</span></p></td><td>a value to compare with.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td><a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <em class="parameter"><code>a</code></em> = <em class="parameter"><code>b</code></em>; <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3289317"></a><h3><a name="g-hash-table-insert"></a>g_hash_table_insert ()</h3><a class="indexterm" name="id3289330"></a><pre class="programlisting">void                g_hash_table_insert                 (<a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> key,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> value);</pre><p>Inserts a new key and value into a <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</p><p>If the key already exists in the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a> its current value is replacedwith the new value. If you supplied a <em class="parameter"><code>value_destroy_func</code></em> when creating the<a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>, the old value is freed using that function. If you supplieda <em class="parameter"><code>key_destroy_func</code></em> when creating the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>, the passed key is freedusing that function.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>hash_table</code></em>&#160;:</span></p></td><td> a <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>key</code></em>&#160;:</span></p></td><td> a key to insert.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>value</code></em>&#160;:</span></p></td><td> the value to associate with the key.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3289482"></a><h3><a name="g-hash-table-replace"></a>g_hash_table_replace ()</h3><a class="indexterm" name="id3289496"></a><pre class="programlisting">void                g_hash_table_replace                (<a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> key,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> value);</pre><p>Inserts a new key and value into a <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a> similar to<a class="link" href="glib-Hash-Tables.html#g-hash-table-insert"><code class="function">g_hash_table_insert()</code></a>. The difference is that if the key already existsin the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>, it gets replaced by the new key. If you supplied a<em class="parameter"><code>value_destroy_func</code></em> when creating the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>, the old value is freedusing that function. If you supplied a <em class="parameter"><code>key_destroy_func</code></em> when creating the<a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>, the old key is freed using that function.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>hash_table</code></em>&#160;:</span></p></td><td> a <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.

⌨️ 快捷键说明

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