📄 glib-hash-tables.html
字号:
func evaluates to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>. If no pair with the requested property is found,<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> is returned.</td></tr></tbody></table></div><p class="since">Since 2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3290508"></a><h3><a name="GHFunc"></a>GHFunc ()</h3><a class="indexterm" name="id3290521"></a><pre class="programlisting">void (*GHFunc) (<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> key, <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> value, <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Specifies the type of the function passed to <a class="link" href="glib-Hash-Tables.html#g-hash-table-foreach"><code class="function">g_hash_table_foreach()</code></a>.It is called with each key/value pair, together with the <em class="parameter"><code>user_data</code></em> parameterwhich is passed to <a class="link" href="glib-Hash-Tables.html#g-hash-table-foreach"><code class="function">g_hash_table_foreach()</code></a>.</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> :</span></p></td><td>a key.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td><td>the value corresponding to the key.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td><td>user data passed to <a class="link" href="glib-Hash-Tables.html#g-hash-table-foreach"><code class="function">g_hash_table_foreach()</code></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3290652"></a><h3><a name="g-hash-table-remove"></a>g_hash_table_remove ()</h3><a class="indexterm" name="id3290665"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> g_hash_table_remove (<a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table, <a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> key);</pre><p>Removes a key and its associated value from a <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</p><p>If the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a> was created using <a class="link" href="glib-Hash-Tables.html#g-hash-table-new-full"><code class="function">g_hash_table_new_full()</code></a>, thekey and value are freed using the supplied destroy functions, otherwiseyou have to make sure that any dynamically allocated values are freedyourself.</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> :</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> :</span></p></td><td> the key to remove.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the key was found and removed from the <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="id3290806"></a><h3><a name="g-hash-table-steal"></a>g_hash_table_steal ()</h3><a class="indexterm" name="id3290819"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> g_hash_table_steal (<a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table, <a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> key);</pre><p>Removes a key and its associated value from a <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a> withoutcalling the key and value destroy functions.</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> :</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> :</span></p></td><td> the key to remove.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the key was found and removed from the <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="id3290936"></a><h3><a name="g-hash-table-foreach-remove"></a>g_hash_table_foreach_remove ()</h3><a class="indexterm" name="id3290950"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint">guint</a> g_hash_table_foreach_remove (<a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table, <a class="link" href="glib-Hash-Tables.html#GHRFunc">GHRFunc</a> func, <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Calls the given function for each key/value pair in the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.If the function returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, then the key/value pair is removed from the<a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>. If you supplied key or value destroy functions when creatingthe <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>, they are used to free the memory allocated for the removedkeys and values.</p><p>See <span class="type">GHashTableIterator</span> for an alternative way to loop over the key/value pairs in the hash table.</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> :</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>func</code></em> :</span></p></td><td> the function to call for each key/value pair.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td><td> user data to pass to the function.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the number of key/value pairs removed.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3291114"></a><h3><a name="g-hash-table-foreach-steal"></a>g_hash_table_foreach_steal ()</h3><a class="indexterm" name="id3291128"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint">guint</a> g_hash_table_foreach_steal (<a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table, <a class="link" href="glib-Hash-Tables.html#GHRFunc">GHRFunc</a> func, <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Calls the given function for each key/value pair in the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.If the function returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, then the key/value pair is removed from the<a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>, but no key or value destroy functions are called.</p><p>See <span class="type">GHashTableIterator</span> for an alternative way to loop over the key/value pairs in the hash table.</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> :</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>func</code></em> :</span></p></td><td> the function to call for each key/value pair.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td><td> user data to pass to the function.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the number of key/value pairs removed.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3291283"></a><h3><a name="g-hash-table-remove-all"></a>g_hash_table_remove_all ()</h3><a class="indexterm" name="id3291298"></a><pre class="programlisting">void g_hash_table_remove_all (<a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table);</pre>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -