📄 misc_utils.sgml
字号:
<link linkend="gint">gint</link> nth_bit);</programlisting><para>Find the position of the first bit set in <parameter>mask</parameter>, searching from (but notincluding) <parameter>nth_bit</parameter> upwards. Bits are numbered from 0 (least significant)to 31. To start searching from the 0th bit, set <parameter>nth_bit</parameter> to -1.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>mask</parameter> :</entry><entry>a <link linkend="guint32">guint32</link> containing up to 32 bit flags.</entry></row><row><entry align="right"><parameter>nth_bit</parameter> :</entry><entry>the index of the bit to start the search from.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the index of the first bit set which is higher than <parameter>nth_bit</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-bit-nth-msf">g_bit_nth_msf ()</title><programlisting><link linkend="gint">gint</link> g_bit_nth_msf (<link linkend="gulong">gulong</link> mask, <link linkend="gint">gint</link> nth_bit);</programlisting><para>Find the position of the first bit set in <parameter>mask</parameter>, searching from (but notincluding) <parameter>nth_bit</parameter> downwards. Bits are numbered from 0 (least significant)to 31. To start searching from the 31st bit, set <parameter>nth_bit</parameter> to 32 or -1.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>mask</parameter> :</entry><entry>a <link linkend="guint32">guint32</link> containing up to 32 bit flags.</entry></row><row><entry align="right"><parameter>nth_bit</parameter> :</entry><entry>the index of the bit to start the search from.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the index of the first bit set which is lower than <parameter>nth_bit</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-bit-storage">g_bit_storage ()</title><programlisting><link linkend="guint">guint</link> g_bit_storage (<link linkend="gulong">gulong</link> number);</programlisting><para>Gets the number of bits used to hold <parameter>number</parameter>,e.g. if <parameter>number</parameter> is 4, 3 bits are needed.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>number</parameter> :</entry><entry>a guint.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the number of bits used to hold <parameter>number</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-spaced-primes-closest">g_spaced_primes_closest ()</title><programlisting><link linkend="guint">guint</link> g_spaced_primes_closest (<link linkend="guint">guint</link> num);</programlisting><para>Gets the smallest prime number from a built-in array of primes whichis larger than <parameter>num</parameter>. This is used within GLib to calculate the optimumsize of a <link linkend="GHashTable">GHashTable</link>.</para><para>The built-in array of primes ranges from 11 to 13845163 such thateach prime is approximately 1.5-2 times the previous prime.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>num</parameter> :</entry><entry>a <link linkend="guint">guint</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the smallest prime number from a built-in array of primes which islarger than <parameter>num</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-atexit">g_atexit ()</title><programlisting>void g_atexit (<link linkend="GVoidFunc">GVoidFunc</link> func);</programlisting><para>Specifies a function to be called at normal program termination.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>func</parameter> :</entry><entry>the function to call on normal program termination.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-parse-debug-string">g_parse_debug_string ()</title><programlisting><link linkend="guint">guint</link> g_parse_debug_string (const <link linkend="gchar">gchar</link> *string, const <link linkend="GDebugKey">GDebugKey</link> *keys, <link linkend="guint">guint</link> nkeys);</programlisting><para>Parses a string containing debugging options separated by ':' into a guintcontaining bit flags.This is used within GDK and GTK+ to parse the debug options passed on thecommand line or through environment variables.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>string</parameter> :</entry><entry>a list of debug options separated by ':' or "all" to set all flags.</entry></row><row><entry align="right"><parameter>keys</parameter> :</entry><entry>pointer to an array of <link linkend="GDebugKey">GDebugKey</link> which associate strings withbit flags.</entry></row><row><entry align="right"><parameter>nkeys</parameter> :</entry><entry>the number of <link linkend="GDebugKey">GDebugKey</link> in the array.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the combined set of bit flags.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GDebugKey">struct GDebugKey</title><programlisting>struct GDebugKey{ gchar *key; guint value;};</programlisting><para>Associates a string with a bit flag.Used in <link linkend="g-parse-debug-string">g_parse_debug_string</link>().</para></refsect2><refsect2><title><anchor id="GVoidFunc">GVoidFunc ()</title><programlisting>void (*GVoidFunc) (void);</programlisting><para>Declares a type of function which takes no arguments and has no return value.It is used to specify the type function passed to <link linkend="g-atexit">g_atexit</link>().</para></refsect2><refsect2><title><anchor id="GFreeFunc">GFreeFunc ()</title><programlisting>void (*GFreeFunc) (<link linkend="gpointer">gpointer</link> data);</programlisting><para>Declares a type of function which takes an arbitrary data pointer argumentand has no return value. It is not currently used in GLib or GTK+.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>data</parameter> :</entry><entry>a data pointer.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-qsort-with-data">g_qsort_with_data ()</title><programlisting>void g_qsort_with_data (<link linkend="gconstpointer">gconstpointer</link> pbase, <link linkend="gint">gint</link> total_elems, <link linkend="size-t">size_t</link> size, <link linkend="GCompareDataFunc">GCompareDataFunc</link> compare_func, <link linkend="gpointer">gpointer</link> user_data);</programlisting><para>This is just like the standard C <link linkend="qsort">qsort</link>() function, butthe comparison routine accepts a user data argument.</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>pbase</parameter> :</entry><entry> start of array to sort</entry></row><row><entry align="right"><parameter>total_elems</parameter> :</entry><entry> elements in the array</entry></row><row><entry align="right"><parameter>size</parameter> :</entry><entry> size of each element</entry></row><row><entry align="right"><parameter>compare_func</parameter> :</entry><entry> function to compare elements</entry></row><row><entry align="right"><parameter>user_data</parameter> :</entry><entry> data to pass to <parameter>compare_func</parameter></entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-nullify-pointer">g_nullify_pointer ()</title><programlisting>void g_nullify_pointer (<link linkend="gpointer">gpointer</link> *nullify_location);</programlisting><para>Set the pointer at the specified location to <literal>NULL</literal>.</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>nullify_location</parameter> :</entry><entry> the memory address of the pointer.</entry></row></tbody></tgroup></informaltable></refsect2></refsect1></refentry>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -