📄 glib-miscellaneous-utility-functions.html
字号:
<p>Find the position of the first bit set in <em class="parameter"><code>mask</code></em>, searching from (but notincluding) <em class="parameter"><code>nth_bit</code></em> upwards. Bits are numbered from 0 (least significant)to sizeof(<a href="glib-Basic-Types.html#gulong"><span class="type">gulong</span></a>) * 8 - 1 (31 or 63, usually). To start searching from the0th bit, set <em class="parameter"><code>nth_bit</code></em> to -1.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>mask</code></em> :</span></td><td>a <a href="glib-Basic-Types.html#gulong"><span class="type">gulong</span></a> containing flags.</td></tr><tr><td><span class="term"><em class="parameter"><code>nth_bit</code></em> :</span></td><td>the index of the bit to start the search from.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the index of the first bit set which is higher than <em class="parameter"><code>nth_bit</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3023254"></a><h3><a name="g-bit-nth-msf"></a>g_bit_nth_msf ()</h3><a class="indexterm" name="id3023265"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a> g_bit_nth_msf (<a href="glib-Basic-Types.html#gulong">gulong</a> mask, <a href="glib-Basic-Types.html#gint">gint</a> nth_bit);</pre><p>Find the position of the first bit set in <em class="parameter"><code>mask</code></em>, searching from (but notincluding) <em class="parameter"><code>nth_bit</code></em> downwards. Bits are numbered from 0 (least significant)to sizeof(<a href="glib-Basic-Types.html#gulong"><span class="type">gulong</span></a>) * 8 - 1 (31 or 63, usually). To start searching from thelast bit, set <em class="parameter"><code>nth_bit</code></em> to -1 or GLIB_SIZEOF_LONG * 8.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>mask</code></em> :</span></td><td>a <a href="glib-Basic-Types.html#gulong"><span class="type">gulong</span></a> containing flags.</td></tr><tr><td><span class="term"><em class="parameter"><code>nth_bit</code></em> :</span></td><td>the index of the bit to start the search from.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the index of the first bit set which is lower than <em class="parameter"><code>nth_bit</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3023388"></a><h3><a name="g-bit-storage"></a>g_bit_storage ()</h3><a class="indexterm" name="id3023398"></a><pre class="programlisting"><a href="glib-Basic-Types.html#guint">guint</a> g_bit_storage (<a href="glib-Basic-Types.html#gulong">gulong</a> number);</pre><p>Gets the number of bits used to hold <em class="parameter"><code>number</code></em>,e.g. if <em class="parameter"><code>number</code></em> is 4, 3 bits are needed.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>number</code></em> :</span></td><td>a guint.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the number of bits used to hold <em class="parameter"><code>number</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3023474"></a><h3><a name="g-spaced-primes-closest"></a>g_spaced_primes_closest ()</h3><a class="indexterm" name="id3023485"></a><pre class="programlisting"><a href="glib-Basic-Types.html#guint">guint</a> g_spaced_primes_closest (<a href="glib-Basic-Types.html#guint">guint</a> num);</pre><p>Gets the smallest prime number from a built-in array of primes whichis larger than <em class="parameter"><code>num</code></em>. This is used within GLib to calculate the optimumsize of a <a href="glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a>.</p><p>The built-in array of primes ranges from 11 to 13845163 such thateach prime is approximately 1.5-2 times the previous prime.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>num</code></em> :</span></td><td>a <a href="glib-Basic-Types.html#guint"><span class="type">guint</span></a>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the smallest prime number from a built-in array of primes which islarger than <em class="parameter"><code>num</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3023579"></a><h3><a name="g-atexit"></a>g_atexit ()</h3><a class="indexterm" name="id3023589"></a><pre class="programlisting">void g_atexit (<a href="glib-Miscellaneous-Utility-Functions.html#GVoidFunc">GVoidFunc</a> func);</pre><p>Specifies a function to be called at normal program termination.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>func</code></em> :</span></td><td>the function to call on normal program termination.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3023637"></a><h3><a name="g-parse-debug-string"></a>g_parse_debug_string ()</h3><a class="indexterm" name="id3023648"></a><pre class="programlisting"><a href="glib-Basic-Types.html#guint">guint</a> g_parse_debug_string (const <a href="glib-Basic-Types.html#gchar">gchar</a> *string, const <a href="glib-Miscellaneous-Utility-Functions.html#GDebugKey">GDebugKey</a> *keys, <a href="glib-Basic-Types.html#guint">guint</a> nkeys);</pre><p>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.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>string</code></em> :</span></td><td>a list of debug options separated by ':' or "all" to set all flags.</td></tr><tr><td><span class="term"><em class="parameter"><code>keys</code></em> :</span></td><td>pointer to an array of <a href="glib-Miscellaneous-Utility-Functions.html#GDebugKey"><span class="type">GDebugKey</span></a> which associate strings withbit flags.</td></tr><tr><td><span class="term"><em class="parameter"><code>nkeys</code></em> :</span></td><td>the number of <a href="glib-Miscellaneous-Utility-Functions.html#GDebugKey"><span class="type">GDebugKey</span></a> in the array.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the combined set of bit flags.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3023770"></a><h3><a name="GDebugKey"></a>GDebugKey</h3><a class="indexterm" name="id3023780"></a><pre class="programlisting">typedef struct { gchar *key; guint value;} GDebugKey;</pre><p>Associates a string with a bit flag.Used in <a href="glib-Miscellaneous-Utility-Functions.html#g-parse-debug-string"><code class="function">g_parse_debug_string()</code></a>.</p></div><hr><div class="refsect2" lang="en"><a name="id3023808"></a><h3><a name="GVoidFunc"></a>GVoidFunc ()</h3><a class="indexterm" name="id3023818"></a><pre class="programlisting">void (*GVoidFunc) (void);</pre><p>Declares a type of function which takes no arguments and has no return value.It is used to specify the type function passed to <a href="glib-Miscellaneous-Utility-Functions.html#g-atexit"><code class="function">g_atexit()</code></a>.</p></div><hr><div class="refsect2" lang="en"><a name="id3023852"></a><h3><a name="GFreeFunc"></a>GFreeFunc ()</h3><a class="indexterm" name="id3023862"></a><pre class="programlisting">void (*GFreeFunc) (<a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre><p>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+.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>data</code></em> :</span></td><td>a data pointer.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3023911"></a><h3><a name="g-qsort-with-data"></a>g_qsort_with_data ()</h3><a class="indexterm" name="id3023922"></a><pre class="programlisting">void g_qsort_with_data (<a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> pbase, <a href="glib-Basic-Types.html#gint">gint</a> total_elems, <a href="glib-Basic-Types.html#gsize">gsize</a> size, <a href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> compare_func, <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>This is just like the standard C <code class="function">qsort()</code> function, butthe comparison routine accepts a user data argument.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>pbase</code></em> :</span></td><td> start of array to sort</td></tr><tr><td><span class="term"><em class="parameter"><code>total_elems</code></em> :</span></td><td> elements in the array</td></tr><tr><td><span class="term"><em class="parameter"><code>size</code></em> :</span></td><td> size of each element</td></tr><tr><td><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></td><td> function to compare elements</td></tr><tr><td><span class="term"><em class="parameter"><code>user_data</code></em> :</span></td><td> data to pass to <em class="parameter"><code>compare_func</code></em></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3024077"></a><h3><a name="g-nullify-pointer"></a>g_nullify_pointer ()</h3><a class="indexterm" name="id3024088"></a><pre class="programlisting">void g_nullify_pointer (<a href="glib-Basic-Types.html#gpointer">gpointer</a> *nullify_location);</pre><p>Set the pointer at the specified location to <code class="literal">NULL</code>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>nullify_location</code></em> :</span></td><td> the memory address of the pointer.</td></tr></tbody></table></div></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="glib-Hook-Functions.html"><b><< Hook Functions</b></a></td><td align="right"><a accesskey="n" href="glib-Lexical-Scanner.html"><b>Lexical Scanner >></b></a></td></tr></table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -