📄 glib-singly-linked-lists.html
字号:
<span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new start of the <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3116961"></a><h3><a name="g-slist-insert"></a>g_slist_insert ()</h3><a class="indexterm" name="id3116971"></a><pre class="programlisting"><a href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_insert (<a href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data, <a href="glib-Basic-Types.html#gint">gint</a> position);</pre><p>Inserts a new element into the list at the given position.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>list</code></em> :</span></td><td>a <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>data</code></em> :</span></td><td>the data for the new element.</td></tr><tr><td><span class="term"><em class="parameter"><code>position</code></em> :</span></td><td>the position to insert the element. If this is negative, or islarger than the number of elements in the list, the new element is added onto the end of the list.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new start of the <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3117090"></a><h3><a name="g-slist-insert-before"></a>g_slist_insert_before ()</h3><a class="indexterm" name="id3117101"></a><pre class="programlisting"><a href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_insert_before (<a href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *slist, <a href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *sibling, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre><p>Inserts a node before <em class="parameter"><code>sibling</code></em> containing <em class="parameter"><code>data</code></em>. Returns the new head of the list.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>slist</code></em> :</span></td><td>a <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>sibling</code></em> :</span></td><td>node to insert <em class="parameter"><code>data</code></em> before.</td></tr><tr><td><span class="term"><em class="parameter"><code>data</code></em> :</span></td><td>data to put in the newly-inserted node.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>new head of the list.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3117228"></a><h3><a name="g-slist-insert-sorted"></a>g_slist_insert_sorted ()</h3><a class="indexterm" name="id3117239"></a><pre class="programlisting"><a href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_insert_sorted (<a href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list, <a href="glib-Basic-Types.html#gpointer">gpointer</a> data, <a href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> func);</pre><p>Inserts a new element into the list, using the given comparison functionto determine its position.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>list</code></em> :</span></td><td>a <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>data</code></em> :</span></td><td>the data for the new element.</td></tr><tr><td><span class="term"><em class="parameter"><code>func</code></em> :</span></td><td>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.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new start of the <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3117359"></a><h3><a name="g-slist-remove"></a>g_slist_remove ()</h3><a class="indexterm" name="id3117369"></a><pre class="programlisting"><a href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_remove (<a href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list, <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);</pre><p>Removes an element from a <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.If two elements contain the same data, only the first is removed.If none of the elements contain the data, the <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> is unchanged.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>list</code></em> :</span></td><td>a <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>data</code></em> :</span></td><td>the data of the element to remove.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new start of the <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3117482"></a><h3><a name="g-slist-remove-link"></a>g_slist_remove_link ()</h3><a class="indexterm" name="id3117494"></a><pre class="programlisting"><a href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_remove_link (<a href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list, <a href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *link_);</pre><p>Removes an element from a <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>, without freeing the element.The removed element's next link is set to <code class="literal">NULL</code>, so that it becomes aself-contained list with one element.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>list</code></em> :</span></td><td>a <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>link_</code></em> :</span></td><td>an element in the <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new start of the <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>, without the element.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3117612"></a><h3><a name="g-slist-delete-link"></a>g_slist_delete_link ()</h3><a class="indexterm" name="id3117623"></a><pre class="programlisting"><a href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_delete_link (<a href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list, <a href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *link_);</pre><p>Deletes a node of <em class="parameter"><code>list</code></em>. Returns the new list head.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>list</code></em> :</span></td><td>a <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>link_</code></em> :</span></td><td>node to delete.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>new head of <em class="parameter"><code>list</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3117721"></a><h3><a name="g-slist-remove-all"></a>g_slist_remove_all ()</h3><a class="indexterm" name="id3117732"></a><pre class="programlisting"><a href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_remove_all (<a href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list, <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);</pre><p>Removes all list nodes with data equal to <em class="parameter"><code>data</code></em>. Returns the newhead of the list. Contrast with <a href="glib-Singly-Linked-Lists.html#g-slist-remove"><code class="function">g_slist_remove()</code></a> which removes only the first node matching the given data.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>list</code></em> :</span></td><td>a <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>data</code></em> :</span></td><td>data to remove.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>new head of <em class="parameter"><code>list</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3117842"></a><h3><a name="g-slist-free"></a>g_slist_free ()</h3><a class="indexterm" name="id3117853"></a><pre class="programlisting">void g_slist_free (<a href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre><p>Frees all of the memory used by a <a href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.The freed elements are added to the <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a> free list.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -