📄 arrays_pointer.sgml
字号:
<row><entry align="right"><parameter>data</parameter> :</entry><entry>the pointer to remove.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if the pointer is removed. <literal>FALSE</literal> if the pointer is not foundin the array.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-ptr-array-remove-index">g_ptr_array_remove_index ()</title><programlisting><link linkend="gpointer">gpointer</link> g_ptr_array_remove_index (<link linkend="GPtrArray">GPtrArray</link> *array, <link linkend="guint">guint</link> index);</programlisting><para>Removes the pointer at the given index from the pointer array.The following elements are moved down one place.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter> :</entry><entry>a <link linkend="GPtrArray">GPtrArray</link>.</entry></row><row><entry align="right"><parameter>index</parameter> :</entry><entry>the index of the pointer to remove.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the pointer which was removed.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-ptr-array-remove-fast">g_ptr_array_remove_fast ()</title><programlisting><link linkend="gboolean">gboolean</link> g_ptr_array_remove_fast (<link linkend="GPtrArray">GPtrArray</link> *array, <link linkend="gpointer">gpointer</link> data);</programlisting><para>Removes the first occurrence of the given pointer from the pointer array.The last element in the array is used to fill in the space, so this functiondoes not preserve the order of the array. But it is faster than<link linkend="g-ptr-array-remove">g_ptr_array_remove</link>().</para><para>It returns <literal>TRUE</literal> if the pointer was removed, or <literal>FALSE</literal> if the pointerwas not found.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter> :</entry><entry>a <link linkend="GPtrArray">GPtrArray</link>.</entry></row><row><entry align="right"><parameter>data</parameter> :</entry><entry>the pointer to remove.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry><literal>TRUE</literal> if the pointer was found in the array.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-ptr-array-remove-index-fast">g_ptr_array_remove_index_fast ()</title><programlisting><link linkend="gpointer">gpointer</link> g_ptr_array_remove_index_fast (<link linkend="GPtrArray">GPtrArray</link> *array, <link linkend="guint">guint</link> index);</programlisting><para>Removes the pointer at the given index from the pointer array.The last element in the array is used to fill in the space, so this functiondoes not preserve the order of the array. But it is faster than<link linkend="g-ptr-array-remove-index">g_ptr_array_remove_index</link>().</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter> :</entry><entry>a <link linkend="GPtrArray">GPtrArray</link>.</entry></row><row><entry align="right"><parameter>index</parameter> :</entry><entry>the index of the pointer to remove.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the pointer which was removed.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-ptr-array-sort">g_ptr_array_sort ()</title><programlisting>void g_ptr_array_sort (<link linkend="GPtrArray">GPtrArray</link> *array, <link linkend="GCompareFunc">GCompareFunc</link> compare_func);</programlisting><para>Sorts the array, using <parameter>compare_func</parameter> which should be a <function><link linkend="qsort">qsort</link>()</function>-style comparisonfunction (returns -1 for first arg is less than second arg, 0 for equal, 1 iffirst arg is greater than second arg).</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter> :</entry><entry>a <link linkend="GPtrArray">GPtrArray</link>.</entry></row><row><entry align="right"><parameter>compare_func</parameter> :</entry><entry>comparison function.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-ptr-array-sort-with-data">g_ptr_array_sort_with_data ()</title><programlisting>void g_ptr_array_sort_with_data (<link linkend="GPtrArray">GPtrArray</link> *array, <link linkend="GCompareDataFunc">GCompareDataFunc</link> compare_func, <link linkend="gpointer">gpointer</link> user_data);</programlisting><para>Like <link linkend="g-ptr-array-sort">g_ptr_array_sort</link>(), but the comparison function has a user data argument.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter> :</entry><entry>a <link linkend="GPtrArray">GPtrArray</link>.</entry></row><row><entry align="right"><parameter>compare_func</parameter> :</entry><entry>comparison function.</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-ptr-array-set-size">g_ptr_array_set_size ()</title><programlisting>void g_ptr_array_set_size (<link linkend="GPtrArray">GPtrArray</link> *array, <link linkend="gint">gint</link> length);</programlisting><para>Sets the size of the array, expanding it if necessary.New elements are set to <literal>NULL</literal>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter> :</entry><entry>a <link linkend="GPtrArray">GPtrArray</link>.</entry></row><row><entry align="right"><parameter>length</parameter> :</entry><entry>the new length of the pointer array.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-ptr-array-index">g_ptr_array_index()</title><programlisting>#define g_ptr_array_index(array,index)</programlisting><para>Returns the pointer at the given index of the pointer array.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter> :</entry><entry>a <link linkend="GPtrArray">GPtrArray</link>.</entry></row><row><entry align="right"><parameter>index</parameter> :</entry><entry>the index of the pointer to return.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the pointer at the given index.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-ptr-array-free">g_ptr_array_free ()</title><programlisting><link linkend="gpointer">gpointer</link>* g_ptr_array_free (<link linkend="GPtrArray">GPtrArray</link> *array, <link linkend="gboolean">gboolean</link> free_seg);</programlisting><para>Frees all of the memory allocated for the pointer array.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>array</parameter> :</entry><entry>a <link linkend="GPtrArray">GPtrArray</link>.</entry></row><row><entry align="right"><parameter>free_seg</parameter> :</entry><entry>if <literal>TRUE</literal> the actual element data is freed as well.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry></entry></row></tbody></tgroup></informaltable></refsect2></refsect1></refentry>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -