glib-Doubly-Linked-Lists.html   [plain text]


<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Doubly-Linked Lists</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="GLib Reference Manual"><link rel="up" href="glib-data-types.html" title="GLib Data Types"><link rel="previous" href="glib-Memory-Chunks.html" title="Memory Chunks"><link rel="next" href="glib-Singly-Linked-Lists.html" title="Singly-Linked Lists"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="refentry" href="glib-building.html" title="Compiling the GLib package"><link rel="refentry" href="glib-cross-compiling.html" title="Cross-compiling the GLib package"><link rel="refentry" href="glib-compiling.html" title="Compiling GLib Applications"><link rel="refentry" href="glib-running.html" title="Running GLib Applications"><link rel="refentry" href="glib-changes.html" title="Changes to GLib"><link rel="refentry" href="glib-resources.html" title="Mailing lists and bug reports"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="refentry" href="glib-Basic-Types.html" title="Basic Types"><link rel="refentry" href="glib-Limits-of-Basic-Types.html" title="Limits of Basic Types"><link rel="refentry" href="glib-Standard-Macros.html" title="Standard Macros"><link rel="refentry" href="glib-Type-Conversion-Macros.html" title="Type Conversion Macros"><link rel="refentry" href="glib-Byte-Order-Macros.html" title="Byte Order Macros"><link rel="refentry" href="glib-Numerical-Definitions.html" title="Numerical Definitions"><link rel="refentry" href="glib-Miscellaneous-Macros.html" title="Miscellaneous Macros"><link rel="refentry" href="glib-Atomic-Operations.html" title="Atomic Operations"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="refentry" href="glib-The-Main-Event-Loop.html" title="The Main Event Loop"><link rel="refentry" href="glib-Threads.html" title="
Threads"><link rel="refentry" href="glib-Thread-Pools.html" title="Thread Pools"><link rel="refentry" href="glib-Asynchronous-Queues.html" title="Asynchronous Queues"><link rel="refentry" href="glib-Dynamic-Loading-of-Modules.html" title="Dynamic Loading of Modules"><link rel="refentry" href="glib-Memory-Allocation.html" title="Memory Allocation"><link rel="refentry" href="glib-IO-Channels.html" title="IO Channels"><link rel="refentry" href="glib-Error-Reporting.html" title="Error Reporting"><link rel="refentry" href="glib-Warnings-and-Assertions.html" title="Message Output and Debugging Functions"><link rel="refentry" href="glib-Message-Logging.html" title="Message Logging"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="refentry" href="glib-String-Utility-Functions.html" title="String Utility Functions"><link rel="refentry" href="glib-Character-Set-Conversion.html" title="Character Set Conversion"><link rel="refentry" href="glib-Unicode-Manipulation.html" title="Unicode Manipulation"><link rel="refentry" href="glib-I18N.html" title="Internationalization"><link rel="refentry" href="glib-Date-and-Time-Functions.html" title="Date and Time Functions"><link rel="refentry" href="glib-Random-Numbers.html" title="Random Numbers"><link rel="refentry" href="glib-Hook-Functions.html" title="Hook Functions"><link rel="refentry" href="glib-Miscellaneous-Utility-Functions.html" title="Miscellaneous Utility Functions"><link rel="refentry" href="glib-Lexical-Scanner.html" title="Lexical Scanner"><link rel="refentry" href="glib-Automatic-String-Completion.html" title="Automatic String Completion"><link rel="refentry" href="glib-Timers.html" title="Timers"><link rel="refentry" href="glib-Spawning-Processes.html" title="Spawning Processes"><link rel="refentry" href="glib-File-Utilities.html" title="File Utilities"><link rel="refentry" href="glib-Shell-related-Utilities.html" title="Shell-related Utilities"><link rel="refentry" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching"><link rel="refentry" href="glib-Simple-XML-Subset-Parser.html" title="Simple XML Subset Parser"><link rel="refentry" href="glib-Windows-Compatability-Functions.html" title="Windows Compatibility Functions"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="refentry" href="glib-Memory-Chunks.html" title="Memory Chunks"><link rel="refentry" href="glib-Doubly-Linked-Lists.html" title="Doubly-Linked Lists"><link rel="refentry" href="glib-Singly-Linked-Lists.html" title="Singly-Linked Lists"><link rel="refentry" href="glib-Double-ended-Queues.html" title="Double-ended Queues"><link rel="refentry" href="glib-Trash-Stacks.html" title="Trash Stacks"><link rel="refentry" href="glib-Hash-Tables.html" title="Hash Tables"><link rel="refentry" href="glib-Strings.html" title="Strings"><link rel="refentry" href="glib-String-Chunks.html" title="String Chunks"><link rel="refentry" href="glib-Arrays.html" title="Arrays"><link rel="refentry" href="glib-Pointer-Arrays.html" title="Pointer Arrays"><link rel="refentry" href="glib-Byte-Arrays.html" title="Byte Arrays"><link rel="refentry" href="glib-Balanced-Binary-Trees.html" title="Balanced Binary Trees"><link rel="refentry" href="glib-N-ary-Trees.html" title="N-ary Trees"><link rel="refentry" href="glib-Quarks.html" title="Quarks"><link rel="refentry" href="glib-Keyed-Data-Lists.html" title="Keyed Data Lists"><link rel="refentry" href="glib-Datasets.html" title="Datasets"><link rel="refentry" href="glib-Relations-and-Tuples.html" title="Relations and Tuples"><link rel="refentry" href="glib-Caches.html" title="Caches"><link rel="refentry" href="glib-Memory-Allocators.html" title="Memory Allocators"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="refentry" href="glib-gettextize.html" title="glib-gettextize"><link rel="index" href="ix01.html" title="Index"><link rel="section" href="glib-Doubly-Linked-Lists.html#id3235937" title="Description"><link rel="section" href="glib-Doubly-Linked-Lists.html#id3236248" title="Details"><meta name="generator" content="GTK-Doc V1.2 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="glib-Memory-Chunks.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="glib-data-types.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GLib Reference Manual</th><td><a accesskey="n" href="glib-Singly-Linked-Lists.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="glib-Doubly-Linked-Lists"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2><span class="refentrytitle">Doubly-Linked Lists</span></h2><p>Doubly-Linked Lists &#8212; linked lists containing integer values or pointers to data, with the ability
to iterate over the list in both directions.</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">

#include &lt;glib.h&gt;


struct      <a href="glib-Doubly-Linked-Lists.html#GList">GList</a>;

<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-append">g_list_append</a>                   (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-prepend">g_list_prepend</a>                  (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-insert">g_list_insert</a>                   (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data,
                                             <a href="glib-Basic-Types.html#gint">gint</a> position);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-insert-before">g_list_insert_before</a>            (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *sibling,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-insert-sorted">g_list_insert_sorted</a>            (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data,
                                             <a href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> func);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-remove">g_list_remove</a>                   (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-remove-link">g_list_remove_link</a>              (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *llink);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-delete-link">g_list_delete_link</a>              (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *link_);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-remove-all">g_list_remove_all</a>               (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);
void        <a href="glib-Doubly-Linked-Lists.html#g-list-free">g_list_free</a>                     (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);

<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-alloc">g_list_alloc</a>                    (void);
void        <a href="glib-Doubly-Linked-Lists.html#g-list-free-1">g_list_free_1</a>                   (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);

<a href="glib-Basic-Types.html#guint">guint</a>       <a href="glib-Doubly-Linked-Lists.html#g-list-length">g_list_length</a>                   (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-copy">g_list_copy</a>                     (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-reverse">g_list_reverse</a>                  (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-sort">g_list_sort</a>                     (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> compare_func);
<a href="glib-Basic-Types.html#gint">gint</a>        (<a href="glib-Doubly-Linked-Lists.html#GCompareFunc">*GCompareFunc</a>)                 (<a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> a,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> b);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-sort-with-data">g_list_sort_with_data</a>           (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> compare_func,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);
<a href="glib-Basic-Types.html#gint">gint</a>        (<a href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">*GCompareDataFunc</a>)             (<a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> a,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> b,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-concat">g_list_concat</a>                   (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list1,
                                             <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list2);
void        <a href="glib-Doubly-Linked-Lists.html#g-list-foreach">g_list_foreach</a>                  (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GFunc">GFunc</a> func,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);
void        (<a href="glib-Doubly-Linked-Lists.html#GFunc">*GFunc</a>)                        (<a href="glib-Basic-Types.html#gpointer">gpointer</a> data,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);

<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-first">g_list_first</a>                    (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-last">g_list_last</a>                     (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);
#define     <a href="glib-Doubly-Linked-Lists.html#g-list-previous">g_list_previous</a>                 (list)
#define     <a href="glib-Doubly-Linked-Lists.html#g-list-next">g_list_next</a>                     (list)
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-nth">g_list_nth</a>                      (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#guint">guint</a> n);
<a href="glib-Basic-Types.html#gpointer">gpointer</a>    <a href="glib-Doubly-Linked-Lists.html#g-list-nth-data">g_list_nth_data</a>                 (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#guint">guint</a> n);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-nth-prev">g_list_nth_prev</a>                 (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#guint">guint</a> n);

<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-find">g_list_find</a>                     (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);
<a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      <a href="glib-Doubly-Linked-Lists.html#g-list-find-custom">g_list_find_custom</a>              (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data,
                                             <a href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> func);
<a href="glib-Basic-Types.html#gint">gint</a>        <a href="glib-Doubly-Linked-Lists.html#g-list-position">g_list_position</a>                 (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *llink);
<a href="glib-Basic-Types.html#gint">gint</a>        <a href="glib-Doubly-Linked-Lists.html#g-list-index">g_list_index</a>                    (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);

void        <a href="glib-Doubly-Linked-Lists.html#g-list-push-allocator">g_list_push_allocator</a>           (<a href="glib-Memory-Allocators.html#GAllocator">GAllocator</a> *allocator);
void        <a href="glib-Doubly-Linked-Lists.html#g-list-pop-allocator">g_list_pop_allocator</a>            (void);
</pre></div><div class="refsect1" lang="en"><a name="id3235937"></a><h2>Description</h2><p>
The <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> structure and its associated functions provide a standard
doubly-linked list data structure.
</p><p>
Each element in the list contains a piece of data, together with pointers
which link to the previous and next elements in the list.
Using these pointers it is possible to move through the list in both
directions (unlike the
Singly-Linked Lists
which only allows movement through the list in the forward direction).
</p><p>
The data contained in each element can be either integer values, by using one
of the
<a href="glib-Type-Conversion-Macros.html" title="Type Conversion Macros">Type Conversion Macros</a>,
or simply pointers to any type of data.
</p><p>
List elements are allocated in blocks using a <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>, which is
more efficient than allocating elements individually.
</p><p>
Note that most of the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> functions expect to be passed a pointer to
the first element in the list. The functions which insert elements return
the new start of the list, which may have changed.
</p><p>
There is no function to create a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>. <tt class="literal">NULL</tt> is considered to be the empty
list so you simply set a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>* to <tt class="literal">NULL</tt>.
</p><p>
To add elements, use <a href="glib-Doubly-Linked-Lists.html#g-list-append"><tt class="function">g_list_append()</tt></a>, <a href="glib-Doubly-Linked-Lists.html#g-list-prepend"><tt class="function">g_list_prepend()</tt></a>, <a href="glib-Doubly-Linked-Lists.html#g-list-insert"><tt class="function">g_list_insert()</tt></a>
and <a href="glib-Doubly-Linked-Lists.html#g-list-insert-sorted"><tt class="function">g_list_insert_sorted()</tt></a>.
</p><p>
To remove elements, use <a href="glib-Doubly-Linked-Lists.html#g-list-remove"><tt class="function">g_list_remove()</tt></a>.
</p><p>
To find elements in the list use <a href="glib-Doubly-Linked-Lists.html#g-list-first"><tt class="function">g_list_first()</tt></a>, <a href="glib-Doubly-Linked-Lists.html#g-list-last"><tt class="function">g_list_last()</tt></a>, <a href="glib-Doubly-Linked-Lists.html#g-list-next"><tt class="function">g_list_next()</tt></a>,
<a href="glib-Doubly-Linked-Lists.html#g-list-previous"><tt class="function">g_list_previous()</tt></a>, <a href="glib-Doubly-Linked-Lists.html#g-list-nth"><tt class="function">g_list_nth()</tt></a>, <a href="glib-Doubly-Linked-Lists.html#g-list-nth-data"><tt class="function">g_list_nth_data()</tt></a>, <a href="glib-Doubly-Linked-Lists.html#g-list-find"><tt class="function">g_list_find()</tt></a> and
<a href="glib-Doubly-Linked-Lists.html#g-list-find-custom"><tt class="function">g_list_find_custom()</tt></a>.
</p><p>
To find the index of an element use <a href="glib-Doubly-Linked-Lists.html#g-list-position"><tt class="function">g_list_position()</tt></a> and <a href="glib-Doubly-Linked-Lists.html#g-list-index"><tt class="function">g_list_index()</tt></a>.
</p><p>
To call a function for each element in the list use <a href="glib-Doubly-Linked-Lists.html#g-list-foreach"><tt class="function">g_list_foreach()</tt></a>.
</p><p>
To free the entire list, use <a href="glib-Doubly-Linked-Lists.html#g-list-free"><tt class="function">g_list_free()</tt></a>.
</p></div><div class="refsect1" lang="en"><a name="id3236248"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3236254"></a><h3><a name="GList"></a>struct GList</h3><a class="indexterm" name="id3236264"></a><pre class="programlisting">struct GList {

  gpointer data;
  GList *next;
  GList *prev;
};
</pre><p>
The <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> struct is used for each element in a doubly-linked list.
The <i class="structfield"><tt>data</tt></i> field holds the element's data, which can
be a pointer to any kind of data, or any integer value using the
<a href="glib-Type-Conversion-Macros.html" title="Type Conversion Macros">Type Conversion Macros</a>.
The <i class="structfield"><tt>next</tt></i> and <i class="structfield"><tt>prev</tt></i>
pointers are the links to the next and previous elements in the list.
</p></div><hr><div class="refsect2" lang="en"><a name="id3236311"></a><h3><a name="g-list-append"></a>g_list_append ()</h3><a class="indexterm" name="id3236322"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_append                   (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre><p>
Adds a new element on to the end of the list.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
The return value is the new start of the list, which may have changed, so
make sure you store the new value.
</p></div><div class="informalexample"><pre class="programlisting">
  /* Notice that these are initialized to the empty list. */
  GList *list = NULL, *number_list = NULL;

  /* This is a list of strings. */
  list = g_list_append (list, "first");
  list = g_list_append (list, "second");

  /* This is a list of integers. */
  number_list = g_list_append (number_list, GINT_TO_POINTER (27));
  number_list = g_list_append (number_list, GINT_TO_POINTER (14));
</pre></div><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a pointer to a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>the data for the new element.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new start of the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3236439"></a><h3><a name="g-list-prepend"></a>g_list_prepend ()</h3><a class="indexterm" name="id3236449"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_prepend                  (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre><p>
Adds a new element on to the start of the list.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
The return value is the new start of the list, which may have changed, so
make sure you store the new value.
</p></div><div class="informalexample"><pre class="programlisting">
  /* Notice that it is initialized to the empty list. */
  GList *list = NULL;
  list = g_list_prepend (list, "last");
  list = g_list_prepend (list, "first");
</pre></div><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a pointer to a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>the data for the new element.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new start of the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3236562"></a><h3><a name="g-list-insert"></a>g_list_insert ()</h3><a class="indexterm" name="id3236573"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_insert                   (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data,
                                             <a href="glib-Basic-Types.html#gint">gint</a> position);</pre><p>
Inserts a new element into the list at the given position.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a pointer to a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>the data for the new element.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>position</tt></i> :</span></td><td>the position to insert the element. If this is negative, or is
larger than the number of elements in the list, the new element is added on
to the end of the list.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new start of the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3236692"></a><h3><a name="g-list-insert-before"></a>g_list_insert_before ()</h3><a class="indexterm" name="id3236704"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_insert_before            (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *sibling,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre><p>
Inserts a new element into the list before the given position.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a pointer to a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>sibling</tt></i> :</span></td><td>the list element before which the new element is inserted
  or <tt class="literal">NULL</tt> to insert at the end of the list.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>the data for the new element.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new start of the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3236828"></a><h3><a name="g-list-insert-sorted"></a>g_list_insert_sorted ()</h3><a class="indexterm" name="id3236840"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_insert_sorted            (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data,
                                             <a href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> func);</pre><p>
Inserts a new element into the list, using the given comparison function
to determine its position.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a pointer to a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>the data for the new element.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>func</tt></i> :</span></td><td>the function to compare elements in the list. It should return a
number &gt; 0 if the first parameter comes after the second parameter in
the sort order.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new start of the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3236960"></a><h3><a name="g-list-remove"></a>g_list_remove ()</h3><a class="indexterm" name="id3236971"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_remove                   (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);</pre><p>
Removes an element from a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
If two elements contain the same data, only the first is removed.
If none of the elements contain the data, the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> is unchanged.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>the data of the element to remove.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new start of the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3237083"></a><h3><a name="g-list-remove-link"></a>g_list_remove_link ()</h3><a class="indexterm" name="id3237094"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_remove_link              (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *llink);</pre><p>
Removes an element from a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>, without freeing the element.
The removed element's prev and next links are set to <tt class="literal">NULL</tt>, so that it becomes a
self-contained list with one element.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>llink</tt></i> :</span></td><td>an element in the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new start of the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>, without the element.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3237212"></a><h3><a name="g-list-delete-link"></a>g_list_delete_link ()</h3><a class="indexterm" name="id3237223"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_delete_link              (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *link_);</pre><p>
Deletes the node <i class="parameter"><tt>link_</tt></i> from <i class="parameter"><tt>list</tt></i>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>link_</tt></i> :</span></td><td>node to delete from <i class="parameter"><tt>list</tt></i>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new head of <i class="parameter"><tt>list</tt></i>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3237332"></a><h3><a name="g-list-remove-all"></a>g_list_remove_all ()</h3><a class="indexterm" name="id3237344"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_remove_all               (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);</pre><p>
Removes all list nodes with data equal to <i class="parameter"><tt>data</tt></i>. Returns the new
head of the list. Contrast with <a href="glib-Doubly-Linked-Lists.html#g-list-remove"><tt class="function">g_list_remove()</tt></a> which removes only 
the first node matching the given data.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>data to remove.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>new head of <i class="parameter"><tt>list</tt></i>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3237454"></a><h3><a name="g-list-free"></a>g_list_free ()</h3><a class="indexterm" name="id3237465"></a><pre class="programlisting">void        g_list_free                     (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>
Frees all of the memory used by a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
The freed elements are added to the <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a> free list.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
If list elements contain dynamically-allocated memory, they should be freed
first.
</p></div><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3237544"></a><h3><a name="g-list-alloc"></a>g_list_alloc ()</h3><a class="indexterm" name="id3237554"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_alloc                    (void);</pre><p>
Allocates space for one <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> element.
It is called by <a href="glib-Doubly-Linked-Lists.html#g-list-append"><tt class="function">g_list_append()</tt></a>, <a href="glib-Doubly-Linked-Lists.html#g-list-prepend"><tt class="function">g_list_prepend()</tt></a>, <a href="glib-Doubly-Linked-Lists.html#g-list-insert"><tt class="function">g_list_insert()</tt></a> and
<a href="glib-Doubly-Linked-Lists.html#g-list-insert-sorted"><tt class="function">g_list_insert_sorted()</tt></a> and so is rarely used on its own.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>a pointer to the newly-allocated <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> element.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3237650"></a><h3><a name="g-list-free-1"></a>g_list_free_1 ()</h3><a class="indexterm" name="id3237661"></a><pre class="programlisting">void        g_list_free_1                   (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>
Frees one <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> element.
It is usually used after <a href="glib-Doubly-Linked-Lists.html#g-list-remove-link"><tt class="function">g_list_remove_link()</tt></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> element.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3237735"></a><h3><a name="g-list-length"></a>g_list_length ()</h3><a class="indexterm" name="id3237745"></a><pre class="programlisting"><a href="glib-Basic-Types.html#guint">guint</a>       g_list_length                   (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>
Gets the number of elements in a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the number of elements in the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3237826"></a><h3><a name="g-list-copy"></a>g_list_copy ()</h3><a class="indexterm" name="id3237837"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_copy                     (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>
Copies a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</p><p>
Note that this is a "shallow" copy. If the list elements consist of pointers
to data, the pointers are copied but the actual data isn't.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>a copy of <i class="parameter"><tt>list</tt></i>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3237920"></a><h3><a name="g-list-reverse"></a>g_list_reverse ()</h3><a class="indexterm" name="id3237930"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_reverse                  (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>
Reverses a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
It simply switches the next and prev pointers of each element.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the start of the reversed <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3238011"></a><h3><a name="g-list-sort"></a>g_list_sort ()</h3><a class="indexterm" name="id3238022"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_sort                     (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> compare_func);</pre><p>
Sorts a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> using the given comparison function.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>compare_func</tt></i> :</span></td><td>the comparison function used to sort the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>. This function
is passed 2 elements of the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> and should return 0 if they are equal,
a negative value if the first element comes before the second, or a positive
value if the first element comes after the second.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the start of the sorted <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3238145"></a><h3><a name="GCompareFunc"></a>GCompareFunc ()</h3><a class="indexterm" name="id3238155"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a>        (*GCompareFunc)                 (<a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> a,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> b);</pre><p>
Specifies the type of a comparison function used to compare two
values.  The function should return a negative integer if the first
value comes before the second, 0 if they are equal, or a positive
integer if the first value comes after the second.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>a</tt></i> :</span></td><td>a value.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>b</tt></i> :</span></td><td>a value to compare with.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>negative value if <i class="parameter"><tt>a</tt></i> &lt; <i class="parameter"><tt>b</tt></i>; zero if <i class="parameter"><tt>a</tt></i> = <i class="parameter"><tt>b</tt></i>; positive value
if <i class="parameter"><tt>a</tt></i> &gt; <i class="parameter"><tt>b</tt></i>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3238272"></a><h3><a name="g-list-sort-with-data"></a>g_list_sort_with_data ()</h3><a class="indexterm" name="id3238284"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_sort_with_data           (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> compare_func,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>
Like <a href="glib-Doubly-Linked-Lists.html#g-list-sort"><tt class="function">g_list_sort()</tt></a>, but the comparison function accepts a user data argument.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>compare_func</tt></i> :</span></td><td>comparison function.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_data</tt></i> :</span></td><td>user data to pass to comparison function.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new head of <i class="parameter"><tt>list</tt></i>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3238410"></a><h3><a name="GCompareDataFunc"></a>GCompareDataFunc ()</h3><a class="indexterm" name="id3238420"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a>        (*GCompareDataFunc)             (<a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> a,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> b,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>
Specifies the type of a comparison function used to compare two
values.  The function should return a negative integer if the first
value comes before the second, 0 if they are equal, or a positive
integer if the first value comes after the second.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>a</tt></i> :</span></td><td>a value.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>b</tt></i> :</span></td><td>a value to compare with.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_data</tt></i> :</span></td><td>user data to pass to comparison function.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>negative value if <i class="parameter"><tt>a</tt></i> &lt; <i class="parameter"><tt>b</tt></i>; zero if <i class="parameter"><tt>a</tt></i> = <i class="parameter"><tt>b</tt></i>; positive value
if <i class="parameter"><tt>a</tt></i> &gt; <i class="parameter"><tt>b</tt></i>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3238559"></a><h3><a name="g-list-concat"></a>g_list_concat ()</h3><a class="indexterm" name="id3238569"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_concat                   (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list1,
                                             <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list2);</pre><p>
Adds the second <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> onto the end of the first <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
Note that the elements of the second <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> are not copied.
They are used directly.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list1</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>list2</tt></i> :</span></td><td>the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> to add to the end of the first <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the start of the new <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3238705"></a><h3><a name="g-list-foreach"></a>g_list_foreach ()</h3><a class="indexterm" name="id3238716"></a><pre class="programlisting">void        g_list_foreach                  (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GFunc">GFunc</a> func,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>
Calls a function for each element of a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>func</tt></i> :</span></td><td>the function to call with each element's data.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_data</tt></i> :</span></td><td>user data to pass to the function.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3238822"></a><h3><a name="GFunc"></a>GFunc ()</h3><a class="indexterm" name="id3238832"></a><pre class="programlisting">void        (*GFunc)                        (<a href="glib-Basic-Types.html#gpointer">gpointer</a> data,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>
Specifies the type of functions passed to <a href="glib-Doubly-Linked-Lists.html#g-list-foreach"><tt class="function">g_list_foreach()</tt></a> and
<a href="glib-Singly-Linked-Lists.html#g-slist-foreach"><tt class="function">g_slist_foreach()</tt></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>the element's data.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>user_data</tt></i> :</span></td><td>user data passed to <a href="glib-Doubly-Linked-Lists.html#g-list-foreach"><tt class="function">g_list_foreach()</tt></a> or <a href="glib-Singly-Linked-Lists.html#g-slist-foreach"><tt class="function">g_slist_foreach()</tt></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3238945"></a><h3><a name="g-list-first"></a>g_list_first ()</h3><a class="indexterm" name="id3238956"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_first                    (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>
Gets the first element in a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the first element in a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>, or <tt class="literal">NULL</tt> if the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> has no elements.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3239051"></a><h3><a name="g-list-last"></a>g_list_last ()</h3><a class="indexterm" name="id3239061"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_last                     (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list);</pre><p>
Gets the last element in a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the last element in the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>, or <tt class="literal">NULL</tt> if the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> has no
elements.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3239155"></a><h3><a name="g-list-previous"></a>g_list_previous()</h3><a class="indexterm" name="id3239166"></a><pre class="programlisting">#define     g_list_previous(list)</pre><p>
A convenience macro to gets the previous element in a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>an element in a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the previous element, or <tt class="literal">NULL</tt> if there are no previous elements.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3239233"></a><h3><a name="g-list-next"></a>g_list_next()</h3><a class="indexterm" name="id3239243"></a><pre class="programlisting">#define     g_list_next(list)</pre><p>
A convenience macro to gets the next element in a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>an element in a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the next element, or <tt class="literal">NULL</tt> if there are no more elements.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3239310"></a><h3><a name="g-list-nth"></a>g_list_nth ()</h3><a class="indexterm" name="id3239320"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_nth                      (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#guint">guint</a> n);</pre><p>
Gets the element at the given position in a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>n</tt></i> :</span></td><td>the position of the element, counting from 0.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the element, or <tt class="literal">NULL</tt> if the position is off the end of the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3239429"></a><h3><a name="g-list-nth-data"></a>g_list_nth_data ()</h3><a class="indexterm" name="id3239440"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gpointer">gpointer</a>    g_list_nth_data                 (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#guint">guint</a> n);</pre><p>
Gets the data of the element at the given position.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>n</tt></i> :</span></td><td>the position of the element.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the element's data, or <tt class="literal">NULL</tt> if the position is off the end of the
<a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3239541"></a><h3><a name="g-list-nth-prev"></a>g_list_nth_prev ()</h3><a class="indexterm" name="id3239552"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_nth_prev                 (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#guint">guint</a> n);</pre><p>
Gets the element <i class="parameter"><tt>n</tt></i> places before <i class="parameter"><tt>list</tt></i>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>n</tt></i> :</span></td><td>the position of the element, counting from 0.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the element, or <tt class="literal">NULL</tt> if the position is off the end of the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3239664"></a><h3><a name="g-list-find"></a>g_list_find ()</h3><a class="indexterm" name="id3239675"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_find                     (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);</pre><p>
Finds the element in a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> which contains the given data.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>the element data to find.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the found <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> element, or <tt class="literal">NULL</tt> if it is not found.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3239784"></a><h3><a name="g-list-find-custom"></a>g_list_find_custom ()</h3><a class="indexterm" name="id3239795"></a><pre class="programlisting"><a href="glib-Doubly-Linked-Lists.html#GList">GList</a>*      g_list_find_custom              (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data,
                                             <a href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> func);</pre><p>
Finds an element in a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>, using a supplied function to find the desired
element.
It iterates over the list, calling the given function which should return 0
when the desired element is found.
The function takes two <a href="glib-Basic-Types.html#gconstpointer"><span class="type">gconstpointer</span></a> arguments, the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> element's data
and the given user data.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>user data passed to the function.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>func</tt></i> :</span></td><td>the function to call for each element. It should return 0 when the
desired element is found.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the found <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> element, or <tt class="literal">NULL</tt> if it is not found.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3239947"></a><h3><a name="g-list-position"></a>g_list_position ()</h3><a class="indexterm" name="id3239957"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a>        g_list_position                 (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *llink);</pre><p>
Gets the position of the given element in the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> (starting from 0).
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>llink</tt></i> :</span></td><td>an element in the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the position of the element in the <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>, or -1 if the element is
not found.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3240068"></a><h3><a name="g-list-index"></a>g_list_index ()</h3><a class="indexterm" name="id3240079"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a>        g_list_index                    (<a href="glib-Doubly-Linked-Lists.html#GList">GList</a> *list,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> data);</pre><p>
Gets the position of the element containing the given data (starting from 0).
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>list</tt></i> :</span></td><td>a <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>the data to find.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the index of the element containing the data, or -1 if the data
is not found.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3240167"></a><h3><a name="g-list-push-allocator"></a>g_list_push_allocator ()</h3><a class="indexterm" name="id3240178"></a><pre class="programlisting">void        g_list_push_allocator           (<a href="glib-Memory-Allocators.html#GAllocator">GAllocator</a> *allocator);</pre><p>
Sets the allocator to use to allocate <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> elements.
Use <a href="glib-Doubly-Linked-Lists.html#g-list-pop-allocator"><tt class="function">g_list_pop_allocator()</tt></a> to restore the previous allocator.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>allocator</tt></i> :</span></td><td>the <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a> to use when allocating <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> elements.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3240262"></a><h3><a name="g-list-pop-allocator"></a>g_list_pop_allocator ()</h3><a class="indexterm" name="id3240273"></a><pre class="programlisting">void        g_list_pop_allocator            (void);</pre><p>
Restores the previous <a href="glib-Memory-Allocators.html#GAllocator"><span class="type">GAllocator</span></a>, used when allocating <a href="glib-Doubly-Linked-Lists.html#GList"><span class="type">GList</span></a> elements.
</p></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="glib-Memory-Chunks.html"><b>&lt;&lt; Memory Chunks</b></a></td><td align="right"><a accesskey="n" href="glib-Singly-Linked-Lists.html"><b>Singly-Linked Lists &gt;&gt;</b></a></td></tr></table></body></html>