<refentry id="glib-Sequences">
<refmeta>
<refentrytitle role="top_of_page" id="glib-Sequences.top_of_page">Sequences</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GLIB Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Sequences</refname>
<refpurpose>scalable lists</refpurpose>
</refnamediv>

<refsynopsisdiv id="glib-Sequences.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

#include &lt;glib.h&gt;

                    <link linkend="GSequence">GSequence</link>;
typedef             <link linkend="GSequenceIter">GSequenceIter</link>;
<link linkend="gint">gint</link>                (<link linkend="GSequenceIterCompareFunc">*GSequenceIterCompareFunc</link>)         (<link linkend="GSequenceIter">GSequenceIter</link> *a,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *b,
                                                         <link linkend="gpointer">gpointer</link> data);

<link linkend="GSequence">GSequence</link> *         <link linkend="g-sequence-new">g_sequence_new</link>                      (<link linkend="GDestroyNotify">GDestroyNotify</link> data_destroy);
<link linkend="void">void</link>                <link linkend="g-sequence-free">g_sequence_free</link>                     (<link linkend="GSequence">GSequence</link> *seq);
<link linkend="gint">gint</link>                <link linkend="g-sequence-get-length">g_sequence_get_length</link>               (<link linkend="GSequence">GSequence</link> *seq);
<link linkend="void">void</link>                <link linkend="g-sequence-foreach">g_sequence_foreach</link>                  (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="GFunc">GFunc</link> func,
                                                         <link linkend="gpointer">gpointer</link> user_data);
<link linkend="void">void</link>                <link linkend="g-sequence-foreach-range">g_sequence_foreach_range</link>            (<link linkend="GSequenceIter">GSequenceIter</link> *begin,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *end,
                                                         <link linkend="GFunc">GFunc</link> func,
                                                         <link linkend="gpointer">gpointer</link> user_data);
<link linkend="void">void</link>                <link linkend="g-sequence-sort">g_sequence_sort</link>                     (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="GCompareDataFunc">GCompareDataFunc</link> cmp_func,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);
<link linkend="void">void</link>                <link linkend="g-sequence-sort-iter">g_sequence_sort_iter</link>                (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="GSequenceIterCompareFunc">GSequenceIterCompareFunc</link> cmp_func,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);

<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-get-begin-iter">g_sequence_get_begin_iter</link>           (<link linkend="GSequence">GSequence</link> *seq);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-get-end-iter">g_sequence_get_end_iter</link>             (<link linkend="GSequence">GSequence</link> *seq);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-get-iter-at-pos">g_sequence_get_iter_at_pos</link>          (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gint">gint</link> pos);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-append">g_sequence_append</link>                   (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gpointer">gpointer</link> data);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-prepend">g_sequence_prepend</link>                  (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gpointer">gpointer</link> data);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-insert-before">g_sequence_insert_before</link>            (<link linkend="GSequenceIter">GSequenceIter</link> *iter,
                                                         <link linkend="gpointer">gpointer</link> data);
<link linkend="void">void</link>                <link linkend="g-sequence-move">g_sequence_move</link>                     (<link linkend="GSequenceIter">GSequenceIter</link> *src,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *dest);
<link linkend="void">void</link>                <link linkend="g-sequence-swap">g_sequence_swap</link>                     (<link linkend="GSequenceIter">GSequenceIter</link> *a,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *b);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-insert-sorted">g_sequence_insert_sorted</link>            (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GCompareDataFunc">GCompareDataFunc</link> cmp_func,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-insert-sorted-iter">g_sequence_insert_sorted_iter</link>       (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GSequenceIterCompareFunc">GSequenceIterCompareFunc</link> iter_cmp,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);
<link linkend="void">void</link>                <link linkend="g-sequence-sort-changed">g_sequence_sort_changed</link>             (<link linkend="GSequenceIter">GSequenceIter</link> *iter,
                                                         <link linkend="GCompareDataFunc">GCompareDataFunc</link> cmp_func,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);
<link linkend="void">void</link>                <link linkend="g-sequence-sort-changed-iter">g_sequence_sort_changed_iter</link>        (<link linkend="GSequenceIter">GSequenceIter</link> *iter,
                                                         <link linkend="GSequenceIterCompareFunc">GSequenceIterCompareFunc</link> iter_cmp,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);
<link linkend="void">void</link>                <link linkend="g-sequence-remove">g_sequence_remove</link>                   (<link linkend="GSequenceIter">GSequenceIter</link> *iter);
<link linkend="void">void</link>                <link linkend="g-sequence-remove-range">g_sequence_remove_range</link>             (<link linkend="GSequenceIter">GSequenceIter</link> *begin,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *end);
<link linkend="void">void</link>                <link linkend="g-sequence-move-range">g_sequence_move_range</link>               (<link linkend="GSequenceIter">GSequenceIter</link> *dest,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *begin,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *end);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-search">g_sequence_search</link>                   (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GCompareDataFunc">GCompareDataFunc</link> cmp_func,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-search-iter">g_sequence_search_iter</link>              (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GSequenceIterCompareFunc">GSequenceIterCompareFunc</link> iter_cmp,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);

<link linkend="gpointer">gpointer</link>            <link linkend="g-sequence-get">g_sequence_get</link>                      (<link linkend="GSequenceIter">GSequenceIter</link> *iter);
<link linkend="void">void</link>                <link linkend="g-sequence-set">g_sequence_set</link>                      (<link linkend="GSequenceIter">GSequenceIter</link> *iter,
                                                         <link linkend="gpointer">gpointer</link> data);

<link linkend="gboolean">gboolean</link>            <link linkend="g-sequence-iter-is-begin">g_sequence_iter_is_begin</link>            (<link linkend="GSequenceIter">GSequenceIter</link> *iter);
<link linkend="gboolean">gboolean</link>            <link linkend="g-sequence-iter-is-end">g_sequence_iter_is_end</link>              (<link linkend="GSequenceIter">GSequenceIter</link> *iter);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-iter-next">g_sequence_iter_next</link>                (<link linkend="GSequenceIter">GSequenceIter</link> *iter);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-iter-prev">g_sequence_iter_prev</link>                (<link linkend="GSequenceIter">GSequenceIter</link> *iter);
<link linkend="gint">gint</link>                <link linkend="g-sequence-iter-get-position">g_sequence_iter_get_position</link>        (<link linkend="GSequenceIter">GSequenceIter</link> *iter);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-iter-move">g_sequence_iter_move</link>                (<link linkend="GSequenceIter">GSequenceIter</link> *iter,
                                                         <link linkend="gint">gint</link> delta);
<link linkend="GSequence">GSequence</link> *         <link linkend="g-sequence-iter-get-sequence">g_sequence_iter_get_sequence</link>        (<link linkend="GSequenceIter">GSequenceIter</link> *iter);

<link linkend="gint">gint</link>                <link linkend="g-sequence-iter-compare">g_sequence_iter_compare</link>             (<link linkend="GSequenceIter">GSequenceIter</link> *a,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *b);
<link linkend="GSequenceIter">GSequenceIter</link> *     <link linkend="g-sequence-range-get-midpoint">g_sequence_range_get_midpoint</link>       (<link linkend="GSequenceIter">GSequenceIter</link> *begin,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *end);
</synopsis>
</refsynopsisdiv>









<refsect1 id="glib-Sequences.description" role="desc">
<title role="desc.title">Description</title>
<para>
The <link linkend="GSequence"><type>GSequence</type></link> data structure has the API of a list, but is
implemented internally with a balanced binary tree. This means that it
is possible to maintain a sorted list of n elements in time O(n log
n). The data contained in each element can be either integer values, by
using of the
<link linkend="glib-Type-Conversion-Macros">Type Conversion Macros</link>,
or simply pointers to any type of data.
</para>
<para>
A <link linkend="GSequence"><type>GSequence</type></link> is accessed through <firstterm>iterators</firstterm>,
represented by a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>. An iterator represents a position
between two elements of the sequence. For example, the
<firstterm>begin</firstterm> iterator represents the gap immediately
before the first element of the sequence, and the
<firstterm>end</firstterm> iterator represents the gap immediately
after the last element. In an empty sequence, the begin and end
iterators are the same.
</para>
<para>
Some methods on <link linkend="GSequence"><type>GSequence</type></link> operate on ranges of items. For example
<link linkend="g-sequence-foreach-range"><function>g_sequence_foreach_range()</function></link> will call a user-specified function on each
element with the given range. The range is delimited by the gaps
represented by the passed-in iterators, so if you pass in the begin
and end iterators, the range in question is the entire sequence.
</para>
<para>
The function <link linkend="g-sequence-get"><function>g_sequence_get()</function></link> is used with an iterator to access the
element immediately following the gap that the iterator
represents. The iterator is said to <firstterm>point</firstterm> to
that element.
</para>
<para>
Iterators are stable across most operations on a <link linkend="GSequence"><type>GSequence</type></link>. For
example an iterator pointing to some element of a sequence will
continue to point to that element even after the sequence is
sorted. Even moving an element to another sequence using for example
<link linkend="g-sequence-move-range"><function>g_sequence_move_range()</function></link> will not invalidate the iterators pointing to
it. The only operation that will invalidate an iterator is when the
element it points to is removed from any sequence.
</para>
</refsect1>

<refsect1 id="glib-Sequences.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GSequence" role="struct">
<title>GSequence</title>
<indexterm zone="GSequence"><primary sortas="Sequence">GSequence</primary></indexterm><programlisting>typedef struct _GSequence GSequence;</programlisting>
<para>
The <structname>GSequence</structname> struct is an opaque data type
representing a <link linkend="glib-Sequences">Sequence</link> data type.
</para></refsect2>
<refsect2 id="GSequenceIter" role="typedef">
<title>GSequenceIter</title>
<indexterm zone="GSequenceIter"><primary sortas="SequenceIter">GSequenceIter</primary></indexterm><programlisting>typedef struct _GSequenceNode  GSequenceIter;
</programlisting>
<para>
The <structname>GSequenceIter</structname> struct is an opaque data
type representing an iterator pointing into a <link linkend="GSequence"><type>GSequence</type></link>.
</para></refsect2>
<refsect2 id="GSequenceIterCompareFunc" role="function">
<title>GSequenceIterCompareFunc ()</title>
<indexterm zone="GSequenceIterCompareFunc"><primary sortas="SequenceIterCompareFunc">GSequenceIterCompareFunc</primary></indexterm><programlisting><link linkend="gint">gint</link>                (*GSequenceIterCompareFunc)         (<link linkend="GSequenceIter">GSequenceIter</link> *a,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *b,
                                                         <link linkend="gpointer">gpointer</link> data);</programlisting>
<para>
A <link linkend="GSequenceIterCompareFunc"><type>GSequenceIterCompareFunc</type></link> is a function used to compare
iterators. It must return zero if the iterators compare equal, a
negative value if <parameter>a</parameter> comes before <parameter>b</parameter>, and a positive value if <parameter>b</parameter> comes
before <parameter>a</parameter>.
</para><variablelist role="params">
<varlistentry><term><parameter>a</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>b</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara>user data
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>zero if the iterators are equal, a negative value if <parameter>a</parameter>
comes before <parameter>b</parameter>, and a positive value if <parameter>b</parameter> comes before <parameter>a</parameter>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="g-sequence-new" role="function" condition="since:2.14">
<title>g_sequence_new ()</title>
<indexterm zone="g-sequence-new" role="2.14"><primary sortas="sequence_new">g_sequence_new</primary></indexterm><programlisting><link linkend="GSequence">GSequence</link> *         g_sequence_new                      (<link linkend="GDestroyNotify">GDestroyNotify</link> data_destroy);</programlisting>
<para>
Creates a new GSequence. The <parameter>data_destroy</parameter> function, if non-<link linkend="NULL--CAPS"><literal>NULL</literal></link> will
be called on all items when the sequence is destroyed and on items that
are removed from the sequence.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>data_destroy</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GDestroyNotify"><type>GDestroyNotify</type></link> function, or <link linkend="NULL--CAPS"><literal>NULL</literal></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a new <link linkend="GSequence"><type>GSequence</type></link>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-free" role="function" condition="since:2.14">
<title>g_sequence_free ()</title>
<indexterm zone="g-sequence-free" role="2.14"><primary sortas="sequence_free">g_sequence_free</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_free                     (<link linkend="GSequence">GSequence</link> *seq);</programlisting>
<para>
Frees the memory allocated for <parameter>seq</parameter>. If <parameter>seq</parameter> has a data destroy 
function associated with it, that function is called on all items in
<parameter>seq</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-get-length" role="function" condition="since:2.14">
<title>g_sequence_get_length ()</title>
<indexterm zone="g-sequence-get-length" role="2.14"><primary sortas="sequence_get_length">g_sequence_get_length</primary></indexterm><programlisting><link linkend="gint">gint</link>                g_sequence_get_length               (<link linkend="GSequence">GSequence</link> *seq);</programlisting>
<para>
Returns the length of <parameter>seq</parameter></para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the length of <parameter>seq</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-foreach" role="function" condition="since:2.14">
<title>g_sequence_foreach ()</title>
<indexterm zone="g-sequence-foreach" role="2.14"><primary sortas="sequence_foreach">g_sequence_foreach</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_foreach                  (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="GFunc">GFunc</link> func,
                                                         <link linkend="gpointer">gpointer</link> user_data);</programlisting>
<para>
Calls <parameter>func</parameter> for each item in the sequence passing <parameter>user_data</parameter>
to the function.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>func</parameter>&#160;:</term>
<listitem><simpara> the function to call for each item in <parameter>seq</parameter>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&#160;:</term>
<listitem><simpara> user data passed to <parameter>func</parameter>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-foreach-range" role="function" condition="since:2.14">
<title>g_sequence_foreach_range ()</title>
<indexterm zone="g-sequence-foreach-range" role="2.14"><primary sortas="sequence_foreach_range">g_sequence_foreach_range</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_foreach_range            (<link linkend="GSequenceIter">GSequenceIter</link> *begin,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *end,
                                                         <link linkend="GFunc">GFunc</link> func,
                                                         <link linkend="gpointer">gpointer</link> user_data);</programlisting>
<para>
Calls <parameter>func</parameter> for each item in the range (<parameter>begin</parameter>, <parameter>end</parameter>) passing
<parameter>user_data</parameter> to the function.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>begin</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>end</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>func</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GFunc"><type>GFunc</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&#160;:</term>
<listitem><simpara> user data passed to <parameter>func</parameter>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-sort" role="function" condition="since:2.14">
<title>g_sequence_sort ()</title>
<indexterm zone="g-sequence-sort" role="2.14"><primary sortas="sequence_sort">g_sequence_sort</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_sort                     (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="GCompareDataFunc">GCompareDataFunc</link> cmp_func,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);</programlisting>
<para>
Sorts <parameter>seq</parameter> using <parameter>cmp_func</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_func</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GCompareDataFunc"><type>GCompareDataFunc</type></link> used to sort <parameter>seq</parameter>. This function is
      passed two items of <parameter>seq</parameter> and should return 0 if they are equal,
      a negative value if the first comes before the second, and a
      positive value if the second comes before the first.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_data</parameter>&#160;:</term>
<listitem><simpara> user data passed to <parameter>cmp_func</parameter>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-sort-iter" role="function" condition="since:2.14">
<title>g_sequence_sort_iter ()</title>
<indexterm zone="g-sequence-sort-iter" role="2.14"><primary sortas="sequence_sort_iter">g_sequence_sort_iter</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_sort_iter                (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="GSequenceIterCompareFunc">GSequenceIterCompareFunc</link> cmp_func,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);</programlisting>
<para>
Like <link linkend="g-sequence-sort"><function>g_sequence_sort()</function></link>, but uses a <link linkend="GSequenceIterCompareFunc"><type>GSequenceIterCompareFunc</type></link> instead
of a GCompareDataFunc as the compare function</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_func</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GSequenceItercompare"><type>GSequenceItercompare</type></link> used to compare iterators in the
    sequence. It is called with two iterators pointing into <parameter>seq</parameter>. It should
    return 0 if the iterators are equal, a negative value if the first
    iterator comes before the second, and a positive value if the second
    iterator comes before the first.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_data</parameter>&#160;:</term>
<listitem><simpara> user data passed to <parameter>cmp_func</parameter>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-get-begin-iter" role="function" condition="since:2.14">
<title>g_sequence_get_begin_iter ()</title>
<indexterm zone="g-sequence-get-begin-iter" role="2.14"><primary sortas="sequence_get_begin_iter">g_sequence_get_begin_iter</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_get_begin_iter           (<link linkend="GSequence">GSequence</link> *seq);</programlisting>
<para>
Returns the begin iterator for <parameter>seq</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the begin iterator for <parameter>seq</parameter>.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-get-end-iter" role="function" condition="since:2.14">
<title>g_sequence_get_end_iter ()</title>
<indexterm zone="g-sequence-get-end-iter" role="2.14"><primary sortas="sequence_get_end_iter">g_sequence_get_end_iter</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_get_end_iter             (<link linkend="GSequence">GSequence</link> *seq);</programlisting>
<para>
Returns the end iterator for <parameter>seg</parameter></para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the end iterator for <parameter>seq</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-get-iter-at-pos" role="function" condition="since:2.14">
<title>g_sequence_get_iter_at_pos ()</title>
<indexterm zone="g-sequence-get-iter-at-pos" role="2.14"><primary sortas="sequence_get_iter_at_pos">g_sequence_get_iter_at_pos</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_get_iter_at_pos          (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gint">gint</link> pos);</programlisting>
<para>
Returns the iterator at position <parameter>pos</parameter>. If <parameter>pos</parameter> is negative or larger
than the number of items in <parameter>seq</parameter>, the end iterator is returned.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>pos</parameter>&#160;:</term>
<listitem><simpara> a position in <parameter>seq</parameter>, or -1 for the end.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The <link linkend="GSequenceIter"><type>GSequenceIter</type></link> at position <parameter>pos</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-append" role="function" condition="since:2.14">
<title>g_sequence_append ()</title>
<indexterm zone="g-sequence-append" role="2.14"><primary sortas="sequence_append">g_sequence_append</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_append                   (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gpointer">gpointer</link> data);</programlisting>
<para>
Adds a new item to the end of <parameter>seq</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequencePointer"><type>GSequencePointer</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> the data for the new item
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> an iterator pointing to the new item

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-prepend" role="function" condition="since:2.14">
<title>g_sequence_prepend ()</title>
<indexterm zone="g-sequence-prepend" role="2.14"><primary sortas="sequence_prepend">g_sequence_prepend</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_prepend                  (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gpointer">gpointer</link> data);</programlisting>
<para>
Adds a new item to the front of <parameter>seq</parameter></para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> the data for the new item
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> an iterator pointing to the new item

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-insert-before" role="function" condition="since:2.14">
<title>g_sequence_insert_before ()</title>
<indexterm zone="g-sequence-insert-before" role="2.14"><primary sortas="sequence_insert_before">g_sequence_insert_before</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_insert_before            (<link linkend="GSequenceIter">GSequenceIter</link> *iter,
                                                         <link linkend="gpointer">gpointer</link> data);</programlisting>
<para>
Inserts a new item just before the item pointed to by <parameter>iter</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> the data for the new item
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> an iterator pointing to the new item

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-move" role="function" condition="since:2.14">
<title>g_sequence_move ()</title>
<indexterm zone="g-sequence-move" role="2.14"><primary sortas="sequence_move">g_sequence_move</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_move                     (<link linkend="GSequenceIter">GSequenceIter</link> *src,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *dest);</programlisting>
<para>
Moves the item pointed to by <parameter>src</parameter> to the position indicated by <parameter>dest</parameter>.
After calling this function <parameter>dest</parameter> will point to the position immediately
after <parameter>src</parameter>. It is allowed for <parameter>src</parameter> and <parameter>dest</parameter> to point into different
sequences.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>src</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link> pointing to the item to move
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dest</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link> pointing to the position to which
       the item is moved.
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-swap" role="function" condition="since:2.14">
<title>g_sequence_swap ()</title>
<indexterm zone="g-sequence-swap" role="2.14"><primary sortas="sequence_swap">g_sequence_swap</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_swap                     (<link linkend="GSequenceIter">GSequenceIter</link> *a,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *b);</programlisting>
<para>
Swaps the items pointed to by <parameter>a</parameter> and <parameter>b</parameter>. It is allowed for <parameter>a</parameter> and <parameter>b</parameter>
to point into difference sequences.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>a</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>b</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-insert-sorted" role="function" condition="since:2.14">
<title>g_sequence_insert_sorted ()</title>
<indexterm zone="g-sequence-insert-sorted" role="2.14"><primary sortas="sequence_insert_sorted">g_sequence_insert_sorted</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_insert_sorted            (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GCompareDataFunc">GCompareDataFunc</link> cmp_func,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);</programlisting>
<para>
Inserts <parameter>data</parameter> into <parameter>sequence</parameter> using <parameter>func</parameter> to determine the new position.
The sequence must already be sorted according to <parameter>cmp_func</parameter>; otherwise the
new position of <parameter>data</parameter> is undefined.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> the data to insert
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_func</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GCompareDataFunc"><type>GCompareDataFunc</type></link> used to compare items in the sequence. It
    is called with two items of the <parameter>seq</parameter> and <parameter>user_data</parameter>. It should
    return 0 if the items are equal, a negative value if the first
    item comes before the second, and a positive value if the second
    item comes before the first.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_data</parameter>&#160;:</term>
<listitem><simpara> user data passed to <parameter>cmp_func</parameter>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link> pointing to the new item.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-insert-sorted-iter" role="function" condition="since:2.14">
<title>g_sequence_insert_sorted_iter ()</title>
<indexterm zone="g-sequence-insert-sorted-iter" role="2.14"><primary sortas="sequence_insert_sorted_iter">g_sequence_insert_sorted_iter</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_insert_sorted_iter       (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GSequenceIterCompareFunc">GSequenceIterCompareFunc</link> iter_cmp,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);</programlisting>
<para>
Like <link linkend="g-sequence-insert-sorted"><function>g_sequence_insert_sorted()</function></link>, but uses
a <link linkend="GSequenceIterCompareFunc"><type>GSequenceIterCompareFunc</type></link> instead of a <link linkend="GCompareDataFunc"><type>GCompareDataFunc</type></link> as
the compare function.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> data for the new item
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>iter_cmp</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GSequenceItercompare"><type>GSequenceItercompare</type></link> used to compare iterators in the
    sequence. It is called with two iterators pointing into <parameter>seq</parameter>. It should
    return 0 if the iterators are equal, a negative value if the first
    iterator comes before the second, and a positive value if the second
    iterator comes before the first.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_data</parameter>&#160;:</term>
<listitem><simpara> user data passed to <parameter>cmp_func</parameter>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link> pointing to the new item

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-sort-changed" role="function" condition="since:2.14">
<title>g_sequence_sort_changed ()</title>
<indexterm zone="g-sequence-sort-changed" role="2.14"><primary sortas="sequence_sort_changed">g_sequence_sort_changed</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_sort_changed             (<link linkend="GSequenceIter">GSequenceIter</link> *iter,
                                                         <link linkend="GCompareDataFunc">GCompareDataFunc</link> cmp_func,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);</programlisting>
<para>
Moves the data pointed to a new position as indicated by <parameter>cmp_func</parameter>. This
function should be called for items in a sequence already sorted according
to <parameter>cmp_func</parameter> whenever some aspect of an item changes so that <parameter>cmp_func</parameter>
may return different values for that item.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_func</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GCompareDataFunc"><type>GCompareDataFunc</type></link> used to compare items in the sequence. It
    is called with two items of the <parameter>seq</parameter> and <parameter>user_data</parameter>. It should
    return 0 if the items are equal, a negative value if the first
    item comes before the second, and a positive value if the second
    item comes before the first.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_data</parameter>&#160;:</term>
<listitem><simpara> user data passed to <parameter>cmp_func</parameter>.
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-sort-changed-iter" role="function" condition="since:2.14">
<title>g_sequence_sort_changed_iter ()</title>
<indexterm zone="g-sequence-sort-changed-iter" role="2.14"><primary sortas="sequence_sort_changed_iter">g_sequence_sort_changed_iter</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_sort_changed_iter        (<link linkend="GSequenceIter">GSequenceIter</link> *iter,
                                                         <link linkend="GSequenceIterCompareFunc">GSequenceIterCompareFunc</link> iter_cmp,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);</programlisting>
<para>
Like <link linkend="g-sequence-sort-changed"><function>g_sequence_sort_changed()</function></link>, but uses
a <link linkend="GSequenceIterCompareFunc"><type>GSequenceIterCompareFunc</type></link> instead of a <link linkend="GCompareDataFunc"><type>GCompareDataFunc</type></link> as
the compare function.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>iter_cmp</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GSequenceItercompare"><type>GSequenceItercompare</type></link> used to compare iterators in the
    sequence. It is called with two iterators pointing into <parameter>seq</parameter>. It should
    return 0 if the iterators are equal, a negative value if the first
    iterator comes before the second, and a positive value if the second
    iterator comes before the first.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_data</parameter>&#160;:</term>
<listitem><simpara> user data passed to <parameter>cmp_func</parameter>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-remove" role="function" condition="since:2.14">
<title>g_sequence_remove ()</title>
<indexterm zone="g-sequence-remove" role="2.14"><primary sortas="sequence_remove">g_sequence_remove</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_remove                   (<link linkend="GSequenceIter">GSequenceIter</link> *iter);</programlisting>
<para>
Removes the item pointed to by <parameter>iter</parameter>. It is an error to pass the
end iterator to this function.
</para>
<para>
If the sequnce has a data destroy function associated with it, this
function is called on the data for the removed item.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-remove-range" role="function" condition="since:2.14">
<title>g_sequence_remove_range ()</title>
<indexterm zone="g-sequence-remove-range" role="2.14"><primary sortas="sequence_remove_range">g_sequence_remove_range</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_remove_range             (<link linkend="GSequenceIter">GSequenceIter</link> *begin,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *end);</programlisting>
<para>
Removes all items in the (<parameter>begin</parameter>, <parameter>end</parameter>) range.
</para>
<para>
If the sequence has a data destroy function associated with it, this
function is called on the data for the removed items.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>begin</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>end</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-move-range" role="function" condition="since:2.14">
<title>g_sequence_move_range ()</title>
<indexterm zone="g-sequence-move-range" role="2.14"><primary sortas="sequence_move_range">g_sequence_move_range</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_move_range               (<link linkend="GSequenceIter">GSequenceIter</link> *dest,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *begin,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *end);</programlisting>
<para>
Inserts the (<parameter>begin</parameter>, <parameter>end</parameter>) range at the destination pointed to by ptr.
The <parameter>begin</parameter> and <parameter>end</parameter> iters must point into the same sequence. It is
allowed for <parameter>dest</parameter> to point to a different sequence than the one pointed
into by <parameter>begin</parameter> and <parameter>end</parameter>.
</para>
<para>
If <parameter>dest</parameter> is NULL, the range indicated by <parameter>begin</parameter> and <parameter>end</parameter> is
removed from the sequence. If <parameter>dest</parameter> iter points to a place within
the (<parameter>begin</parameter>, <parameter>end</parameter>) range, the range does not move.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>dest</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>begin</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>end</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-search" role="function" condition="since:2.14">
<title>g_sequence_search ()</title>
<indexterm zone="g-sequence-search" role="2.14"><primary sortas="sequence_search">g_sequence_search</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_search                   (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GCompareDataFunc">GCompareDataFunc</link> cmp_func,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);</programlisting>
<para>
Returns an iterator pointing to the position where <parameter>data</parameter> would
be inserted according to <parameter>cmp_func</parameter> and <parameter>cmp_data</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> data for the new item
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_func</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GCompareDataFunc"><type>GCompareDataFunc</type></link> used to compare items in the sequence. It
    is called with two items of the <parameter>seq</parameter> and <parameter>user_data</parameter>. It should
    return 0 if the items are equal, a negative value if the first
    item comes before the second, and a positive value if the second
    item comes before the first.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_data</parameter>&#160;:</term>
<listitem><simpara> user data passed to <parameter>cmp_func</parameter>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> an <link linkend="GSequenceIter"><type>GSequenceIter</type></link> pointing to the position where <parameter>data</parameter>
would have been inserted according to <parameter>cmp_func</parameter> and <parameter>cmp_data</parameter>.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-search-iter" role="function" condition="since:2.14">
<title>g_sequence_search_iter ()</title>
<indexterm zone="g-sequence-search-iter" role="2.14"><primary sortas="sequence_search_iter">g_sequence_search_iter</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_search_iter              (<link linkend="GSequence">GSequence</link> *seq,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GSequenceIterCompareFunc">GSequenceIterCompareFunc</link> iter_cmp,
                                                         <link linkend="gpointer">gpointer</link> cmp_data);</programlisting>
<para>
Like <link linkend="g-sequence-search"><function>g_sequence_search()</function></link>, but uses
a <link linkend="GSequenceIterCompareFunc"><type>GSequenceIterCompareFunc</type></link> instead of a <link linkend="GCompareDataFunc"><type>GCompareDataFunc</type></link> as
the compare function.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>seq</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequence"><type>GSequence</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> data for the new item
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>iter_cmp</parameter>&#160;:</term>
<listitem><simpara> the <link linkend="GSequenceIterCompare"><type>GSequenceIterCompare</type></link> function used to compare iterators
    in the sequence. It is called with two iterators pointing into <parameter>seq</parameter>.
    It should return 0 if the iterators are equal, a negative value if the
    first iterator comes before the second, and a positive value if the
    second iterator comes before the first.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cmp_data</parameter>&#160;:</term>
<listitem><simpara> user data passed to <parameter>iter_cmp</parameter>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link> pointing to the position in <parameter>seq</parameter>
where <parameter>data</parameter> would have been inserted according to <parameter>iter_cmp</parameter> and <parameter>cmp_data</parameter>.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-get" role="function" condition="since:2.14">
<title>g_sequence_get ()</title>
<indexterm zone="g-sequence-get" role="2.14"><primary sortas="sequence_get">g_sequence_get</primary></indexterm><programlisting><link linkend="gpointer">gpointer</link>            g_sequence_get                      (<link linkend="GSequenceIter">GSequenceIter</link> *iter);</programlisting>
<para>
Returns the data that <parameter>iter</parameter> points to.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the data that <parameter>iter</parameter> points to

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-set" role="function" condition="since:2.14">
<title>g_sequence_set ()</title>
<indexterm zone="g-sequence-set" role="2.14"><primary sortas="sequence_set">g_sequence_set</primary></indexterm><programlisting><link linkend="void">void</link>                g_sequence_set                      (<link linkend="GSequenceIter">GSequenceIter</link> *iter,
                                                         <link linkend="gpointer">gpointer</link> data);</programlisting>
<para>
Changes the data for the item pointed to by <parameter>iter</parameter> to be <parameter>data</parameter>. If
the sequence has a data destroy function associated with it, that
function is called on the existing data that <parameter>iter</parameter> pointed to.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> new data for the item
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-iter-is-begin" role="function" condition="since:2.14">
<title>g_sequence_iter_is_begin ()</title>
<indexterm zone="g-sequence-iter-is-begin" role="2.14"><primary sortas="sequence_iter_is_begin">g_sequence_iter_is_begin</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_sequence_iter_is_begin            (<link linkend="GSequenceIter">GSequenceIter</link> *iter);</programlisting>
<para>
Returns whether <parameter>iter</parameter> is the begin iterator</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> whether <parameter>iter</parameter> is the begin iterator

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-iter-is-end" role="function" condition="since:2.14">
<title>g_sequence_iter_is_end ()</title>
<indexterm zone="g-sequence-iter-is-end" role="2.14"><primary sortas="sequence_iter_is_end">g_sequence_iter_is_end</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            g_sequence_iter_is_end              (<link linkend="GSequenceIter">GSequenceIter</link> *iter);</programlisting>
<para>
Returns whether <parameter>iter</parameter> is the end iterator</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> Whether <parameter>iter</parameter> is the end iterator.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-iter-next" role="function" condition="since:2.14">
<title>g_sequence_iter_next ()</title>
<indexterm zone="g-sequence-iter-next" role="2.14"><primary sortas="sequence_iter_next">g_sequence_iter_next</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_iter_next                (<link linkend="GSequenceIter">GSequenceIter</link> *iter);</programlisting>
<para>
Returns an iterator pointing to the next position after <parameter>iter</parameter>. If
<parameter>iter</parameter> is the end iterator, the end iterator is returned.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link> pointing to the next position after <parameter>iter</parameter>.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-iter-prev" role="function" condition="since:2.14">
<title>g_sequence_iter_prev ()</title>
<indexterm zone="g-sequence-iter-prev" role="2.14"><primary sortas="sequence_iter_prev">g_sequence_iter_prev</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_iter_prev                (<link linkend="GSequenceIter">GSequenceIter</link> *iter);</programlisting>
<para>
Returns an iterator pointing to the previous position before <parameter>iter</parameter>. If
<parameter>iter</parameter> is the begin iterator, the begin iterator is returned.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link> pointing to the previous position before
<parameter>iter</parameter>.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-iter-get-position" role="function" condition="since:2.14">
<title>g_sequence_iter_get_position ()</title>
<indexterm zone="g-sequence-iter-get-position" role="2.14"><primary sortas="sequence_iter_get_position">g_sequence_iter_get_position</primary></indexterm><programlisting><link linkend="gint">gint</link>                g_sequence_iter_get_position        (<link linkend="GSequenceIter">GSequenceIter</link> *iter);</programlisting>
<para>
Returns the position of <parameter>iter</parameter></para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the position of <parameter>iter</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-iter-move" role="function" condition="since:2.14">
<title>g_sequence_iter_move ()</title>
<indexterm zone="g-sequence-iter-move" role="2.14"><primary sortas="sequence_iter_move">g_sequence_iter_move</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_iter_move                (<link linkend="GSequenceIter">GSequenceIter</link> *iter,
                                                         <link linkend="gint">gint</link> delta);</programlisting>
<para>
Returns the <link linkend="GSequenceIter"><type>GSequenceIter</type></link> which is <parameter>delta</parameter> positions away from <parameter>iter</parameter>.
If <parameter>iter</parameter> is closer than -<parameter>delta</parameter> positions to the beginning of the sequence,
the begin iterator is returned. If <parameter>iter</parameter> is closer than <parameter>delta</parameter> positions
to the end of the sequence, the end iterator is returned.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>delta</parameter>&#160;:</term>
<listitem><simpara> A positive or negative number indicating how many positions away
   from <parameter>iter</parameter> the returned <link linkend="GSequenceIter"><type>GSequenceIter</type></link> will be.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link> which is <parameter>delta</parameter> positions away from <parameter>iter</parameter>.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-iter-get-sequence" role="function" condition="since:2.14">
<title>g_sequence_iter_get_sequence ()</title>
<indexterm zone="g-sequence-iter-get-sequence" role="2.14"><primary sortas="sequence_iter_get_sequence">g_sequence_iter_get_sequence</primary></indexterm><programlisting><link linkend="GSequence">GSequence</link> *         g_sequence_iter_get_sequence        (<link linkend="GSequenceIter">GSequenceIter</link> *iter);</programlisting>
<para>
Returns the <link linkend="GSequence"><type>GSequence</type></link> that <parameter>iter</parameter> points into.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the <link linkend="GSequence"><type>GSequence</type></link> that <parameter>iter</parameter> points into.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-iter-compare" role="function" condition="since:2.14">
<title>g_sequence_iter_compare ()</title>
<indexterm zone="g-sequence-iter-compare" role="2.14"><primary sortas="sequence_iter_compare">g_sequence_iter_compare</primary></indexterm><programlisting><link linkend="gint">gint</link>                g_sequence_iter_compare             (<link linkend="GSequenceIter">GSequenceIter</link> *a,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *b);</programlisting>
<para>
Returns a negative number if <parameter>a</parameter> comes before <parameter>b</parameter>, 0 if they are equal,
and a positive number if <parameter>a</parameter> comes after <parameter>b</parameter>.
</para>
<para>
The <parameter>a</parameter> and <parameter>b</parameter> iterators must point into the same sequence.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>a</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>b</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> A negative number if <parameter>a</parameter> comes before <parameter>b</parameter>, 0 if they are
equal, and a positive number if <parameter>a</parameter> comes after <parameter>b</parameter>.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="g-sequence-range-get-midpoint" role="function" condition="since:2.14">
<title>g_sequence_range_get_midpoint ()</title>
<indexterm zone="g-sequence-range-get-midpoint" role="2.14"><primary sortas="sequence_range_get_midpoint">g_sequence_range_get_midpoint</primary></indexterm><programlisting><link linkend="GSequenceIter">GSequenceIter</link> *     g_sequence_range_get_midpoint       (<link linkend="GSequenceIter">GSequenceIter</link> *begin,
                                                         <link linkend="GSequenceIter">GSequenceIter</link> *end);</programlisting>
<para>
Finds an iterator somewhere in the range (<parameter>begin</parameter>, <parameter>end</parameter>). This
iterator will be close to the middle of the range, but is not
guaranteed to be <emphasis>exactly</emphasis> in the middle.
</para>
<para>
The <parameter>begin</parameter> and <parameter>end</parameter> iterators must both point to the same sequence and
<parameter>begin</parameter> must come before or be equal to <parameter>end</parameter> in the sequence.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>begin</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>end</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GSequenceIter"><type>GSequenceIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> A <link linkend="GSequenceIter"><type>GSequenceIter</type></link> pointing somewhere in the
(<parameter>begin</parameter>, <parameter>end</parameter>) range.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>

</refsect1>




</refentry>
