Update to version 2.33.1
[profile/ivi/glib2.git] / docs / reference / glib / html / glib-Singly-Linked-Lists.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Singly-Linked Lists</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GLib Reference Manual">
8 <link rel="up" href="glib-data-types.html" title="GLib Data Types">
9 <link rel="prev" href="glib-Doubly-Linked-Lists.html" title="Doubly-Linked Lists">
10 <link rel="next" href="glib-Double-ended-Queues.html" title="Double-ended Queues">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
16 <tr valign="middle">
17 <td><a accesskey="p" href="glib-Doubly-Linked-Lists.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="glib-data-types.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
19 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
20 <th width="100%" align="center">GLib Reference Manual</th>
21 <td><a accesskey="n" href="glib-Double-ended-Queues.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
22 </tr>
23 <tr><td colspan="5" class="shortcuts">
24 <a href="#glib-Singly-Linked-Lists.synopsis" class="shortcut">Top</a>
25                    | 
26                   <a href="#glib-Singly-Linked-Lists.description" class="shortcut">Description</a>
27 </td></tr>
28 </table>
29 <div class="refentry">
30 <a name="glib-Singly-Linked-Lists"></a><div class="titlepage"></div>
31 <div class="refnamediv"><table width="100%"><tr>
32 <td valign="top">
33 <h2><span class="refentrytitle"><a name="glib-Singly-Linked-Lists.top_of_page"></a>Singly-Linked Lists</span></h2>
34 <p>Singly-Linked Lists — linked lists that can be iterated in one direction</p>
35 </td>
36 <td valign="top" align="right"></td>
37 </tr></table></div>
38 <div class="refsynopsisdiv">
39 <a name="glib-Singly-Linked-Lists.synopsis"></a><h2>Synopsis</h2>
40 <pre class="synopsis">
41 #include &lt;glib.h&gt;
42
43 struct              <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList">GSList</a>;
44
45 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-alloc" title="g_slist_alloc ()">g_slist_alloc</a>                       (<em class="parameter"><code><span class="type">void</span></code></em>);
46 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-append" title="g_slist_append ()">g_slist_append</a>                      (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
47                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);
48 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-prepend" title="g_slist_prepend ()">g_slist_prepend</a>                     (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
49                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);
50 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-insert" title="g_slist_insert ()">g_slist_insert</a>                      (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
51                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
52                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> position</code></em>);
53 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-insert-before" title="g_slist_insert_before ()">g_slist_insert_before</a>               (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *slist</code></em>,
54                                                          <em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *sibling</code></em>,
55                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);
56 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-insert-sorted" title="g_slist_insert_sorted ()">g_slist_insert_sorted</a>               (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
57                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
58                                                          <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> func</code></em>);
59 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-remove" title="g_slist_remove ()">g_slist_remove</a>                      (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
60                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>);
61 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-remove-link" title="g_slist_remove_link ()">g_slist_remove_link</a>                 (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
62                                                          <em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *link_</code></em>);
63 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-delete-link" title="g_slist_delete_link ()">g_slist_delete_link</a>                 (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
64                                                          <em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *link_</code></em>);
65 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-remove-all" title="g_slist_remove_all ()">g_slist_remove_all</a>                  (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
66                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>);
67 <span class="returnvalue">void</span>                <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-free" title="g_slist_free ()">g_slist_free</a>                        (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>);
68 <span class="returnvalue">void</span>                <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-free-full" title="g_slist_free_full ()">g_slist_free_full</a>                   (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
69                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> free_func</code></em>);
70 <span class="returnvalue">void</span>                <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-free-1" title="g_slist_free_1 ()">g_slist_free_1</a>                      (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>);
71 #define             <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-free1" title="g_slist_free1">g_slist_free1</a>
72
73 <a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-length" title="g_slist_length ()">g_slist_length</a>                      (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>);
74 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-copy" title="g_slist_copy ()">g_slist_copy</a>                        (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>);
75 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-reverse" title="g_slist_reverse ()">g_slist_reverse</a>                     (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>);
76 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-insert-sorted-with-data" title="g_slist_insert_sorted_with_data ()">g_slist_insert_sorted_with_data</a>     (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
77                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
78                                                          <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> func</code></em>,
79                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
80 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-sort" title="g_slist_sort ()">g_slist_sort</a>                        (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
81                                                          <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> compare_func</code></em>);
82 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-sort-with-data" title="g_slist_sort_with_data ()">g_slist_sort_with_data</a>              (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
83                                                          <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> compare_func</code></em>,
84                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
85 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-concat" title="g_slist_concat ()">g_slist_concat</a>                      (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list1</code></em>,
86                                                          <em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list2</code></em>);
87 <span class="returnvalue">void</span>                <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-foreach" title="g_slist_foreach ()">g_slist_foreach</a>                     (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
88                                                          <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GFunc" title="GFunc ()"><span class="type">GFunc</span></a> func</code></em>,
89                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
90
91 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-last" title="g_slist_last ()">g_slist_last</a>                        (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>);
92 #define             <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-next" title="g_slist_next()">g_slist_next</a>                        (slist)
93 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-nth" title="g_slist_nth ()">g_slist_nth</a>                         (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
94                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> n</code></em>);
95 <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-nth-data" title="g_slist_nth_data ()">g_slist_nth_data</a>                    (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
96                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> n</code></em>);
97
98 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-find" title="g_slist_find ()">g_slist_find</a>                        (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
99                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>);
100 <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-find-custom" title="g_slist_find_custom ()">g_slist_find_custom</a>                 (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
101                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>,
102                                                          <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> func</code></em>);
103 <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-position" title="g_slist_position ()">g_slist_position</a>                    (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
104                                                          <em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *llink</code></em>);
105 <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-index" title="g_slist_index ()">g_slist_index</a>                       (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
106                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>);
107 </pre>
108 </div>
109 <div class="refsect1">
110 <a name="glib-Singly-Linked-Lists.description"></a><h2>Description</h2>
111 <p>
112 The <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> structure and its associated functions provide a
113 standard singly-linked list data structure.
114 </p>
115 <p>
116 Each element in the list contains a piece of data, together with a
117 pointer which links to the next element in the list. Using this
118 pointer it is possible to move through the list in one direction
119 only (unlike the <a class="link" href="glib-Doubly-Linked-Lists.html" title="Doubly-Linked Lists">Doubly-Linked Lists</a> which
120 allow movement in both directions).
121 </p>
122 <p>
123 The data contained in each element can be either integer values, by
124 using one of the <a class="link" href="glib-Type-Conversion-Macros.html" title="Type Conversion Macros">Type
125 Conversion Macros</a>, or simply pointers to any type of data.
126 </p>
127 <p>
128 List elements are allocated from the <a class="link" href="glib-Memory-Slices.html" title="Memory Slices">slice allocator</a>, which is more
129 efficient than allocating elements individually.
130 </p>
131 <p>
132 Note that most of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> functions expect to be passed a
133 pointer to the first element in the list. The functions which insert
134 elements return the new start of the list, which may have changed.
135 </p>
136 <p>
137 There is no function to create a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>. <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is considered to be
138 the empty list so you simply set a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>* to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
139 </p>
140 <p>
141 To add elements, use <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-append" title="g_slist_append ()"><code class="function">g_slist_append()</code></a>, <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-prepend" title="g_slist_prepend ()"><code class="function">g_slist_prepend()</code></a>,
142 <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-insert" title="g_slist_insert ()"><code class="function">g_slist_insert()</code></a> and <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-insert-sorted" title="g_slist_insert_sorted ()"><code class="function">g_slist_insert_sorted()</code></a>.
143 </p>
144 <p>
145 To remove elements, use <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-remove" title="g_slist_remove ()"><code class="function">g_slist_remove()</code></a>.
146 </p>
147 <p>
148 To find elements in the list use <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-last" title="g_slist_last ()"><code class="function">g_slist_last()</code></a>, <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-next" title="g_slist_next()"><code class="function">g_slist_next()</code></a>,
149 <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-nth" title="g_slist_nth ()"><code class="function">g_slist_nth()</code></a>, <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-nth-data" title="g_slist_nth_data ()"><code class="function">g_slist_nth_data()</code></a>, <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-find" title="g_slist_find ()"><code class="function">g_slist_find()</code></a> and
150 <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-find-custom" title="g_slist_find_custom ()"><code class="function">g_slist_find_custom()</code></a>.
151 </p>
152 <p>
153 To find the index of an element use <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-position" title="g_slist_position ()"><code class="function">g_slist_position()</code></a> and
154 <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-index" title="g_slist_index ()"><code class="function">g_slist_index()</code></a>.
155 </p>
156 <p>
157 To call a function for each element in the list use
158 <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-foreach" title="g_slist_foreach ()"><code class="function">g_slist_foreach()</code></a>.
159 </p>
160 <p>
161 To free the entire list, use <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-free" title="g_slist_free ()"><code class="function">g_slist_free()</code></a>.
162 </p>
163 </div>
164 <div class="refsect1">
165 <a name="glib-Singly-Linked-Lists.details"></a><h2>Details</h2>
166 <div class="refsect2">
167 <a name="GSList"></a><h3>struct GSList</h3>
168 <pre class="programlisting">struct GSList {
169   gpointer data;
170   GSList *next;
171 };
172 </pre>
173 <p>
174 The <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> struct is used for each element in the singly-linked
175 list.
176 </p>
177 <div class="variablelist"><table border="0">
178 <col align="left" valign="top">
179 <tbody>
180 <tr>
181 <td><p><span class="term"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> <em class="structfield"><code><a name="GSList.data"></a>data</code></em>;</span></p></td>
182 <td>holds the element's data, which can be a pointer to any kind
183 of data, or any integer value using the <a class="link" href="glib-Type-Conversion-Macros.html" title="Type Conversion Macros">Type Conversion
184 Macros</a>.</td>
185 </tr>
186 <tr>
187 <td><p><span class="term"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *<em class="structfield"><code><a name="GSList.next"></a>next</code></em>;</span></p></td>
188 <td>contains the link to the next element in the list.</td>
189 </tr>
190 </tbody>
191 </table></div>
192 </div>
193 <hr>
194 <div class="refsect2">
195 <a name="g-slist-alloc"></a><h3>g_slist_alloc ()</h3>
196 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_alloc                       (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
197 <p>
198 Allocates space for one <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> element. It is called by the
199 <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-append" title="g_slist_append ()"><code class="function">g_slist_append()</code></a>, <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-prepend" title="g_slist_prepend ()"><code class="function">g_slist_prepend()</code></a>, <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-insert" title="g_slist_insert ()"><code class="function">g_slist_insert()</code></a> and
200 <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-insert-sorted" title="g_slist_insert_sorted ()"><code class="function">g_slist_insert_sorted()</code></a> functions and so is rarely used on its own.
201 </p>
202 <div class="variablelist"><table border="0">
203 <col align="left" valign="top">
204 <tbody><tr>
205 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
206 <td>a pointer to the newly-allocated <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> element.</td>
207 </tr></tbody>
208 </table></div>
209 </div>
210 <hr>
211 <div class="refsect2">
212 <a name="g-slist-append"></a><h3>g_slist_append ()</h3>
213 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_append                      (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
214                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
215 <p>
216 Adds a new element on to the end of the list.
217 </p>
218 <p>
219 </p>
220 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
221 <h3 class="title">Note</h3>
222 <p>
223 The return value is the new start of the list, which may
224 have changed, so make sure you store the new value.
225 </p>
226 </div>
227 <p>
228 </p>
229 <p>
230 </p>
231 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
232 <h3 class="title">Note</h3>
233 <p>
234 Note that <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-append" title="g_slist_append ()"><code class="function">g_slist_append()</code></a> has to traverse the entire list
235 to find the end, which is inefficient when adding multiple
236 elements. A common idiom to avoid the inefficiency is to prepend
237 the elements and reverse the list when all elements have been added.
238 </p>
239 </div>
240 <p>
241 </p>
242 <p>
243 </p>
244 <div class="informalexample"><pre class="programlisting">
245 /* Notice that these are initialized to the empty list. */
246 GSList *list = NULL, *number_list = NULL;
247
248 /* This is a list of strings. */
249 list = g_slist_append (list, "first");
250 list = g_slist_append (list, "second");
251
252 /* This is a list of integers. */
253 number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
254 number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
255 </pre></div>
256 <p>
257 </p>
258 <div class="variablelist"><table border="0">
259 <col align="left" valign="top">
260 <tbody>
261 <tr>
262 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
263 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
264 </td>
265 </tr>
266 <tr>
267 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
268 <td>the data for the new element</td>
269 </tr>
270 <tr>
271 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
272 <td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
273 </td>
274 </tr>
275 </tbody>
276 </table></div>
277 </div>
278 <hr>
279 <div class="refsect2">
280 <a name="g-slist-prepend"></a><h3>g_slist_prepend ()</h3>
281 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_prepend                     (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
282                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
283 <p>
284 Adds a new element on to the start of the list.
285 </p>
286 <p>
287 </p>
288 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
289 <h3 class="title">Note</h3>
290 <p>
291 The return value is the new start of the list, which
292 may have changed, so make sure you store the new value.
293 </p>
294 </div>
295 <p>
296 </p>
297 <p>
298 </p>
299 <div class="informalexample"><pre class="programlisting">
300 /* Notice that it is initialized to the empty list. */
301 GSList *list = NULL;
302 list = g_slist_prepend (list, "last");
303 list = g_slist_prepend (list, "first");
304 </pre></div>
305 <p>
306 </p>
307 <div class="variablelist"><table border="0">
308 <col align="left" valign="top">
309 <tbody>
310 <tr>
311 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
312 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
313 </td>
314 </tr>
315 <tr>
316 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
317 <td>the data for the new element</td>
318 </tr>
319 <tr>
320 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
321 <td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
322 </td>
323 </tr>
324 </tbody>
325 </table></div>
326 </div>
327 <hr>
328 <div class="refsect2">
329 <a name="g-slist-insert"></a><h3>g_slist_insert ()</h3>
330 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_insert                      (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
331                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
332                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> position</code></em>);</pre>
333 <p>
334 Inserts a new element into the list at the given position.
335 </p>
336 <div class="variablelist"><table border="0">
337 <col align="left" valign="top">
338 <tbody>
339 <tr>
340 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
341 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
342 </td>
343 </tr>
344 <tr>
345 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
346 <td>the data for the new element</td>
347 </tr>
348 <tr>
349 <td><p><span class="term"><em class="parameter"><code>position</code></em> :</span></p></td>
350 <td>the position to insert the element.
351 If this is negative, or is larger than the number
352 of elements in the list, the new element is added on
353 to the end of the list.</td>
354 </tr>
355 <tr>
356 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
357 <td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
358 </td>
359 </tr>
360 </tbody>
361 </table></div>
362 </div>
363 <hr>
364 <div class="refsect2">
365 <a name="g-slist-insert-before"></a><h3>g_slist_insert_before ()</h3>
366 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_insert_before               (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *slist</code></em>,
367                                                          <em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *sibling</code></em>,
368                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
369 <p>
370 Inserts a node before <em class="parameter"><code>sibling</code></em> containing <em class="parameter"><code>data</code></em>.
371 </p>
372 <div class="variablelist"><table border="0">
373 <col align="left" valign="top">
374 <tbody>
375 <tr>
376 <td><p><span class="term"><em class="parameter"><code>slist</code></em> :</span></p></td>
377 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
378 </td>
379 </tr>
380 <tr>
381 <td><p><span class="term"><em class="parameter"><code>sibling</code></em> :</span></p></td>
382 <td>node to insert <em class="parameter"><code>data</code></em> before</td>
383 </tr>
384 <tr>
385 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
386 <td>data to put in the newly-inserted node</td>
387 </tr>
388 <tr>
389 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
390 <td>the new head of the list.</td>
391 </tr>
392 </tbody>
393 </table></div>
394 </div>
395 <hr>
396 <div class="refsect2">
397 <a name="g-slist-insert-sorted"></a><h3>g_slist_insert_sorted ()</h3>
398 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_insert_sorted               (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
399                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
400                                                          <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> func</code></em>);</pre>
401 <p>
402 Inserts a new element into the list, using the given
403 comparison function to determine its position.
404 </p>
405 <div class="variablelist"><table border="0">
406 <col align="left" valign="top">
407 <tbody>
408 <tr>
409 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
410 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
411 </td>
412 </tr>
413 <tr>
414 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
415 <td>the data for the new element</td>
416 </tr>
417 <tr>
418 <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
419 <td>the function to compare elements in the list.
420 It should return a number &gt; 0 if the first parameter
421 comes after the second parameter in the sort order.</td>
422 </tr>
423 <tr>
424 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
425 <td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
426 </td>
427 </tr>
428 </tbody>
429 </table></div>
430 </div>
431 <hr>
432 <div class="refsect2">
433 <a name="g-slist-remove"></a><h3>g_slist_remove ()</h3>
434 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_remove                      (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
435                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>);</pre>
436 <p>
437 Removes an element from a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>.
438 If two elements contain the same data, only the first is removed.
439 If none of the elements contain the data, the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> is unchanged.
440 </p>
441 <div class="variablelist"><table border="0">
442 <col align="left" valign="top">
443 <tbody>
444 <tr>
445 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
446 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
447 </td>
448 </tr>
449 <tr>
450 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
451 <td>the data of the element to remove</td>
452 </tr>
453 <tr>
454 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
455 <td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
456 </td>
457 </tr>
458 </tbody>
459 </table></div>
460 </div>
461 <hr>
462 <div class="refsect2">
463 <a name="g-slist-remove-link"></a><h3>g_slist_remove_link ()</h3>
464 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_remove_link                 (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
465                                                          <em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *link_</code></em>);</pre>
466 <p>
467 Removes an element from a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>, without
468 freeing the element. The removed element's next
469 link is set to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, so that it becomes a
470 self-contained list with one element.
471 </p>
472 <div class="variablelist"><table border="0">
473 <col align="left" valign="top">
474 <tbody>
475 <tr>
476 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
477 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
478 </td>
479 </tr>
480 <tr>
481 <td><p><span class="term"><em class="parameter"><code>link_</code></em> :</span></p></td>
482 <td>an element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
483 </td>
484 </tr>
485 <tr>
486 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
487 <td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>, without the element</td>
488 </tr>
489 </tbody>
490 </table></div>
491 </div>
492 <hr>
493 <div class="refsect2">
494 <a name="g-slist-delete-link"></a><h3>g_slist_delete_link ()</h3>
495 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_delete_link                 (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
496                                                          <em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *link_</code></em>);</pre>
497 <p>
498 Removes the node link_ from the list and frees it.
499 Compare this to <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-remove-link" title="g_slist_remove_link ()"><code class="function">g_slist_remove_link()</code></a> which removes the node
500 without freeing it.
501 </p>
502 <div class="variablelist"><table border="0">
503 <col align="left" valign="top">
504 <tbody>
505 <tr>
506 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
507 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
508 </td>
509 </tr>
510 <tr>
511 <td><p><span class="term"><em class="parameter"><code>link_</code></em> :</span></p></td>
512 <td>node to delete</td>
513 </tr>
514 <tr>
515 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
516 <td>the new head of <em class="parameter"><code>list</code></em>
517 </td>
518 </tr>
519 </tbody>
520 </table></div>
521 </div>
522 <hr>
523 <div class="refsect2">
524 <a name="g-slist-remove-all"></a><h3>g_slist_remove_all ()</h3>
525 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_remove_all                  (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
526                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>);</pre>
527 <p>
528 Removes all list nodes with data equal to <em class="parameter"><code>data</code></em>.
529 Returns the new head of the list. Contrast with
530 <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-remove" title="g_slist_remove ()"><code class="function">g_slist_remove()</code></a> which removes only the first node
531 matching the given data.
532 </p>
533 <div class="variablelist"><table border="0">
534 <col align="left" valign="top">
535 <tbody>
536 <tr>
537 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
538 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
539 </td>
540 </tr>
541 <tr>
542 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
543 <td>data to remove</td>
544 </tr>
545 <tr>
546 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
547 <td>new head of <em class="parameter"><code>list</code></em>
548 </td>
549 </tr>
550 </tbody>
551 </table></div>
552 </div>
553 <hr>
554 <div class="refsect2">
555 <a name="g-slist-free"></a><h3>g_slist_free ()</h3>
556 <pre class="programlisting"><span class="returnvalue">void</span>                g_slist_free                        (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>);</pre>
557 <p>
558 Frees all of the memory used by a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>.
559 The freed elements are returned to the slice allocator.
560 </p>
561 <p>
562 </p>
563 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
564 <h3 class="title">Note</h3>
565 <p>
566 If list elements contain dynamically-allocated memory,
567 you should either use <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-free-full" title="g_slist_free_full ()"><code class="function">g_slist_free_full()</code></a> or free them manually
568 first.
569 </p>
570 </div>
571 <p>
572 </p>
573 <div class="variablelist"><table border="0">
574 <col align="left" valign="top">
575 <tbody><tr>
576 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
577 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
578 </td>
579 </tr></tbody>
580 </table></div>
581 </div>
582 <hr>
583 <div class="refsect2">
584 <a name="g-slist-free-full"></a><h3>g_slist_free_full ()</h3>
585 <pre class="programlisting"><span class="returnvalue">void</span>                g_slist_free_full                   (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
586                                                          <em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> free_func</code></em>);</pre>
587 <p>
588 Convenience method, which frees all the memory used by a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>, and
589 calls the specified destroy function on every element's data.
590 </p>
591 <div class="variablelist"><table border="0">
592 <col align="left" valign="top">
593 <tbody>
594 <tr>
595 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
596 <td>a pointer to a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
597 </td>
598 </tr>
599 <tr>
600 <td><p><span class="term"><em class="parameter"><code>free_func</code></em> :</span></p></td>
601 <td>the function to be called to free each element's data</td>
602 </tr>
603 </tbody>
604 </table></div>
605 <p class="since">Since 2.28</p>
606 </div>
607 <hr>
608 <div class="refsect2">
609 <a name="g-slist-free-1"></a><h3>g_slist_free_1 ()</h3>
610 <pre class="programlisting"><span class="returnvalue">void</span>                g_slist_free_1                      (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>);</pre>
611 <p>
612 Frees one <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> element.
613 It is usually used after <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-remove-link" title="g_slist_remove_link ()"><code class="function">g_slist_remove_link()</code></a>.
614 </p>
615 <div class="variablelist"><table border="0">
616 <col align="left" valign="top">
617 <tbody><tr>
618 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
619 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> element</td>
620 </tr></tbody>
621 </table></div>
622 </div>
623 <hr>
624 <div class="refsect2">
625 <a name="g-slist-free1"></a><h3>g_slist_free1</h3>
626 <pre class="programlisting">#define             g_slist_free1</pre>
627 <p>
628 A macro which does the same as <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-free-1" title="g_slist_free_1 ()"><code class="function">g_slist_free_1()</code></a>.
629 </p>
630 <p class="since">Since 2.10</p>
631 </div>
632 <hr>
633 <div class="refsect2">
634 <a name="g-slist-length"></a><h3>g_slist_length ()</h3>
635 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_slist_length                      (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>);</pre>
636 <p>
637 Gets the number of elements in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>.
638 </p>
639 <p>
640 </p>
641 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
642 <h3 class="title">Note</h3>
643 <p>
644 This function iterates over the whole list to
645 count its elements.
646 </p>
647 </div>
648 <p>
649 </p>
650 <div class="variablelist"><table border="0">
651 <col align="left" valign="top">
652 <tbody>
653 <tr>
654 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
655 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
656 </td>
657 </tr>
658 <tr>
659 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
660 <td>the number of elements in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
661 </td>
662 </tr>
663 </tbody>
664 </table></div>
665 </div>
666 <hr>
667 <div class="refsect2">
668 <a name="g-slist-copy"></a><h3>g_slist_copy ()</h3>
669 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_copy                        (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>);</pre>
670 <p>
671 Copies a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>.
672 </p>
673 <p>
674 </p>
675 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
676 <h3 class="title">Note</h3>
677 <p>
678 Note that this is a "shallow" copy. If the list elements
679 consist of pointers to data, the pointers are copied but
680 the actual data isn't.
681 </p>
682 </div>
683 <p>
684 </p>
685 <div class="variablelist"><table border="0">
686 <col align="left" valign="top">
687 <tbody>
688 <tr>
689 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
690 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
691 </td>
692 </tr>
693 <tr>
694 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
695 <td>a copy of <em class="parameter"><code>list</code></em>
696 </td>
697 </tr>
698 </tbody>
699 </table></div>
700 </div>
701 <hr>
702 <div class="refsect2">
703 <a name="g-slist-reverse"></a><h3>g_slist_reverse ()</h3>
704 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_reverse                     (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>);</pre>
705 <p>
706 Reverses a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>.
707 </p>
708 <div class="variablelist"><table border="0">
709 <col align="left" valign="top">
710 <tbody>
711 <tr>
712 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
713 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
714 </td>
715 </tr>
716 <tr>
717 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
718 <td>the start of the reversed <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
719 </td>
720 </tr>
721 </tbody>
722 </table></div>
723 </div>
724 <hr>
725 <div class="refsect2">
726 <a name="g-slist-insert-sorted-with-data"></a><h3>g_slist_insert_sorted_with_data ()</h3>
727 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_insert_sorted_with_data     (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
728                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
729                                                          <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> func</code></em>,
730                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
731 <p>
732 Inserts a new element into the list, using the given
733 comparison function to determine its position.
734 </p>
735 <div class="variablelist"><table border="0">
736 <col align="left" valign="top">
737 <tbody>
738 <tr>
739 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
740 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
741 </td>
742 </tr>
743 <tr>
744 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
745 <td>the data for the new element</td>
746 </tr>
747 <tr>
748 <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
749 <td>the function to compare elements in the list.
750 It should return a number &gt; 0 if the first parameter
751 comes after the second parameter in the sort order.</td>
752 </tr>
753 <tr>
754 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
755 <td>data to pass to comparison function</td>
756 </tr>
757 <tr>
758 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
759 <td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
760 </td>
761 </tr>
762 </tbody>
763 </table></div>
764 <p class="since">Since 2.10</p>
765 </div>
766 <hr>
767 <div class="refsect2">
768 <a name="g-slist-sort"></a><h3>g_slist_sort ()</h3>
769 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_sort                        (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
770                                                          <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> compare_func</code></em>);</pre>
771 <p>
772 Sorts a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> using the given comparison function.
773 </p>
774 <div class="variablelist"><table border="0">
775 <col align="left" valign="top">
776 <tbody>
777 <tr>
778 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
779 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
780 </td>
781 </tr>
782 <tr>
783 <td><p><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></p></td>
784 <td>the comparison function used to sort the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>.
785 This function is passed the data from 2 elements of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
786 and should return 0 if they are equal, a negative value if the
787 first element comes before the second, or a positive value if
788 the first element comes after the second.</td>
789 </tr>
790 <tr>
791 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
792 <td>the start of the sorted <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
793 </td>
794 </tr>
795 </tbody>
796 </table></div>
797 </div>
798 <hr>
799 <div class="refsect2">
800 <a name="g-slist-sort-with-data"></a><h3>g_slist_sort_with_data ()</h3>
801 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_sort_with_data              (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
802                                                          <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> compare_func</code></em>,
803                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
804 <p>
805 Like <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-sort" title="g_slist_sort ()"><code class="function">g_slist_sort()</code></a>, but the sort function accepts a user data argument.
806 </p>
807 <div class="variablelist"><table border="0">
808 <col align="left" valign="top">
809 <tbody>
810 <tr>
811 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
812 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
813 </td>
814 </tr>
815 <tr>
816 <td><p><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></p></td>
817 <td>comparison function</td>
818 </tr>
819 <tr>
820 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
821 <td>data to pass to comparison function</td>
822 </tr>
823 <tr>
824 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
825 <td>new head of the list</td>
826 </tr>
827 </tbody>
828 </table></div>
829 </div>
830 <hr>
831 <div class="refsect2">
832 <a name="g-slist-concat"></a><h3>g_slist_concat ()</h3>
833 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_concat                      (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list1</code></em>,
834                                                          <em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list2</code></em>);</pre>
835 <p>
836 Adds the second <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> onto the end of the first <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>.
837 Note that the elements of the second <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> are not copied.
838 They are used directly.
839 </p>
840 <div class="variablelist"><table border="0">
841 <col align="left" valign="top">
842 <tbody>
843 <tr>
844 <td><p><span class="term"><em class="parameter"><code>list1</code></em> :</span></p></td>
845 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
846 </td>
847 </tr>
848 <tr>
849 <td><p><span class="term"><em class="parameter"><code>list2</code></em> :</span></p></td>
850 <td>the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> to add to the end of the first <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
851 </td>
852 </tr>
853 <tr>
854 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
855 <td>the start of the new <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
856 </td>
857 </tr>
858 </tbody>
859 </table></div>
860 </div>
861 <hr>
862 <div class="refsect2">
863 <a name="g-slist-foreach"></a><h3>g_slist_foreach ()</h3>
864 <pre class="programlisting"><span class="returnvalue">void</span>                g_slist_foreach                     (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
865                                                          <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GFunc" title="GFunc ()"><span class="type">GFunc</span></a> func</code></em>,
866                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
867 <p>
868 Calls a function for each element of a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>.
869 </p>
870 <div class="variablelist"><table border="0">
871 <col align="left" valign="top">
872 <tbody>
873 <tr>
874 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
875 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
876 </td>
877 </tr>
878 <tr>
879 <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
880 <td>the function to call with each element's data</td>
881 </tr>
882 <tr>
883 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
884 <td>user data to pass to the function</td>
885 </tr>
886 </tbody>
887 </table></div>
888 </div>
889 <hr>
890 <div class="refsect2">
891 <a name="g-slist-last"></a><h3>g_slist_last ()</h3>
892 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_last                        (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>);</pre>
893 <p>
894 Gets the last element in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>.
895 </p>
896 <p>
897 </p>
898 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
899 <h3 class="title">Note</h3>
900 <p>
901 This function iterates over the whole list.
902 </p>
903 </div>
904 <p>
905 </p>
906 <div class="variablelist"><table border="0">
907 <col align="left" valign="top">
908 <tbody>
909 <tr>
910 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
911 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
912 </td>
913 </tr>
914 <tr>
915 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
916 <td>the last element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>,
917 or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> has no elements</td>
918 </tr>
919 </tbody>
920 </table></div>
921 </div>
922 <hr>
923 <div class="refsect2">
924 <a name="g-slist-next"></a><h3>g_slist_next()</h3>
925 <pre class="programlisting">#define             g_slist_next(slist)</pre>
926 <p>
927 A convenience macro to get the next element in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>.
928 </p>
929 <div class="variablelist"><table border="0">
930 <col align="left" valign="top">
931 <tbody>
932 <tr>
933 <td><p><span class="term"><em class="parameter"><code>slist</code></em> :</span></p></td>
934 <td>an element in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>.</td>
935 </tr>
936 <tr>
937 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
938 <td>the next element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if there are no more elements.</td>
939 </tr>
940 </tbody>
941 </table></div>
942 </div>
943 <hr>
944 <div class="refsect2">
945 <a name="g-slist-nth"></a><h3>g_slist_nth ()</h3>
946 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_nth                         (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
947                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> n</code></em>);</pre>
948 <p>
949 Gets the element at the given position in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>.
950 </p>
951 <div class="variablelist"><table border="0">
952 <col align="left" valign="top">
953 <tbody>
954 <tr>
955 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
956 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
957 </td>
958 </tr>
959 <tr>
960 <td><p><span class="term"><em class="parameter"><code>n</code></em> :</span></p></td>
961 <td>the position of the element, counting from 0</td>
962 </tr>
963 <tr>
964 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
965 <td>the element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the position is off
966 the end of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
967 </td>
968 </tr>
969 </tbody>
970 </table></div>
971 </div>
972 <hr>
973 <div class="refsect2">
974 <a name="g-slist-nth-data"></a><h3>g_slist_nth_data ()</h3>
975 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            g_slist_nth_data                    (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
976                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> n</code></em>);</pre>
977 <p>
978 Gets the data of the element at the given position.
979 </p>
980 <div class="variablelist"><table border="0">
981 <col align="left" valign="top">
982 <tbody>
983 <tr>
984 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
985 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
986 </td>
987 </tr>
988 <tr>
989 <td><p><span class="term"><em class="parameter"><code>n</code></em> :</span></p></td>
990 <td>the position of the element</td>
991 </tr>
992 <tr>
993 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
994 <td>the element's data, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if the position
995 is off the end of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
996 </td>
997 </tr>
998 </tbody>
999 </table></div>
1000 </div>
1001 <hr>
1002 <div class="refsect2">
1003 <a name="g-slist-find"></a><h3>g_slist_find ()</h3>
1004 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_find                        (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
1005                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>);</pre>
1006 <p>
1007 Finds the element in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> which
1008 contains the given data.
1009 </p>
1010 <div class="variablelist"><table border="0">
1011 <col align="left" valign="top">
1012 <tbody>
1013 <tr>
1014 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
1015 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
1016 </td>
1017 </tr>
1018 <tr>
1019 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1020 <td>the element data to find</td>
1021 </tr>
1022 <tr>
1023 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1024 <td>the found <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> element,
1025 or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if it is not found</td>
1026 </tr>
1027 </tbody>
1028 </table></div>
1029 </div>
1030 <hr>
1031 <div class="refsect2">
1032 <a name="g-slist-find-custom"></a><h3>g_slist_find_custom ()</h3>
1033 <pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="returnvalue">GSList</span></a> *            g_slist_find_custom                 (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
1034                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>,
1035                                                          <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> func</code></em>);</pre>
1036 <p>
1037 Finds an element in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>, using a supplied function to
1038 find the desired element. It iterates over the list, calling
1039 the given function which should return 0 when the desired
1040 element is found. The function takes two <a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> arguments,
1041 the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> element's data as the first argument and the
1042 given user data.
1043 </p>
1044 <div class="variablelist"><table border="0">
1045 <col align="left" valign="top">
1046 <tbody>
1047 <tr>
1048 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
1049 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
1050 </td>
1051 </tr>
1052 <tr>
1053 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1054 <td>user data passed to the function</td>
1055 </tr>
1056 <tr>
1057 <td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
1058 <td>the function to call for each element.
1059 It should return 0 when the desired element is found</td>
1060 </tr>
1061 <tr>
1062 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1063 <td>the found <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> if it is not found</td>
1064 </tr>
1065 </tbody>
1066 </table></div>
1067 </div>
1068 <hr>
1069 <div class="refsect2">
1070 <a name="g-slist-position"></a><h3>g_slist_position ()</h3>
1071 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                g_slist_position                    (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
1072                                                          <em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *llink</code></em>);</pre>
1073 <p>
1074 Gets the position of the given element
1075 in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> (starting from 0).
1076 </p>
1077 <div class="variablelist"><table border="0">
1078 <col align="left" valign="top">
1079 <tbody>
1080 <tr>
1081 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
1082 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
1083 </td>
1084 </tr>
1085 <tr>
1086 <td><p><span class="term"><em class="parameter"><code>llink</code></em> :</span></p></td>
1087 <td>an element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
1088 </td>
1089 </tr>
1090 <tr>
1091 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1092 <td>the position of the element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>,
1093 or -1 if the element is not found</td>
1094 </tr>
1095 </tbody>
1096 </table></div>
1097 </div>
1098 <hr>
1099 <div class="refsect2">
1100 <a name="g-slist-index"></a><h3>g_slist_index ()</h3>
1101 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                g_slist_index                       (<em class="parameter"><code><a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a> *list</code></em>,
1102                                                          <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>);</pre>
1103 <p>
1104 Gets the position of the element containing
1105 the given data (starting from 0).
1106 </p>
1107 <div class="variablelist"><table border="0">
1108 <col align="left" valign="top">
1109 <tbody>
1110 <tr>
1111 <td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
1112 <td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList" title="struct GSList"><span class="type">GSList</span></a>
1113 </td>
1114 </tr>
1115 <tr>
1116 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1117 <td>the data to find</td>
1118 </tr>
1119 <tr>
1120 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1121 <td>the index of the element containing the data,
1122 or -1 if the data is not found</td>
1123 </tr>
1124 </tbody>
1125 </table></div>
1126 </div>
1127 </div>
1128 </div>
1129 <div class="footer">
1130 <hr>
1131           Generated by GTK-Doc V1.18</div>
1132 </body>
1133 </html>