36
36
<th width="100%" align="center">GLib Reference Manual</th>
37
37
<td><a accesskey="n" href="glib-Double-ended-Queues.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
39
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3127045" class="shortcut">Top</a>
39
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3249902" class="shortcut">Top</a>
41
<a href="#id3127955" class="shortcut">Description</a></nobr></td></tr>
41
<a href="#id3250812" class="shortcut">Description</a></nobr></td></tr>
43
43
<div class="refentry" lang="en">
44
44
<a name="glib-Singly-Linked-Lists"></a><div class="titlepage"></div>
45
45
<div class="refnamediv"><table width="100%"><tr>
48
<a name="id3127045"></a><span class="refentrytitle">Singly-Linked Lists</span>
48
<a name="id3249902"></a><span class="refentrytitle">Singly-Linked Lists</span>
50
50
<p>Singly-Linked Lists — linked lists containing integer values or pointers to data, limited to
51
51
iterating over the list in one direction</p>
239
239
<div class="refsect2" lang="en">
240
<a name="id3128468"></a><h3>
240
<a name="id3251326"></a><h3>
241
241
<a name="g-slist-append"></a>g_slist_append ()</h3>
242
<a class="indexterm" name="id3128481"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_append (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
242
<a class="indexterm" name="id3251339"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_append (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
243
243
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre>
245
245
Adds a new element on to the end of the list.
247
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
248
<h3 class="title">Note</h3>
250
The return value is the new start of the list, which may have changed, so
251
make sure you store the new value.
254
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
255
<h3 class="title">Note</h3>
257
Note that <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-append"><code class="function">g_slist_append()</code></a> has to traverse the entire list to find the end,
258
which is inefficient when adding multiple elements. A common idiom to
259
avoid the inefficiency is to prepend the elements and reverse the list
260
when all elements have been added.
249
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
250
<h3 class="title">Note</h3>
252
The return value is the new start of the list, which may
253
have changed, so make sure you store the new value.
260
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
261
<h3 class="title">Note</h3>
263
Note that <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-append"><code class="function">g_slist_append()</code></a> has to traverse the entire list
264
to find the end, which is inefficient when adding multiple
265
elements. A common idiom to avoid the inefficiency is to prepend
266
the elements and reverse the list when all elements have been added.
263
273
<div class="informalexample"><pre class="programlisting">
264
/* Notice that these are initialized to the empty list. */
265
GSList *list = NULL, *number_list = NULL;
267
/* This is a list of strings. */
268
list = g_slist_append (list, "first");
269
list = g_slist_append (list, "second");
271
/* This is a list of integers. */
272
number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
273
number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
274
/* Notice that these are initialized to the empty list. */
275
GSList *list = NULL, *number_list = NULL;
277
/* This is a list of strings. */
278
list = g_slist_append (list, "first");
279
list = g_slist_append (list, "second");
281
/* This is a list of integers. */
282
number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
283
number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
275
288
<div class="variablelist"><table border="0">
276
289
<col align="left" valign="top">
279
292
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
280
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
293
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
284
297
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
285
<td>the data for the new element.
298
<td> the data for the new element
289
302
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
290
<td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
303
<td> the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
299
310
<div class="refsect2" lang="en">
300
<a name="id3128620"></a><h3>
311
<a name="id3251484"></a><h3>
301
312
<a name="g-slist-prepend"></a>g_slist_prepend ()</h3>
302
<a class="indexterm" name="id3128632"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_prepend (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
313
<a class="indexterm" name="id3251497"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_prepend (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
303
314
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre>
305
316
Adds a new element on to the start of the list.
307
320
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
308
321
<h3 class="title">Note</h3>
310
The return value is the new start of the list, which may have changed, so
311
make sure you store the new value.
323
The return value is the new start of the list, which
324
may have changed, so make sure you store the new value.
314
331
<div class="informalexample"><pre class="programlisting">
315
/* Notice that it is initialized to the empty list. */
317
list = g_slist_prepend (list, "last");
318
list = g_slist_prepend (list, "first");
332
/* Notice that it is initialized to the empty list. */
334
list = g_slist_prepend (list, "last");
335
list = g_slist_prepend (list, "first");
320
340
<div class="variablelist"><table border="0">
321
341
<col align="left" valign="top">
324
344
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
325
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
345
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
329
349
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
330
<td>the data for the new element.
350
<td> the data for the new element
334
354
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
335
<td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
355
<td> the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
344
362
<div class="refsect2" lang="en">
345
<a name="id3128746"></a><h3>
363
<a name="id3251616"></a><h3>
346
364
<a name="g-slist-insert"></a>g_slist_insert ()</h3>
347
<a class="indexterm" name="id3128758"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_insert (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
365
<a class="indexterm" name="id3251628"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_insert (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
348
366
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,
349
367
<a class="link" href="glib-Basic-Types.html#gint">gint</a> position);</pre>
351
Inserts a new element into the list at the given position.
369
Inserts a new element into the list at the given position.</p>
353
373
<div class="variablelist"><table border="0">
354
374
<col align="left" valign="top">
357
377
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
358
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
378
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
362
382
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
363
<td>the data for the new element.
383
<td> the data for the new element
367
387
<td><p><span class="term"><em class="parameter"><code>position</code></em> :</span></p></td>
368
<td>the position to insert the element. If this is negative, or is
369
larger than the number of elements in the list, the new element is added on
370
to the end of the list.
388
<td> the position to insert the element.
389
If this is negative, or is larger than the number
390
of elements in the list, the new element is added on
391
to the end of the list.
374
395
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
375
<td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
396
<td> the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
384
403
<div class="refsect2" lang="en">
385
<a name="id3128878"></a><h3>
404
<a name="id3251751"></a><h3>
386
405
<a name="g-slist-insert-before"></a>g_slist_insert_before ()</h3>
387
<a class="indexterm" name="id3128891"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_insert_before (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *slist,
406
<a class="indexterm" name="id3251765"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_insert_before (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *slist,
388
407
<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *sibling,
389
408
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre>
391
Inserts a node before <em class="parameter"><code>sibling</code></em> containing <em class="parameter"><code>data</code></em>. Returns the new head of the list.
410
Inserts a node before <em class="parameter"><code>sibling</code></em> containing <em class="parameter"><code>data</code></em>.</p>
393
414
<div class="variablelist"><table border="0">
394
415
<col align="left" valign="top">
397
418
<td><p><span class="term"><em class="parameter"><code>slist</code></em> :</span></p></td>
398
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
419
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
402
423
<td><p><span class="term"><em class="parameter"><code>sibling</code></em> :</span></p></td>
403
<td>node to insert <em class="parameter"><code>data</code></em> before.
424
<td> node to insert <em class="parameter"><code>data</code></em> before
407
428
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
408
<td>data to put in the newly-inserted node.
429
<td> data to put in the newly-inserted node
412
433
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
413
<td>new head of the list.
434
<td> the new head of the list.
422
441
<div class="refsect2" lang="en">
423
<a name="id3129019"></a><h3>
442
<a name="id3251895"></a><h3>
424
443
<a name="g-slist-insert-sorted"></a>g_slist_insert_sorted ()</h3>
425
<a class="indexterm" name="id3129032"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_insert_sorted (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
444
<a class="indexterm" name="id3251908"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_insert_sorted (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
426
445
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,
427
446
<a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> func);</pre>
429
Inserts a new element into the list, using the given comparison function
430
to determine its position.
448
Inserts a new element into the list, using the given
449
comparison function to determine its position.</p>
432
453
<div class="variablelist"><table border="0">
433
454
<col align="left" valign="top">
436
457
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
437
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
458
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
441
462
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
442
<td>the data for the new element.
463
<td> the data for the new element
446
467
<td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
447
<td>the function to compare elements in the list. It should return a
448
number > 0 if the first parameter comes after the second parameter in
468
<td> the function to compare elements in the list.
469
It should return a number > 0 if the first parameter
470
comes after the second parameter in the sort order.
453
474
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
454
<td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
475
<td> the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
463
482
<div class="refsect2" lang="en">
464
<a name="id3129153"></a><h3>
483
<a name="id3252037"></a><h3>
465
484
<a name="g-slist-remove"></a>g_slist_remove ()</h3>
466
<a class="indexterm" name="id3129166"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_remove (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
485
<a class="indexterm" name="id3252050"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_remove (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
467
486
<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);</pre>
469
488
Removes an element from a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
470
489
If two elements contain the same data, only the first is removed.
471
If none of the elements contain the data, the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> is unchanged.
490
If none of the elements contain the data, the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> is unchanged.</p>
473
494
<div class="variablelist"><table border="0">
474
495
<col align="left" valign="top">
477
498
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
478
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
499
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
482
503
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
483
<td>the data of the element to remove.
504
<td> the data of the element to remove
487
508
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
488
<td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
509
<td> the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
497
516
<div class="refsect2" lang="en">
498
<a name="id3129279"></a><h3>
517
<a name="id3252166"></a><h3>
499
518
<a name="g-slist-remove-link"></a>g_slist_remove_link ()</h3>
500
<a class="indexterm" name="id3129292"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_remove_link (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
519
<a class="indexterm" name="id3252179"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_remove_link (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
501
520
<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *link_);</pre>
503
Removes an element from a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>, without freeing the element.
504
The removed element's next link is set to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, so that it becomes a
505
self-contained list with one element.
522
Removes an element from a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>, without
523
freeing the element. The removed element's next
524
link is set to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, so that it becomes a
525
self-contained list with one element.</p>
507
529
<div class="variablelist"><table border="0">
508
530
<col align="left" valign="top">
511
533
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
512
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
534
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
516
538
<td><p><span class="term"><em class="parameter"><code>link_</code></em> :</span></p></td>
517
<td>an element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
539
<td> an element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
521
543
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
522
<td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>, without the element.
544
<td> the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>, without the element
531
551
<div class="refsect2" lang="en">
532
<a name="id3129415"></a><h3>
552
<a name="id3252305"></a><h3>
533
553
<a name="g-slist-delete-link"></a>g_slist_delete_link ()</h3>
534
<a class="indexterm" name="id3129428"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_delete_link (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
554
<a class="indexterm" name="id3252319"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_delete_link (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
535
555
<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *link_);</pre>
537
Deletes a node of <em class="parameter"><code>list</code></em>. Returns the new list head.
557
Removes the node link_ from the list and frees it.
558
Compare this to <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-remove-link"><code class="function">g_slist_remove_link()</code></a> which removes the node
559
without freeing it.</p>
539
563
<div class="variablelist"><table border="0">
540
564
<col align="left" valign="top">
543
567
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
544
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
568
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
548
572
<td><p><span class="term"><em class="parameter"><code>link_</code></em> :</span></p></td>
553
577
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
554
<td>new head of <em class="parameter"><code>list</code></em>.
578
<td> the new head of <em class="parameter"><code>list</code></em>
563
585
<div class="refsect2" lang="en">
564
<a name="id3129527"></a><h3>
586
<a name="id3252426"></a><h3>
565
587
<a name="g-slist-remove-all"></a>g_slist_remove_all ()</h3>
566
<a class="indexterm" name="id3129540"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_remove_all (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
588
<a class="indexterm" name="id3252439"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_remove_all (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
567
589
<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);</pre>
569
Removes all list nodes with data equal to <em class="parameter"><code>data</code></em>. Returns the new
570
head of the list. Contrast with <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-remove"><code class="function">g_slist_remove()</code></a> which removes only
571
the first node matching the given data.
591
Removes all list nodes with data equal to <em class="parameter"><code>data</code></em>.
592
Returns the new head of the list. Contrast with
593
<a class="link" href="glib-Singly-Linked-Lists.html#g-slist-remove"><code class="function">g_slist_remove()</code></a> which removes only the first node
594
matching the given data.</p>
573
598
<div class="variablelist"><table border="0">
574
599
<col align="left" valign="top">
577
602
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
578
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
603
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
582
607
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
587
612
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
588
<td>new head of <em class="parameter"><code>list</code></em>.
613
<td> new head of <em class="parameter"><code>list</code></em>
597
620
<div class="refsect2" lang="en">
598
<a name="id3129651"></a><h3>
621
<a name="id3252553"></a><h3>
599
622
<a name="g-slist-free"></a>g_slist_free ()</h3>
600
<a class="indexterm" name="id3129664"></a><pre class="programlisting">void g_slist_free (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre>
623
<a class="indexterm" name="id3252566"></a><pre class="programlisting">void g_slist_free (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre>
602
625
Frees all of the memory used by a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
603
The freed elements are returned to the slice allocator.
626
The freed elements are returned to the slice allocator.</p>
605
630
<div class="variablelist"><table border="0">
606
631
<col align="left" valign="top">
608
633
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
609
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
634
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
617
640
<div class="refsect2" lang="en">
618
<a name="id3129727"></a><h3>
641
<a name="id3252632"></a><h3>
619
642
<a name="g-slist-free-1"></a>g_slist_free_1 ()</h3>
620
<a class="indexterm" name="id3129740"></a><pre class="programlisting">void g_slist_free_1 (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre>
643
<a class="indexterm" name="id3252645"></a><pre class="programlisting">void g_slist_free_1 (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre>
622
645
Frees one <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> element.
623
It is usually used after <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-remove-link"><code class="function">g_slist_remove_link()</code></a>.
646
It is usually used after <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-remove-link"><code class="function">g_slist_remove_link()</code></a>.</p>
625
650
<div class="variablelist"><table border="0">
626
651
<col align="left" valign="top">
628
653
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
629
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> element.
654
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> element
637
660
<div class="refsect2" lang="en">
638
<a name="id3129813"></a><h3>
661
<a name="id3252721"></a><h3>
639
662
<a name="g-slist-free1"></a>g_slist_free1</h3>
640
<a class="indexterm" name="id3129828"></a><pre class="programlisting">#define g_slist_free1</pre>
663
<a class="indexterm" name="id3252737"></a><pre class="programlisting">#define g_slist_free1</pre>
642
665
A macro which does the same as <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-free-1"><code class="function">g_slist_free_1()</code></a>.
650
673
<div class="refsect2" lang="en">
651
<a name="id3129862"></a><h3>
674
<a name="id3252770"></a><h3>
652
675
<a name="g-slist-length"></a>g_slist_length ()</h3>
653
<a class="indexterm" name="id3129875"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint">guint</a> g_slist_length (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre>
676
<a class="indexterm" name="id3252783"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint">guint</a> g_slist_length (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre>
655
678
Gets the number of elements in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
682
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
683
<h3 class="title">Note</h3>
685
This function iterates over the whole list to
657
692
<div class="variablelist"><table border="0">
658
693
<col align="left" valign="top">
661
696
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
662
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
697
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
666
701
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
667
<td>the number of elements in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
702
<td> the number of elements in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
676
709
<div class="refsect2" lang="en">
677
<a name="id3129956"></a><h3>
710
<a name="id3252875"></a><h3>
678
711
<a name="g-slist-copy"></a>g_slist_copy ()</h3>
679
<a class="indexterm" name="id3129968"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_copy (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre>
712
<a class="indexterm" name="id3252887"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_copy (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre>
681
714
Copies a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
684
Note that this is a "shallow" copy. If the list elements consist of pointers
685
to data, the pointers are copied but the actual data isn't.
718
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
719
<h3 class="title">Note</h3>
721
Note that this is a "shallow" copy. If the list elements
722
consist of pointers to data, the pointers are copied but
723
the actual data isn't.
687
729
<div class="variablelist"><table border="0">
688
730
<col align="left" valign="top">
691
733
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
692
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
734
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
696
738
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
697
<td>a copy of <em class="parameter"><code>list</code></em>.
739
<td> a copy of <em class="parameter"><code>list</code></em>
706
746
<div class="refsect2" lang="en">
707
<a name="id3130052"></a><h3>
747
<a name="id3252977"></a><h3>
708
748
<a name="g-slist-reverse"></a>g_slist_reverse ()</h3>
709
<a class="indexterm" name="id3130065"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_reverse (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre>
711
Reverses a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
749
<a class="indexterm" name="id3252990"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_reverse (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre>
751
Reverses a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</p>
713
755
<div class="variablelist"><table border="0">
714
756
<col align="left" valign="top">
717
759
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
718
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
760
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
722
764
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
723
<td>the start of the reversed <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
765
<td> the start of the reversed <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
732
772
<div class="refsect2" lang="en">
733
<a name="id3130145"></a><h3>
773
<a name="id3253074"></a><h3>
734
774
<a name="g-slist-insert-sorted-with-data"></a>g_slist_insert_sorted_with_data ()</h3>
735
<a class="indexterm" name="id3130158"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_insert_sorted_with_data (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
775
<a class="indexterm" name="id3253089"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_insert_sorted_with_data (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
736
776
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,
737
777
<a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> func,
738
778
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre>
740
Inserts a new element into the list, using the given comparison function
741
to determine its position.
780
Inserts a new element into the list, using the given
781
comparison function to determine its position.</p>
743
785
<div class="variablelist"><table border="0">
744
786
<col align="left" valign="top">
747
789
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
748
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
790
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
752
794
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
753
<td>the data for the new element.
795
<td> the data for the new element
757
799
<td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
758
<td>the function to compare elements in the list. It should return a
759
number > 0 if the first parameter comes after the second parameter in
800
<td> the function to compare elements in the list.
801
It should return a number > 0 if the first parameter
802
comes after the second parameter in the sort order.
764
806
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
765
<td>data to pass to comparison function.
807
<td> data to pass to comparison function
769
811
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
770
<td>the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
771
<em class="parameter"><code>Since</code></em> 2.10
812
<td> the new start of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
818
<p class="since">Since 2.10
780
822
<div class="refsect2" lang="en">
781
<a name="id3130307"></a><h3>
823
<a name="id3253248"></a><h3>
782
824
<a name="g-slist-sort"></a>g_slist_sort ()</h3>
783
<a class="indexterm" name="id3130320"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_sort (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
825
<a class="indexterm" name="id3253261"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_sort (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
784
826
<a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> compare_func);</pre>
786
Sorts a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> using the given comparison function.
828
Sorts a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> using the given comparison function.</p>
788
832
<div class="variablelist"><table border="0">
789
833
<col align="left" valign="top">
792
836
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
793
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
837
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
797
841
<td><p><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></p></td>
798
<td>the comparison function used to sort the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
799
This function is passed the data from 2 elements of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> and should
800
return 0 if they are equal, a negative value if the first element
801
comes before the second, or a positive value if the first element
802
comes after the second.
842
<td> the comparison function used to sort the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
843
This function is passed the data from 2 elements of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
844
and should return 0 if they are equal, a negative value if the
845
first element comes before the second, or a positive value if
846
the first element comes after the second.
806
850
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
807
<td>the start of the sorted <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
851
<td> the start of the sorted <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
816
858
<div class="refsect2" lang="en">
817
<a name="id3130444"></a><h3>
859
<a name="id3253388"></a><h3>
818
860
<a name="g-slist-sort-with-data"></a>g_slist_sort_with_data ()</h3>
819
<a class="indexterm" name="id3130457"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_sort_with_data (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
861
<a class="indexterm" name="id3253401"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_sort_with_data (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
820
862
<a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> compare_func,
821
863
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre>
823
Like <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-sort"><code class="function">g_slist_sort()</code></a>, but the sort function accepts a user data argument.
865
Like <a class="link" href="glib-Singly-Linked-Lists.html#g-slist-sort"><code class="function">g_slist_sort()</code></a>, but the sort function accepts a user data argument.</p>
825
869
<div class="variablelist"><table border="0">
826
870
<col align="left" valign="top">
829
873
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
830
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
874
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
834
878
<td><p><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></p></td>
835
<td>comparison function.
879
<td> comparison function
839
883
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
840
<td>data to pass to comparison function.
884
<td> data to pass to comparison function
844
888
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
845
<td>new head of the list.
889
<td> new head of the list
854
896
<div class="refsect2" lang="en">
855
<a name="id3130578"></a><h3>
897
<a name="id3253525"></a><h3>
856
898
<a name="g-slist-concat"></a>g_slist_concat ()</h3>
857
<a class="indexterm" name="id3130591"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_concat (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list1,
899
<a class="indexterm" name="id3253538"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_concat (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list1,
858
900
<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list2);</pre>
860
902
Adds the second <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> onto the end of the first <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
861
903
Note that the elements of the second <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> are not copied.
862
They are used directly.
904
They are used directly.</p>
864
908
<div class="variablelist"><table border="0">
865
909
<col align="left" valign="top">
868
912
<td><p><span class="term"><em class="parameter"><code>list1</code></em> :</span></p></td>
869
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
913
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
873
917
<td><p><span class="term"><em class="parameter"><code>list2</code></em> :</span></p></td>
874
<td>the <a class="link" href="glib-Singly-Linked-Lists.html#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"><span class="type">GSList</span></a>.
918
<td> the <a class="link" href="glib-Singly-Linked-Lists.html#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"><span class="type">GSList</span></a>
878
922
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
879
<td>the start of the new <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
923
<td> the start of the new <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
888
930
<div class="refsect2" lang="en">
889
<a name="id3130726"></a><h3>
931
<a name="id3253676"></a><h3>
890
932
<a name="g-slist-foreach"></a>g_slist_foreach ()</h3>
891
<a class="indexterm" name="id3130739"></a><pre class="programlisting">void g_slist_foreach (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
933
<a class="indexterm" name="id3253689"></a><pre class="programlisting">void g_slist_foreach (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
892
934
<a class="link" href="glib-Doubly-Linked-Lists.html#GFunc">GFunc</a> func,
893
935
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre>
895
Calls a function for each element of a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
937
Calls a function for each element of a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</p>
897
941
<div class="variablelist"><table border="0">
898
942
<col align="left" valign="top">
901
945
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
902
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
946
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
906
950
<td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
907
<td>the function to call with each element's data.
951
<td> the function to call with each element's data
911
955
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
912
<td>user data to pass to the function.
956
<td> user data to pass to the function
921
963
<div class="refsect2" lang="en">
922
<a name="id3130846"></a><h3>
964
<a name="id3253799"></a><h3>
923
965
<a name="g-slist-last"></a>g_slist_last ()</h3>
924
<a class="indexterm" name="id3130858"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_last (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre>
966
<a class="indexterm" name="id3253811"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_last (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list);</pre>
926
968
Gets the last element in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
971
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
972
<h3 class="title">Note</h3>
974
This function iterates over the whole list.
928
980
<div class="variablelist"><table border="0">
929
981
<col align="left" valign="top">
932
984
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
933
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
985
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
937
989
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
938
<td>the last element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> has no
990
<td> the last element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>,
991
or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> has no elements
974
1024
<div class="refsect2" lang="en">
975
<a name="id3131041"></a><h3>
1025
<a name="id3254002"></a><h3>
976
1026
<a name="g-slist-nth"></a>g_slist_nth ()</h3>
977
<a class="indexterm" name="id3131054"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_nth (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
1027
<a class="indexterm" name="id3254014"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_nth (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
978
1028
<a class="link" href="glib-Basic-Types.html#guint">guint</a> n);</pre>
980
Gets the element at the given position in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
1030
Gets the element at the given position in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.</p>
982
1034
<div class="variablelist"><table border="0">
983
1035
<col align="left" valign="top">
986
1038
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
987
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
1039
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
991
1043
<td><p><span class="term"><em class="parameter"><code>n</code></em> :</span></p></td>
992
<td>the position of the element, counting from 0.
1044
<td> the position of the element, counting from 0
996
1048
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
997
<td>the element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the position is off the end of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
1049
<td> the element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the position is off
1050
the end of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
1006
1057
<div class="refsect2" lang="en">
1007
<a name="id3131167"></a><h3>
1058
<a name="id3254131"></a><h3>
1008
1059
<a name="g-slist-nth-data"></a>g_slist_nth_data ()</h3>
1009
<a class="indexterm" name="id3131180"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_slist_nth_data (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
1060
<a class="indexterm" name="id3254144"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_slist_nth_data (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
1010
1061
<a class="link" href="glib-Basic-Types.html#guint">guint</a> n);</pre>
1012
Gets the data of the element at the given position.
1063
Gets the data of the element at the given position.</p>
1014
1067
<div class="variablelist"><table border="0">
1015
1068
<col align="left" valign="top">
1018
1071
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
1019
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
1072
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
1023
1076
<td><p><span class="term"><em class="parameter"><code>n</code></em> :</span></p></td>
1024
<td>the position of the element.
1077
<td> the position of the element
1028
1081
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1029
<td>the element's data, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the position is off the end of the
1030
<a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
1082
<td> the element's data, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if the position
1083
is off the end of the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
1039
1090
<div class="refsect2" lang="en">
1040
<a name="id3131286"></a><h3>
1091
<a name="id3254253"></a><h3>
1041
1092
<a name="g-slist-find"></a>g_slist_find ()</h3>
1042
<a class="indexterm" name="id3131299"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_find (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
1093
<a class="indexterm" name="id3254266"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_find (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
1043
1094
<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);</pre>
1045
Finds the element in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> which contains the given data.
1096
Finds the element in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> which
1097
contains the given data.</p>
1047
1101
<div class="variablelist"><table border="0">
1048
1102
<col align="left" valign="top">
1051
1105
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
1052
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
1106
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
1056
1110
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1057
<td>the element data to find.
1111
<td> the element data to find
1061
1115
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1062
<td>the found <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if it is not found.
1116
<td> the found <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> element,
1117
or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if it is not found
1071
1124
<div class="refsect2" lang="en">
1072
<a name="id3131413"></a><h3>
1125
<a name="id3254383"></a><h3>
1073
1126
<a name="g-slist-find-custom"></a>g_slist_find_custom ()</h3>
1074
<a class="indexterm" name="id3131426"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_find_custom (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
1127
<a class="indexterm" name="id3254396"></a><pre class="programlisting"><a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a>* g_slist_find_custom (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
1075
1128
<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data,
1076
1129
<a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> func);</pre>
1078
Finds an element in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>, using a supplied function to find the desired
1080
It iterates over the list, calling the given function which should return 0
1081
when the desired element is found.
1082
The function takes two <a class="link" href="glib-Basic-Types.html#gconstpointer"><span class="type">gconstpointer</span></a> arguments, the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> element's data as
1083
the first argument and the given user data.
1131
Finds an element in a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>, using a supplied function to
1132
find the desired element. It iterates over the list, calling
1133
the given function which should return 0 when the desired
1134
element is found. The function takes two <a class="link" href="glib-Basic-Types.html#gconstpointer"><span class="type">gconstpointer</span></a> arguments,
1135
the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> element's data as the first argument and the
1136
given user data.</p>
1085
1140
<div class="variablelist"><table border="0">
1086
1141
<col align="left" valign="top">
1089
1144
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
1090
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
1145
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
1094
1149
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1095
<td>user data passed to the function.
1150
<td> user data passed to the function
1099
1154
<td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td>
1100
<td>the function to call for each element. It should return 0 when the
1101
desired element is found.
1155
<td> the function to call for each element.
1156
It should return 0 when the desired element is found
1105
1160
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1106
<td>the found <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if it is not found.
1161
<td> the found <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> element, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if it is not found
1115
1168
<div class="refsect2" lang="en">
1116
<a name="id3131584"></a><h3>
1169
<a name="id3254557"></a><h3>
1117
1170
<a name="g-slist-position"></a>g_slist_position ()</h3>
1118
<a class="indexterm" name="id3131597"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint">gint</a> g_slist_position (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
1171
<a class="indexterm" name="id3254570"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint">gint</a> g_slist_position (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
1119
1172
<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *llink);</pre>
1121
Gets the position of the given element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> (starting from 0).
1174
Gets the position of the given element
1175
in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a> (starting from 0).</p>
1123
1179
<div class="variablelist"><table border="0">
1124
1180
<col align="left" valign="top">
1127
1183
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
1128
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
1184
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
1132
1188
<td><p><span class="term"><em class="parameter"><code>llink</code></em> :</span></p></td>
1133
<td>an element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
1189
<td> an element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
1137
1193
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1138
<td>the position of the element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>, or -1 if the element
1194
<td> the position of the element in the <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>,
1195
or -1 if the element is not found
1148
1202
<div class="refsect2" lang="en">
1149
<a name="id3131709"></a><h3>
1203
<a name="id3254685"></a><h3>
1150
1204
<a name="g-slist-index"></a>g_slist_index ()</h3>
1151
<a class="indexterm" name="id3131722"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint">gint</a> g_slist_index (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
1205
<a class="indexterm" name="id3254698"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint">gint</a> g_slist_index (<a class="link" href="glib-Singly-Linked-Lists.html#GSList">GSList</a> *list,
1152
1206
<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);</pre>
1154
Gets the position of the element containing the given data (starting from 0).
1208
Gets the position of the element containing
1209
the given data (starting from 0).</p>
1156
1213
<div class="variablelist"><table border="0">
1157
1214
<col align="left" valign="top">
1160
1217
<td><p><span class="term"><em class="parameter"><code>list</code></em> :</span></p></td>
1161
<td>a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>.
1218
<td> a <a class="link" href="glib-Singly-Linked-Lists.html#GSList"><span class="type">GSList</span></a>
1165
1222
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
1166
<td>the data to find.
1223
<td> the data to find
1170
1227
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1171
<td>the index of the element containing the data, or -1 if the data
1228
<td> the index of the element containing the data,
1229
or -1 if the data is not found