📄 glib-doubly-linked-lists.html
字号:
<a name="g-list-copy"></a>g_list_copy ()</h3><a class="indexterm" name="id3241180"></a><pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a>* g_list_copy (<a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>Copies a <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.</p><p></p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Note that this is a "shallow" copy. If the list elements consist of pointers to data, the pointers are copied but the actual data is not.</p></div><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td><td> a <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></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="id3241270"></a><h3><a name="g-list-reverse"></a>g_list_reverse ()</h3><a class="indexterm" name="id3241282"></a><pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a>* g_list_reverse (<a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>Reverses a <a class="link" 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><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td><td> a <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the start of the reversed <a class="link" 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="id3241367"></a><h3><a name="g-list-sort"></a>g_list_sort ()</h3><a class="indexterm" name="id3241380"></a><pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a>* g_list_sort (<a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list, <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> compare_func);</pre><p>Sorts a <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> using the given comparison function.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td><td> a <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></p></td><td> the comparison function used to sort the <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>. This function is passed the data from 2 elements of the <a class="link" 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 positive value if the first element comes after the second.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the start of the sorted <a class="link" 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="id3241506"></a><h3><a name="GCompareFunc"></a>GCompareFunc ()</h3><a class="indexterm" name="id3241519"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint">gint</a> (*GCompareFunc) (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> a, <a class="link" 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><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td><td>a value.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>b</code></em> :</span></p></td><td>a value to compare with.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></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="id3241636"></a><h3><a name="g-list-insert-sorted-with-data"></a>g_list_insert_sorted_with_data ()</h3><a class="indexterm" name="id3241652"></a><pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a>* g_list_insert_sorted_with_data (<a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list, <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data, <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> func, <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Inserts a new element into the list, using the given comparison function to determine its position.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td><td> a pointer to a <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td><td> the data for the new element</td></tr><tr><td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td><td> the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td><td> user data to pass to comparison function.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the new start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a></td></tr></tbody></table></div><p class="since">Since 2.10</p></div><hr><div class="refsect2" lang="en"><a name="id3241811"></a><h3><a name="g-list-sort-with-data"></a>g_list_sort_with_data ()</h3><a class="indexterm" name="id3241824"></a><pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a>* g_list_sort_with_data (<a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list, <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> compare_func, <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Like <a class="link" 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><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td><td> a <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></p></td><td> comparison function</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td><td> user data to pass to comparison function</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></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"><a name="id3241954"></a><h3><a name="GCompareDataFunc"></a>GCompareDataFunc ()</h3><a class="indexterm" name="id3241967"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint">gint</a> (*GCompareDataFunc) (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> a, <a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> b, <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</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><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td><td>a value.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>b</code></em> :</span></p></td><td>a value to compare with.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -