📄 linked_lists_double.sgml
字号:
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the number of elements in the <link linkend="GList">GList</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-list-copy">g_list_copy ()</title><programlisting><link linkend="GList">GList</link>* g_list_copy (<link linkend="GList">GList</link> *list);</programlisting><para>Copies a <link linkend="GList">GList</link>.</para><para>Note that this is a "shallow" copy. If the list elements consist of pointersto data, the pointers are copied but the actual data isn't.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>list</parameter> :</entry><entry>a <link linkend="GList">GList</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>a copy of <parameter>list</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-list-reverse">g_list_reverse ()</title><programlisting><link linkend="GList">GList</link>* g_list_reverse (<link linkend="GList">GList</link> *list);</programlisting><para>Reverses a <link linkend="GList">GList</link>.It simply switches the next and prev pointers of each element.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>list</parameter> :</entry><entry>a <link linkend="GList">GList</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the start of the reversed <link linkend="GList">GList</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-list-sort">g_list_sort ()</title><programlisting><link linkend="GList">GList</link>* g_list_sort (<link linkend="GList">GList</link> *list, <link linkend="GCompareFunc">GCompareFunc</link> compare_func);</programlisting><para>Sorts a <link linkend="GList">GList</link> using the given comparison function.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>list</parameter> :</entry><entry>a <link linkend="GList">GList</link>.</entry></row><row><entry align="right"><parameter>compare_func</parameter> :</entry><entry>the comparison function used to sort the <link linkend="GList">GList</link>. This functionis passed 2 elements of the <link linkend="GList">GList</link> and should return 0 if they are equal,a negative value if the first element comes before the second, or a positivevalue if the first element comes after the second.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the start of the sorted <link linkend="GList">GList</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GCompareFunc">GCompareFunc ()</title><programlisting><link linkend="gint">gint</link> (*GCompareFunc) (<link linkend="gconstpointer">gconstpointer</link> a, <link linkend="gconstpointer">gconstpointer</link> b);</programlisting><para>Specifies the type of a comparison function used to compare twovalues. The function should return a negative integer if the firstvalue comes before the second, 0 if they are equal, or a positiveinteger if the first value comes after the second.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>a</parameter> :</entry><entry>a value.</entry></row><row><entry align="right"><parameter>b</parameter> :</entry><entry>a value to compare with.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>negative value if <parameter>a</parameter> < <parameter>b</parameter>; zero if <parameter>a</parameter> = <parameter>b</parameter>; positive valueif <parameter>a</parameter> > <parameter>b</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-list-sort-with-data">g_list_sort_with_data ()</title><programlisting><link linkend="GList">GList</link>* g_list_sort_with_data (<link linkend="GList">GList</link> *list, <link linkend="GCompareDataFunc">GCompareDataFunc</link> compare_func, <link linkend="gpointer">gpointer</link> user_data);</programlisting><para>Like <link linkend="g-list-sort">g_list_sort</link>(), but the comparison function accepts 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>list</parameter> :</entry><entry>a <link linkend="GList">GList</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>user data to pass to comparison function.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the new head of <parameter>list</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GCompareDataFunc">GCompareDataFunc ()</title><programlisting><link linkend="gint">gint</link> (*GCompareDataFunc) (<link linkend="gconstpointer">gconstpointer</link> a, <link linkend="gconstpointer">gconstpointer</link> b, <link linkend="gpointer">gpointer</link> user_data);</programlisting><para>Specifies the type of a comparison function used to compare twovalues. The function should return a negative integer if the firstvalue comes before the second, 0 if they are equal, or a positiveinteger if the first value comes after the second.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>a</parameter> :</entry><entry>a value.</entry></row><row><entry align="right"><parameter>b</parameter> :</entry><entry>a value to compare with.</entry></row><row><entry align="right"><parameter>user_data</parameter> :</entry><entry>user data to pass to comparison function.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>negative value if <parameter>a</parameter> < <parameter>b</parameter>; zero if <parameter>a</parameter> = <parameter>b</parameter>; positive valueif <parameter>a</parameter> > <parameter>b</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-list-concat">g_list_concat ()</title><programlisting><link linkend="GList">GList</link>* g_list_concat (<link linkend="GList">GList</link> *list1, <link linkend="GList">GList</link> *list2);</programlisting><para>Adds the second <link linkend="GList">GList</link> onto the end of the first <link linkend="GList">GList</link>.Note that the elements of the second <link linkend="GList">GList</link> are not copied.They are used directly.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>list1</parameter> :</entry><entry>a <link linkend="GList">GList</link>.</entry></row><row><entry align="right"><parameter>list2</parameter> :</entry><entry>the <link linkend="GList">GList</link> to add to the end of the first <link linkend="GList">GList</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the start of the new <link linkend="GList">GList</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-list-foreach">g_list_foreach ()</title><programlisting>void g_list_foreach (<link linkend="GList">GList</link> *list, <link linkend="GFunc">GFunc</link> func, <link linkend="gpointer">gpointer</link> user_data);</programlisting><para>Calls a function for each element of a <link linkend="GList">GList</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>list</parameter> :</entry><entry>a <link linkend="GList">GList</link>.</entry></row><row><entry align="right"><parameter>func</parameter> :</entry><entry>the function to call with each element's data.</entry></row><row><entry align="right"><parameter>user_data</parameter> :</entry><entry>user data to pass to the function.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GFunc">GFunc ()</title><programlisting>void (*GFunc) (<link linkend="gpointer">gpointer</link> data, <link linkend="gpointer">gpointer</link> user_data);</programlisting><para>Specifies the type of functions passed to <link linkend="g-list-foreach">g_list_foreach</link>() and<link linkend="g-slist-foreach">g_slist_foreach</link>().</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>the element's data.</entry></row><row><entry align="right"><parameter>user_data</parameter> :</entry><entry>user data passed to <link linkend="g-list-foreach">g_list_foreach</link>() or <link linkend="g-slist-foreach">g_slist_foreach</link>().</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-list-first">g_list_first ()</title><programlisting><link linkend="GList">GList</link>* g_list_first (<link linkend="GList">GList</link> *list);</programlisting><para>Gets the first element in a <link linkend="GList">GList</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>list</parameter> :</entry><entry>a <link linkend="GList">GList</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the first element in a <link linkend="GList">GList</link>, or <literal>NULL</literal> if the <link linkend="GList">GList</link> has no elements.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-list-last">g_list_last ()</title><programlisting><link linkend="GList">GList</link>* g_list_last (<link linkend="GList">GList</link> *list);</programlisting><para>Gets the last element in a <link linkend="GList">GList</link>.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -