📄 hash_tables.sgml
字号:
<refsect2><title><anchor id="g-hash-table-foreach-steal">g_hash_table_foreach_steal ()</title><programlisting><link linkend="guint">guint</link> g_hash_table_foreach_steal (<link linkend="GHashTable">GHashTable</link> *hash_table, <link linkend="GHRFunc">GHRFunc</link> func, <link linkend="gpointer">gpointer</link> user_data);</programlisting><para>Calls the given function for each key/value pair in the <link linkend="GHashTable">GHashTable</link>.If the function returns <literal>TRUE</literal>, then the key/value pair is removed from the<link linkend="GHashTable">GHashTable</link>, but no key or value destroy functions are called.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>hash_table</parameter> :</entry><entry> a <link linkend="GHashTable">GHashTable</link>.</entry></row><row><entry align="right"><parameter>func</parameter> :</entry><entry> the function to call for each key/value pair.</entry></row><row><entry align="right"><parameter>user_data</parameter> :</entry><entry> user data to pass to the function.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> the number of key/value pairs removed.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GHRFunc">GHRFunc ()</title><programlisting><link linkend="gboolean">gboolean</link> (*GHRFunc) (<link linkend="gpointer">gpointer</link> key, <link linkend="gpointer">gpointer</link> value, <link linkend="gpointer">gpointer</link> user_data);</programlisting><para>Specifies the type of the function passed to <link linkend="g-hash-table-foreach-remove">g_hash_table_foreach_remove</link>().It is called with each key/value pair, together with the <parameter>user_data</parameter> parameterpassed to <link linkend="g-hash-table-foreach-remove">g_hash_table_foreach_remove</link>().It should return <literal>TRUE</literal> if the key/value pair should be removed from the<link linkend="GHashTable">GHashTable</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>key</parameter> :</entry><entry>a key.</entry></row><row><entry align="right"><parameter>value</parameter> :</entry><entry>the value associated with the key.</entry></row><row><entry align="right"><parameter>user_data</parameter> :</entry><entry>user data passed to <link linkend="g-hash-table-remove">g_hash_table_remove</link>().</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if the key/value pair should be removed from the <link linkend="GHashTable">GHashTable</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-hash-table-freeze">g_hash_table_freeze()</title><programlisting>#define g_hash_table_freeze(hash_table)</programlisting><warning><para><literal>g_hash_table_freeze</literal> is deprecated and should not be used in newly-written code.</para></warning><para>This function is deprecated and will be removed in the next major release of GLib. It does nothing.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>hash_table</parameter> :</entry><entry></entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-hash-table-thaw">g_hash_table_thaw()</title><programlisting>#define g_hash_table_thaw(hash_table)</programlisting><warning><para><literal>g_hash_table_thaw</literal> is deprecated and should not be used in newly-written code.</para></warning><para>This function is deprecated and will be removed in the next major release of GLib. It does nothing.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>hash_table</parameter> :</entry><entry></entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-hash-table-destroy">g_hash_table_destroy ()</title><programlisting>void g_hash_table_destroy (<link linkend="GHashTable">GHashTable</link> *hash_table);</programlisting><para>Destroys the <link linkend="GHashTable">GHashTable</link>. If keys and/or values are dynamically allocated, you should either free them first or create the <link linkend="GHashTable">GHashTable</link>using <link linkend="g-hash-table-new-full">g_hash_table_new_full</link>(). In the latter case the destroy functions you supplied will be called on all keys and values before destroying the <link linkend="GHashTable">GHashTable</link>.</para><para></para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>hash_table</parameter> :</entry><entry> a <link linkend="GHashTable">GHashTable</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-direct-equal">g_direct_equal ()</title><programlisting><link linkend="gboolean">gboolean</link> g_direct_equal (<link linkend="gconstpointer">gconstpointer</link> v, <link linkend="gconstpointer">gconstpointer</link> v2);</programlisting><para>Compares two <link linkend="gpointer">gpointer</link> arguments and returns <literal>TRUE</literal> if they are equal.It can be passed to <link linkend="g-hash-table-new">g_hash_table_new</link>() as the <parameter>key_equal_func</parameter>parameter, when using pointers as keys in a <link linkend="GHashTable">GHashTable</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>v</parameter> :</entry><entry>a key.</entry></row><row><entry align="right"><parameter>v2</parameter> :</entry><entry>a key to compare with <parameter>v</parameter>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if the two keys match.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-direct-hash">g_direct_hash ()</title><programlisting><link linkend="guint">guint</link> g_direct_hash (<link linkend="gconstpointer">gconstpointer</link> v);</programlisting><para>Converts a gpointer to a hash value.It can be passed to <link linkend="g-hash-table-new">g_hash_table_new</link>() as the <parameter>hash_func</parameter> parameter, whenusing pointers as keys in a <link linkend="GHashTable">GHashTable</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>v</parameter> :</entry><entry>a gpointer key.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>a hash value corresponding to the key.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-int-equal">g_int_equal ()</title><programlisting><link linkend="gboolean">gboolean</link> g_int_equal (<link linkend="gconstpointer">gconstpointer</link> v, <link linkend="gconstpointer">gconstpointer</link> v2);</programlisting><para>Compares the two <link linkend="gint">gint</link> values being pointed to and returns <literal>TRUE</literal> if they areequal.It can be passed to <link linkend="g-hash-table-new">g_hash_table_new</link>() as the <parameter>key_equal_func</parameter>parameter, when using pointers to integers as keys in a <link linkend="GHashTable">GHashTable</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>v</parameter> :</entry><entry>a pointer to a <link linkend="gint">gint</link> key.</entry></row><row><entry align="right"><parameter>v2</parameter> :</entry><entry>a pointer to a <link linkend="gint">gint</link> key to compare with <parameter>v</parameter>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if the two keys match.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-int-hash">g_int_hash ()</title><programlisting><link linkend="guint">guint</link> g_int_hash (<link linkend="gconstpointer">gconstpointer</link> v);</programlisting><para>Converts a pointer to a <link linkend="gint">gint</link> to a hash value.It can be passed to <link linkend="g-hash-table-new">g_hash_table_new</link>() as the <parameter>hash_func</parameter> parameter, whenusing pointers to integers values as keys in a <link linkend="GHashTable">GHashTable</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>v</parameter> :</entry><entry>a pointer to a <link linkend="gint">gint</link> key.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>a hash value corresponding to the key.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-str-equal">g_str_equal ()</title><programlisting><link linkend="gboolean">gboolean</link> g_str_equal (<link linkend="gconstpointer">gconstpointer</link> v, <link linkend="gconstpointer">gconstpointer</link> v2);</programlisting><para>Compares two strings and returns <literal>TRUE</literal> if they are equal.It can be passed to <link linkend="g-hash-table-new">g_hash_table_new</link>() as the <parameter>key_equal_func</parameter>parameter, when using strings as keys in a <link linkend="GHashTable">GHashTable</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>v</parameter> :</entry><entry>a key.</entry></row><row><entry align="right"><parameter>v2</parameter> :</entry><entry>a key to compare with <parameter>v</parameter>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if the two keys match.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-str-hash">g_str_hash ()</title><programlisting><link linkend="guint">guint</link> g_str_hash (<link linkend="gconstpointer">gconstpointer</link> v);</programlisting><para>Converts a string to a hash value.It can be passed to <link linkend="g-hash-table-new">g_hash_table_new</link>() as the <parameter>hash_func</parameter> parameter, whenusing strings as keys in a <link linkend="GHashTable">GHashTable</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>v</parameter> :</entry><entry>a string key.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>a hash value corresponding to the key.</entry></row></tbody></tgroup></informaltable></refsect2></refsect1></refentry>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -