📄 glib-doubly-linked-lists.html
字号:
</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3107382"></a><h3><a name="g-list-free"></a>g_list_free ()</h3><a class="indexterm" name="id3107392"></a><pre class="programlisting">void g_list_free (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>Frees all of the memory used by a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</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="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>If list elements contain dynamically-allocated memory, they should be freedfirst.</p></div><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-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3107471"></a><h3><a name="g-list-alloc"></a>g_list_alloc ()</h3><a class="indexterm" name="id3107481"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>* g_list_alloc (void);</pre><p>Allocates space for one <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> element.It is called by <a href="glib-Doubly-Linked-Lists.html#g-list-append"><code class="function">g_list_append()</code></a>, <a href="glib-Doubly-Linked-Lists.html#g-list-prepend"><code class="function">g_list_prepend()</code></a>, <a href="glib-Doubly-Linked-Lists.html#g-list-insert"><code class="function">g_list_insert()</code></a> and<a href="glib-Doubly-Linked-Lists.html#g-list-insert-sorted"><code class="function">g_list_insert_sorted()</code></a> and so is rarely used on its own.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>a pointer to the newly-allocated <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> element.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3107577"></a><h3><a name="g-list-free-1"></a>g_list_free_1 ()</h3><a class="indexterm" name="id3107588"></a><pre class="programlisting">void g_list_free_1 (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>Frees one <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> element.It is usually used after <a href="glib-Doubly-Linked-Lists.html#g-list-remove-link"><code class="function">g_list_remove_link()</code></a>.</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-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> element.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3107661"></a><h3><a name="g-list-length"></a>g_list_length ()</h3><a class="indexterm" name="id3107671"></a><pre class="programlisting"><a href="glib-Basic-Types.html#guint">guint</a> g_list_length (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>Gets the number of elements in a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.</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-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the number of elements in the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3107752"></a><h3><a name="g-list-copy"></a>g_list_copy ()</h3><a class="indexterm" name="id3107763"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>* g_list_copy (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>Copies a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.</p><p>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.</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-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>a copy of <em class="parameter"><code>list</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3107846"></a><h3><a name="g-list-reverse"></a>g_list_reverse ()</h3><a class="indexterm" name="id3107856"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>* g_list_reverse (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>Reverses a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.It simply switches the next and prev pointers of each 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-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the start of the reversed <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3107938"></a><h3><a name="g-list-sort"></a>g_list_sort ()</h3><a class="indexterm" name="id3107948"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>* g_list_sort (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list, <a href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> compare_func);</pre><p>Sorts a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> using the given comparison function.</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-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></td><td>the comparison function used to sort the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>. This functionis passed 2 elements of the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> 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.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the start of the sorted <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3108071"></a><h3><a name="GCompareFunc"></a>GCompareFunc ()</h3><a class="indexterm" name="id3108081"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a> (*GCompareFunc) (<a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> a, <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> b);</pre><p>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.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>a</code></em> :</span></td><td>a value.</td></tr><tr><td><span class="term"><em class="parameter"><code>b</code></em> :</span></td><td>a value to compare with.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>negative value if <em class="parameter"><code>a</code></em> < <em class="parameter"><code>b</code></em>; zero if <em class="parameter"><code>a</code></em> = <em class="parameter"><code>b</code></em>; positive valueif <em class="parameter"><code>a</code></em> > <em class="parameter"><code>b</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3108198"></a><h3><a name="g-list-sort-with-data"></a>g_list_sort_with_data ()</h3><a class="indexterm" name="id3108209"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>* g_list_sort_with_data (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list, <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>Like <a href="glib-Doubly-Linked-Lists.html#g-list-sort"><code class="function">g_list_sort()</code></a>, but the comparison function accepts a user data argument.</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-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></td><td>comparison function.</td></tr><tr><td><span class="term"><em class="parameter"><code>user_data</code></em> :</span></td><td>user data to pass to comparison function.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new head of <em class="parameter"><code>list</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -