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

📄 glib-doubly-linked-lists.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<h3 class="title">Note</h3><p>The return value is the new start of the list, which may have changed, so make sure you store the new value.</p></div><p></p><p></p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Note that <a class="link" href="glib-Doubly-Linked-Lists.html#g-list-append"><code class="function">g_list_append()</code></a> has to traverse the entire list to find the end, which is inefficient when adding multiple elements. A common idiom to avoid the inefficiency is to prepend the elements and reverse the list when all elements have been added.</p></div><p></p><p></p><div class="informalexample"><pre class="programlisting">/* Notice that these are initialized to the empty list. */GList *list = NULL, *number_list = NULL;/* This is a list of strings. */list = g_list_append (list, "first");list = g_list_append (list, "second");/* This is a list of integers. */number_list = g_list_append (number_list, GINT_TO_POINTER (27));number_list = g_list_append (number_list, GINT_TO_POINTER (14));</pre></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>&#160;:</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>&#160;:</span></p></td><td> the data for the new element</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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></div><hr><div class="refsect2" lang="en"><a name="id3239659"></a><h3><a name="g-list-prepend"></a>g_list_prepend ()</h3><a class="indexterm" name="id3239671"></a><pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a>*              g_list_prepend                      (<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);</pre><p>Adds a new element on to the start of the list.</p><p></p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>The return value is the new start of the list, which may have changed, so make sure you store the new value.</p></div><p></p><p></p><div class="informalexample"><pre class="programlisting"> /* Notice that it is initialized to the empty list. */GList *list = NULL;list = g_list_prepend (list, "last");list = g_list_prepend (list, "first");</pre></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>&#160;:</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>&#160;:</span></p></td><td> the data for the new element</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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></div><hr><div class="refsect2" lang="en"><a name="id3239791"></a><h3><a name="g-list-insert"></a>g_list_insert ()</h3><a class="indexterm" name="id3239804"></a><pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a>*              g_list_insert                       (<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-Basic-Types.html#gint">gint</a> position);</pre><p>Inserts a new element into the list at the given 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>&#160;:</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>&#160;:</span></p></td><td> the data for the new element</td></tr><tr><td><p><span class="term"><em class="parameter"><code>position</code></em>&#160;:</span></p></td><td> the position to insert the element. If this is     negative, or is larger than the number of elements in the     list, the new element is added on to the end of the list.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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></div><hr><div class="refsect2" lang="en"><a name="id3239927"></a><h3><a name="g-list-insert-before"></a>g_list_insert_before ()</h3><a class="indexterm" name="id3239940"></a><pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a>*              g_list_insert_before                (<a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a> *sibling,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre><p>Inserts a new element into the list before the given 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>&#160;:</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>sibling</code></em>&#160;:</span></p></td><td> the list element before which the new element     is inserted or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to insert at the end of the list</td></tr><tr><td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td><td> the data for the new element</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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></div><hr><div class="refsect2" lang="en"><a name="id3240072"></a><h3><a name="g-list-insert-sorted"></a>g_list_insert_sorted ()</h3><a class="indexterm" name="id3240085"></a><pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a>*              g_list_insert_sorted                (<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#GCompareFunc">GCompareFunc</a> func);</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>&#160;:</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>&#160;:</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>&#160;:</span></p></td><td> the function to compare elements in the list. It should     return a number &gt; 0 if the first parameter comes after the     second parameter in the sort order.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</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></div><hr><div class="refsect2" lang="en"><a name="id3240215"></a><h3><a name="g-list-remove"></a>g_list_remove ()</h3><a class="indexterm" name="id3240228"></a><pre class="programlisting"><a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a>*              g_list_remove                       (<a class="link" href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,                                                         <a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);</pre><p>Removes an element from a <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.If two elements contain the same data, only the first is removed.If none of the elements contain the data, the <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> is unchanged.</p><p>Return: the new start of the <a class="link" href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a></p><p>

⌨️ 快捷键说明

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