⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linked_lists_single.sgml

📁 GLib是GTK+和GNOME工程的基础底层核心程序库
💻 SGML
📖 第 1 页 / 共 3 页
字号:
</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-slist-insert-before">g_slist_insert_before ()</title><programlisting><link linkend="GSList">GSList</link>*     g_slist_insert_before           (<link linkend="GSList">GSList</link> *slist,                                             <link linkend="GSList">GSList</link> *sibling,                                             <link linkend="gpointer">gpointer</link> data);</programlisting><para>Inserts a node before <parameter>sibling</parameter> containing <parameter>data</parameter>. Returns the new head of the list.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>slist</parameter>&nbsp;:</entry><entry>a <link linkend="GSList">GSList</link>.</entry></row><row><entry align="right"><parameter>sibling</parameter>&nbsp;:</entry><entry>node to insert <parameter>data</parameter> before.</entry></row><row><entry align="right"><parameter>data</parameter>&nbsp;:</entry><entry>data to put in the newly-inserted node.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>new head of the list.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-slist-insert-sorted">g_slist_insert_sorted ()</title><programlisting><link linkend="GSList">GSList</link>*     g_slist_insert_sorted           (<link linkend="GSList">GSList</link> *list,                                             <link linkend="gpointer">gpointer</link> data,                                             <link linkend="GCompareFunc">GCompareFunc</link> func);</programlisting><para>Inserts a new element into the list, using the given comparison functionto determine its position.</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>&nbsp;:</entry><entry>a <link linkend="GSList">GSList</link>.</entry></row><row><entry align="right"><parameter>data</parameter>&nbsp;:</entry><entry>the data for the new element.</entry></row><row><entry align="right"><parameter>func</parameter>&nbsp;:</entry><entry>the function to compare elements in the list. It should return anumber > 0 if the first parameter comes after the second parameter inthe sort order.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the new start of the <link linkend="GSList">GSList</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-slist-remove">g_slist_remove ()</title><programlisting><link linkend="GSList">GSList</link>*     g_slist_remove                  (<link linkend="GSList">GSList</link> *list,                                             <link linkend="gconstpointer">gconstpointer</link> data);</programlisting><para>Removes an element from a <link linkend="GSList">GSList</link>.If two elements contain the same data, only the first is removed.If none of the elements contain the data, the <link linkend="GSList">GSList</link> is unchanged.</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>&nbsp;:</entry><entry>a <link linkend="GSList">GSList</link>.</entry></row><row><entry align="right"><parameter>data</parameter>&nbsp;:</entry><entry>the data of the element to remove.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the new start of the <link linkend="GSList">GSList</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-slist-remove-link">g_slist_remove_link ()</title><programlisting><link linkend="GSList">GSList</link>*     g_slist_remove_link             (<link linkend="GSList">GSList</link> *list,                                             <link linkend="GSList">GSList</link> *link);</programlisting><para>Removes an element from a <link linkend="GSList">GSList</link>, without freeing the element.The removed element's next link is set to <literal>NULL</literal>, so that it becomes aself-contained list with one 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>&nbsp;:</entry><entry>a <link linkend="GSList">GSList</link>.</entry></row><row><entry align="right"><parameter>link</parameter>&nbsp;:</entry><entry>an element in the <link linkend="GSList">GSList</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the new start of the <link linkend="GSList">GSList</link>, without the element.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-slist-delete-link">g_slist_delete_link ()</title><programlisting><link linkend="GSList">GSList</link>*     g_slist_delete_link             (<link linkend="GSList">GSList</link> *list,                                             <link linkend="GSList">GSList</link> *link);</programlisting><para>Deletes a node of <parameter>list</parameter>. Returns the new list head.</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>&nbsp;:</entry><entry>a <link linkend="GSList">GSList</link>.</entry></row><row><entry align="right"><parameter>link</parameter>&nbsp;:</entry><entry>node to delete.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>new head of <parameter>list</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-slist-remove-all">g_slist_remove_all ()</title><programlisting><link linkend="GSList">GSList</link>*     g_slist_remove_all              (<link linkend="GSList">GSList</link> *list,                                             <link linkend="gconstpointer">gconstpointer</link> data);</programlisting><para>Removes all list nodes with data equal to <parameter>data</parameter>. Returns the newhead of the list. Contrast with <link linkend="g-slist-remove">g_slist_remove</link>() which removes only the first node matching the given data.</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>&nbsp;:</entry><entry>a <link linkend="GSList">GSList</link>.</entry></row><row><entry align="right"><parameter>data</parameter>&nbsp;:</entry><entry>data to remove.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>new head of <parameter>list</parameter>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-slist-free">g_slist_free ()</title><programlisting>void        g_slist_free                    (<link linkend="GSList">GSList</link> *list);</programlisting><para>Frees all of the memory used by a <link linkend="GSList">GSList</link>.The freed elements are added to the <link linkend="GListAllocator">GListAllocator</link> free list.</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>&nbsp;:</entry><entry>a <link linkend="GSList">GSList</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-slist-free-1">g_slist_free_1 ()</title><programlisting>void        g_slist_free_1                  (<link linkend="GSList">GSList</link> *list);</programlisting><para>Frees one <link linkend="GSList">GSList</link> element.It is usually used after <link linkend="g-slist-remove-link">g_slist_remove_link</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>&nbsp;:</entry><entry>a <link linkend="GSList">GSList</link> element.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-slist-length">g_slist_length ()</title><programlisting><link linkend="guint">guint</link>       g_slist_length                  (<link linkend="GSList">GSList</link> *list);</programlisting><para>Gets the number of elements in a <link linkend="GSList">GSList</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>&nbsp;:</entry><entry>a <link linkend="GSList">GSList</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the number of elements in the <link linkend="GSList">GSList</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-slist-copy">g_slist_copy ()</title><programlisting><link linkend="GSList">GSList</link>*     g_slist_copy                    (<link linkend="GSList">GSList</link> *list);</programlisting><para>Copies a <link linkend="GSList">GSList</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>&nbsp;:</entry><entry>a <link linkend="GSList">GSList</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-slist-reverse">g_slist_reverse ()</title><programlisting><link linkend="GSList">GSList</link>*     g_slist_reverse                 (<link linkend="GSList">GSList</link> *list);</programlisting><para>Reverses a <link linkend="GSList">GSList</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>&nbsp;:</entry><entry>a <link linkend="GSList">GSList</link>.</entry></row><row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the start of the reversed <link linkend="GSList">GSList</link>.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="g-slist-sort">g_slist_sort ()</title><programlisting><link linkend="GSList">GSList</link>*     g_slist_sort                    (<link linkend="GSList">GSList</link> *list,                                             <link linkend="GCompareFunc">GCompareFunc</link> compare_func);</programlisting><para>Sorts a <link linkend="GSList">GSList</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>&nbsp;:</entry><entry>a <link linkend="GSList">GSList</link>.</entry></row><row><entry align="right"><parameter>compare_func</parameter>&nbsp;:</entry><entry><function><link linkend="qsort">qsort</link>()</function>-style comparison function.</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="g-slist-sort-with-data">g_slist_sort_with_data ()</title><programlisting><link linkend="GSList">GSList</link>*     g_slist_sort_with_data          (<link linkend="GSList">GSList</link> *list,                                             <link linkend="GCompareDataFunc">GCompareDataFunc</link> compare_func,                                             <link linkend="gpointer">gpointer</link> user_data);</programlisting><para>Like <link linkend="g-slist-sort">g_slist_sort</link>(), but the sort function accepts a user data argument.</para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -