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

📄 glib-hash-tables.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
</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="id3289656"></a><h3><a name="g-hash-table-size"></a>g_hash_table_size ()</h3><a class="indexterm" name="id3289670"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint">guint</a>               g_hash_table_size                   (<a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table);</pre><p>Returns the number of elements contained in 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_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"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> the number of key/value pairs in 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="id3289754"></a><h3><a name="g-hash-table-lookup"></a>g_hash_table_lookup ()</h3><a class="indexterm" name="id3289767"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            g_hash_table_lookup                 (<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>Looks up a key in a <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>. Note that this function cannotdistinguish between a key that is not present and one which is presentand has the value <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. If you need this distinction, use<a class="link" href="glib-Hash-Tables.html#g-hash-table-lookup-extended"><code class="function">g_hash_table_lookup_extended()</code></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_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> the key to look up.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> the associated value, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the key is not found.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3289899"></a><h3><a name="g-hash-table-lookup-extended"></a>g_hash_table_lookup_extended ()</h3><a class="indexterm" name="id3289912"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            g_hash_table_lookup_extended        (<a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table,                                                         <a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> lookup_key,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> *orig_key,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> *value);</pre><p>Looks up a key in the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>, returning the original key and theassociated value and a <a class="link" href="glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> which is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the key was found. Thisis useful if you need to free the memory allocated for the original key,for example before calling <a class="link" href="glib-Hash-Tables.html#g-hash-table-remove"><code class="function">g_hash_table_remove()</code></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_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>lookup_key</code></em>&#160;:</span></p></td><td> the key to look up.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>orig_key</code></em>&#160;:</span></p></td><td> returns the original key.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>value</code></em>&#160;:</span></p></td><td> returns the value associated with the key.</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 the key was found in 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="id3290105"></a><h3><a name="g-hash-table-foreach"></a>g_hash_table_foreach ()</h3><a class="indexterm" name="id3290118"></a><pre class="programlisting">void                g_hash_table_foreach                (<a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table,                                                         <a class="link" href="glib-Hash-Tables.html#GHFunc">GHFunc</a> func,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Calls the given function for each of the key/value pairs in the<a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.  The function is passed the key and value of eachpair, 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/removeitems). To remove all items matching a predicate, use<a class="link" href="glib-Hash-Tables.html#g-hash-table-foreach-remove"><code class="function">g_hash_table_foreach_remove()</code></a>.</p><p>See <a class="link" href="glib-Hash-Tables.html#g-hash-table-find"><code class="function">g_hash_table_find()</code></a> for performance caveats for linearorder searches in contrast to <a class="link" href="glib-Hash-Tables.html#g-hash-table-lookup"><code class="function">g_hash_table_lookup()</code></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_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>func</code></em>&#160;:</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>&#160;:</span></p></td><td> user data to pass to the function.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3290275"></a><h3><a name="g-hash-table-find"></a>g_hash_table_find ()</h3><a class="indexterm" name="id3290291"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            g_hash_table_find                   (<a class="link" href="glib-Hash-Tables.html#GHashTable">GHashTable</a> *hash_table,                                                         <a class="link" href="glib-Hash-Tables.html#GHRFunc">GHRFunc</a> predicate,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Calls the given function for key/value pairs in the <a class="link" href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a> until<em class="parameter"><code>predicate</code></em> returns <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>.  The function is passed the key and value ofeach 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>Note, that hash tables are really only optimized for forward lookups,i.e. <a class="link" href="glib-Hash-Tables.html#g-hash-table-lookup"><code class="function">g_hash_table_lookup()</code></a>.So code that frequently issues <a class="link" href="glib-Hash-Tables.html#g-hash-table-find"><code class="function">g_hash_table_find()</code></a> or<a class="link" href="glib-Hash-Tables.html#g-hash-table-foreach"><code class="function">g_hash_table_foreach()</code></a> (e.g. in the order of once per every entry in ahash table) should probably be reworked to use additional or differentdata structures for reverse lookups (keep in mind that an O(n) find/foreachoperation issued for all n values in a hash table ends up needing O(n*n)operations).</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>predicate</code></em>&#160;:</span></p></td><td>  function to test the key/value pairs for a certain property.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</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>&#160;:</span></p></td><td> The value of the first key/value pair is returned, for which

⌨️ 快捷键说明

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