?? glib-hash-tables.html
字號:
<a name="g-hash-table-find"></a>g_hash_table_find ()</h3><a class="indexterm" name="id3139244"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gpointer">gpointer</a> g_hash_table_find (<a href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table, <a href="glib-Hash-Tables.html#GHRFunc">GHRFunc</a> predicate, <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Calls the given function for key/value pairs in the <a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a> until <em class="parameter"><code>predicate</code></em> returns <code class="literal">TRUE</code>. The function is passed the key and value of each pair, and the given <em class="parameter"><code>user_data</code></em> parameter. The hash table may notbe modified while iterating over it (you can't add/remove items).</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>hash_table</code></em> :</span></td><td> a <a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>predicate</code></em> :</span></td><td> function to test the key/value pairs for a certain property.</td></tr><tr><td><span class="term"><em class="parameter"><code>user_data</code></em> :</span></td><td> user data to pass to the function.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> The value of the first key/value pair is returned, for which func evaluates to <code class="literal">TRUE</code>. If no pair with the requested property is found, <code class="literal">NULL</code> is returned.</td></tr></tbody></table></div><p>Since 2.4</p></div><hr><div class="refsect2" lang="en"><a name="id3139404"></a><h3><a name="GHFunc"></a>GHFunc ()</h3><a class="indexterm" name="id3139414"></a><pre class="programlisting">void (*GHFunc) (<a href="glib-Basic-Types.html#gpointer">gpointer</a> key, <a href="glib-Basic-Types.html#gpointer">gpointer</a> value, <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Specifies the type of the function passed to <a 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 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><span class="term"><em class="parameter"><code>key</code></em> :</span></td><td>a key.</td></tr><tr><td><span class="term"><em class="parameter"><code>value</code></em> :</span></td><td>the value corresponding to the key.</td></tr><tr><td><span class="term"><em class="parameter"><code>user_data</code></em> :</span></td><td>user data passed to <a 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="id3139545"></a><h3><a name="g-hash-table-remove"></a>g_hash_table_remove ()</h3><a class="indexterm" name="id3139555"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> g_hash_table_remove (<a href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table, <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> key);</pre><p>Removes a key and its associated value from a <a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</p><p>If the <a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a> was created using <a 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 freed yourself.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>hash_table</code></em> :</span></td><td> a <a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>key</code></em> :</span></td><td> the key to remove.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <code class="literal">TRUE</code> if the key was found and removed from the <a 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="id3139692"></a><h3><a name="g-hash-table-steal"></a>g_hash_table_steal ()</h3><a class="indexterm" name="id3139703"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> g_hash_table_steal (<a href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table, <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> key);</pre><p>Removes a key and its associated value from a <a 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><span class="term"><em class="parameter"><code>hash_table</code></em> :</span></td><td> a <a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>key</code></em> :</span></td><td> the key to remove.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <code class="literal">TRUE</code> if the key was found and removed from the <a 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="id3139815"></a><h3><a name="g-hash-table-foreach-remove"></a>g_hash_table_foreach_remove ()</h3><a class="indexterm" name="id3139826"></a><pre class="programlisting"><a href="glib-Basic-Types.html#guint">guint</a> g_hash_table_foreach_remove (<a href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table, <a href="glib-Hash-Tables.html#GHRFunc">GHRFunc</a> func, <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Calls the given function for each key/value pair in the <a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.If the function returns <code class="literal">TRUE</code>, then the key/value pair is removed from the<a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>. If you supplied key or value destroy functions when creatingthe <a 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></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>hash_table</code></em> :</span></td><td> a <a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>func</code></em> :</span></td><td> the function to call for each key/value pair.</td></tr><tr><td><span class="term"><em class="parameter"><code>user_data</code></em> :</span></td><td> user data to pass to the function.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the number of key/value pairs removed.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3139972"></a><h3><a name="g-hash-table-foreach-steal"></a>g_hash_table_foreach_steal ()</h3><a class="indexterm" name="id3139984"></a><pre class="programlisting"><a href="glib-Basic-Types.html#guint">guint</a> g_hash_table_foreach_steal (<a href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table, <a href="glib-Hash-Tables.html#GHRFunc">GHRFunc</a> func, <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Calls the given function for each key/value pair in the <a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.If the function returns <code class="literal">TRUE</code>, then the key/value pair is removed from the<a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>, but no key or value destroy functions are called.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>hash_table</code></em> :</span></td><td> a <a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>func</code></em> :</span></td><td> the function to call for each key/value pair.</td></tr><tr><td><span class="term"><em class="parameter"><code>user_data</code></em> :</span></td><td> user data to pass to the function.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the number of key/value pairs removed.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3140120"></a><h3><a name="GHRFunc"></a>GHRFunc ()</h3><a class="indexterm" name="id3140130"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a> (*GHRFunc) (<a href="glib-Basic-Types.html#gpointer">gpointer</a> key, <a href="glib-Basic-Types.html#gpointer">gpointer</a> value, <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Specifies the type of the function passed to <a href="glib-Hash-Tables.html#g-hash-table-foreach-remove"><code class="function">g_hash_table_foreach_remove()</code></a>.It is called with each key/value pair, together with the <em class="parameter"><code>user_data</code></em> parameterpassed to <a href="glib-Hash-Tables.html#g-hash-table-foreach-remove"><code class="function">g_hash_table_foreach_remove()</code></a>.It should return <code class="literal">TRUE</code> if the key/value pair should be removed from the<a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>key</code></em> :</span></td><td>a key.</td></tr><tr><td><span class="term"><em class="parameter"><code>value</code></em> :</span></td><td>the value associated with the key.</td></tr><tr><td><span class="term"><em class="parameter"><code>user_data</code></em> :</span></td><td>user data passed to <a href="glib-Hash-Tables.html#g-hash-table-remove"><code class="function">g_hash_table_remove()</code></a>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td><code class="literal">TRUE</code> if the key/value pair should be removed from the <a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -