glib-Pointer-Arrays.html   [plain text]


<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Pointer Arrays</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-Arrays.html" title="Arrays"><link rel="next" href="glib-Byte-Arrays.html" title="Byte Arrays"><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-Pointer-Arrays.html#id3296292" title="Description"><link rel="section" href="glib-Pointer-Arrays.html#id3296442" 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-Arrays.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-Byte-Arrays.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-Pointer-Arrays"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2><span class="refentrytitle">Pointer Arrays</span></h2><p>Pointer Arrays &#8212; arrays of pointers to any type of data, which grow automatically as new
elements are added.</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">

#include &lt;glib.h&gt;


struct      <a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a>;
<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a>*  <a href="glib-Pointer-Arrays.html#g-ptr-array-new">g_ptr_array_new</a>                 (void);
<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a>*  <a href="glib-Pointer-Arrays.html#g-ptr-array-sized-new">g_ptr_array_sized_new</a>           (<a href="glib-Basic-Types.html#guint">guint</a> reserved_size);
void        <a href="glib-Pointer-Arrays.html#g-ptr-array-add">g_ptr_array_add</a>                 (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);
<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Pointer-Arrays.html#g-ptr-array-remove">g_ptr_array_remove</a>              (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);
<a href="glib-Basic-Types.html#gpointer">gpointer</a>    <a href="glib-Pointer-Arrays.html#g-ptr-array-remove-index">g_ptr_array_remove_index</a>        (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#guint">guint</a> index_);
<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Pointer-Arrays.html#g-ptr-array-remove-fast">g_ptr_array_remove_fast</a>         (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);
<a href="glib-Basic-Types.html#gpointer">gpointer</a>    <a href="glib-Pointer-Arrays.html#g-ptr-array-remove-index-fast">g_ptr_array_remove_index_fast</a>   (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#guint">guint</a> index_);
void        <a href="glib-Pointer-Arrays.html#g-ptr-array-remove-range">g_ptr_array_remove_range</a>        (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#guint">guint</a> index_,
                                             <a href="glib-Basic-Types.html#guint">guint</a> length);
void        <a href="glib-Pointer-Arrays.html#g-ptr-array-sort">g_ptr_array_sort</a>                (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> compare_func);
void        <a href="glib-Pointer-Arrays.html#g-ptr-array-sort-with-data">g_ptr_array_sort_with_data</a>      (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> compare_func,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);
void        <a href="glib-Pointer-Arrays.html#g-ptr-array-set-size">g_ptr_array_set_size</a>            (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#gint">gint</a> length);
#define     <a href="glib-Pointer-Arrays.html#g-ptr-array-index">g_ptr_array_index</a>               (array,index_)
<a href="glib-Basic-Types.html#gpointer">gpointer</a>*   <a href="glib-Pointer-Arrays.html#g-ptr-array-free">g_ptr_array_free</a>                (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#gboolean">gboolean</a> free_seg);
void        <a href="glib-Pointer-Arrays.html#g-ptr-array-foreach">g_ptr_array_foreach</a>             (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Doubly-Linked-Lists.html#GFunc">GFunc</a> func,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);
</pre></div><div class="refsect1" lang="en"><a name="id3296292"></a><h2>Description</h2><p>
Pointer Arrays are similar to Arrays but are used only for storing pointers.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
If you remove elements from the array, elements at the end of the array
are moved into the space previously occupied by the removed element.
This means that you should not rely on the index of particular elements
remaining the same. You should also be careful when deleting elements while
iterating over the array.
</p></div><p>
To create a pointer array, use <a href="glib-Pointer-Arrays.html#g-ptr-array-new"><tt class="function">g_ptr_array_new()</tt></a>.
</p><p>
To add elements to a pointer array, use <a href="glib-Pointer-Arrays.html#g-ptr-array-add"><tt class="function">g_ptr_array_add()</tt></a>.
</p><p>
To remove elements from a pointer array, use <a href="glib-Pointer-Arrays.html#g-ptr-array-remove"><tt class="function">g_ptr_array_remove()</tt></a>,
<a href="glib-Pointer-Arrays.html#g-ptr-array-remove-index"><tt class="function">g_ptr_array_remove_index()</tt></a> or <a href="glib-Pointer-Arrays.html#g-ptr-array-remove-index-fast"><tt class="function">g_ptr_array_remove_index_fast()</tt></a>.
</p><p>
To access an element of a pointer array, use <a href="glib-Pointer-Arrays.html#g-ptr-array-index"><tt class="function">g_ptr_array_index()</tt></a>.
</p><p>
To set the size of a pointer array, use <a href="glib-Pointer-Arrays.html#g-ptr-array-set-size"><tt class="function">g_ptr_array_set_size()</tt></a>.
</p><p>
To free a pointer array, use <a href="glib-Pointer-Arrays.html#g-ptr-array-free"><tt class="function">g_ptr_array_free()</tt></a>.
</p><div class="example"><a name="id3296423"></a><p class="title"><b>Example 5. Using a <span class="structname">GPtrArray</span></b></p><pre class="programlisting">
  GPtrArray *gparray;
  gchar *string1 = "one", *string2 = "two", *string3 = "three";

  gparray = g_ptr_array_new ();
  g_ptr_array_add (gparray, (gpointer) string1);
  g_ptr_array_add (gparray, (gpointer) string2);
  g_ptr_array_add (gparray, (gpointer) string3);

  if (g_ptr_array_index (gparray, 0) != (gpointer) string1)
    g_print ("ERROR: got %p instead of %p\n",
             g_ptr_array_index (gparray, 0), string1);

  g_ptr_array_free (gparray, TRUE);
</pre></div></div><div class="refsect1" lang="en"><a name="id3296442"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3296455"></a><h3><a name="GPtrArray"></a>struct GPtrArray</h3><a class="indexterm" name="id3296465"></a><pre class="programlisting">struct GPtrArray {

  gpointer *pdata;
  guint	    len;
};
</pre><p>
Contains the public fields of a pointer array.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><a href="glib-Basic-Types.html#gpointer">gpointer</a> *<i class="structfield"><tt>pdata</tt></i></span></td><td>points to the array of pointers, which may be moved when the array grows.
</td></tr><tr><td><span class="term"><a href="glib-Basic-Types.html#guint">guint</a> <i class="structfield"><tt>len</tt></i></span></td><td>number of pointers in the array.

</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3296525"></a><h3><a name="g-ptr-array-new"></a>g_ptr_array_new ()</h3><a class="indexterm" name="id3296536"></a><pre class="programlisting"><a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a>*  g_ptr_array_new                 (void);</pre><p>
Creates a new <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.
</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>the new <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3296587"></a><h3><a name="g-ptr-array-sized-new"></a>g_ptr_array_sized_new ()</h3><a class="indexterm" name="id3296598"></a><pre class="programlisting"><a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a>*  g_ptr_array_sized_new           (<a href="glib-Basic-Types.html#guint">guint</a> reserved_size);</pre><p>
Creates a new <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a> with <i class="parameter"><tt>reserved_size</tt></i> pointers
preallocated. This avoids frequent reallocation, if you are going to
add many pointers to the array. Note however that the size of the
array is still 0.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>reserved_size</tt></i> :</span></td><td>number of pointers preallocated.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the new <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3296681"></a><h3><a name="g-ptr-array-add"></a>g_ptr_array_add ()</h3><a class="indexterm" name="id3296692"></a><pre class="programlisting">void        g_ptr_array_add                 (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre><p>
Adds a pointer to the end of the pointer array.
The array will grow in size automatically if necessary.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>array</tt></i> :</span></td><td>a <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>the pointer to add.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3296769"></a><h3><a name="g-ptr-array-remove"></a>g_ptr_array_remove ()</h3><a class="indexterm" name="id3296780"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_ptr_array_remove              (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre><p>
Removes the first occurrence of the given pointer from the pointer array.
The following elements are moved down one place.
</p><p>
It returns <tt class="literal">TRUE</tt> if the pointer was removed, or <tt class="literal">FALSE</tt> if the pointer
was not found.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>array</tt></i> :</span></td><td>a <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>the pointer to remove.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td><tt class="literal">TRUE</tt> if the pointer is removed. <tt class="literal">FALSE</tt> if the pointer is not found
in the array.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3296895"></a><h3><a name="g-ptr-array-remove-index"></a>g_ptr_array_remove_index ()</h3><a class="indexterm" name="id3296906"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gpointer">gpointer</a>    g_ptr_array_remove_index        (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#guint">guint</a> index_);</pre><p>
Removes the pointer at the given index from the pointer array.
The following elements are moved down one place.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>array</tt></i> :</span></td><td>a <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>index_</tt></i> :</span></td><td>the index of the pointer to remove.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the pointer which was removed.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3296995"></a><h3><a name="g-ptr-array-remove-fast"></a>g_ptr_array_remove_fast ()</h3><a class="indexterm" name="id3297006"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_ptr_array_remove_fast         (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre><p>
Removes the first occurrence of the given pointer from the pointer array.
The last element in the array is used to fill in the space, so this function
does not preserve the order of the array. But it is faster than
<a href="glib-Pointer-Arrays.html#g-ptr-array-remove"><tt class="function">g_ptr_array_remove()</tt></a>.
</p><p>
It returns <tt class="literal">TRUE</tt> if the pointer was removed, or <tt class="literal">FALSE</tt> if the pointer
was not found.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>array</tt></i> :</span></td><td>a <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>data</tt></i> :</span></td><td>the pointer to remove.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td><tt class="literal">TRUE</tt> if the pointer was found in the array.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3297127"></a><h3><a name="g-ptr-array-remove-index-fast"></a>g_ptr_array_remove_index_fast ()</h3><a class="indexterm" name="id3297139"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gpointer">gpointer</a>    g_ptr_array_remove_index_fast   (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#guint">guint</a> index_);</pre><p>
Removes the pointer at the given index from the pointer array.
The last element in the array is used to fill in the space, so this function
does not preserve the order of the array. But it is faster than
<a href="glib-Pointer-Arrays.html#g-ptr-array-remove-index"><tt class="function">g_ptr_array_remove_index()</tt></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>array</tt></i> :</span></td><td>a <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>index_</tt></i> :</span></td><td>the index of the pointer to remove.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the pointer which was removed.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3297240"></a><h3><a name="g-ptr-array-remove-range"></a>g_ptr_array_remove_range ()</h3><a class="indexterm" name="id3297251"></a><pre class="programlisting">void        g_ptr_array_remove_range        (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#guint">guint</a> index_,
                                             <a href="glib-Basic-Types.html#guint">guint</a> length);</pre><p>
Removes the given number of bytes starting at the given index from a
<a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.  The following elements are moved to close the gap.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>array</tt></i> :</span></td><td>a <i class="parameter"><tt>GPtrArray</tt></i>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>index_</tt></i> :</span></td><td>the index of the first pointer to remove.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>length</tt></i> :</span></td><td>the number of pointers to remove.
</td></tr></tbody></table></div><p>Since 2.4


</p></div><hr><div class="refsect2" lang="en"><a name="id3297361"></a><h3><a name="g-ptr-array-sort"></a>g_ptr_array_sort ()</h3><a class="indexterm" name="id3297372"></a><pre class="programlisting">void        g_ptr_array_sort                (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Doubly-Linked-Lists.html#GCompareFunc">GCompareFunc</a> compare_func);</pre><p>
Sorts the array, using <i class="parameter"><tt>compare_func</tt></i> which should be a <tt class="function">qsort()</tt>-style comparison
function (returns -1 for first arg is less than second arg, 0 for equal, 1 if
first arg is greater than second arg).
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
The comparison function for <a href="glib-Pointer-Arrays.html#g-ptr-array-sort"><tt class="function">g_ptr_array_sort()</tt></a> doesn't take the pointers from the array as arguments, 
it takes pointers to the pointers in the array.
</p></div><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>array</tt></i> :</span></td><td>a <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>compare_func</tt></i> :</span></td><td>comparison function.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3297484"></a><h3><a name="g-ptr-array-sort-with-data"></a>g_ptr_array_sort_with_data ()</h3><a class="indexterm" name="id3297497"></a><pre class="programlisting">void        g_ptr_array_sort_with_data      (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <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-Pointer-Arrays.html#g-ptr-array-sort"><tt class="function">g_ptr_array_sort()</tt></a>, but the comparison function has a user data argument.
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
The comparison function for <a href="glib-Pointer-Arrays.html#g-ptr-array-sort-with-data"><tt class="function">g_ptr_array_sort_with_data()</tt></a> doesn't take the pointers from the array as arguments, 
it takes pointers to the pointers in the array.
</p></div><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>array</tt></i> :</span></td><td>a <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</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>data to pass to <i class="parameter"><tt>compare_func</tt></i>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3297630"></a><h3><a name="g-ptr-array-set-size"></a>g_ptr_array_set_size ()</h3><a class="indexterm" name="id3297641"></a><pre class="programlisting">void        g_ptr_array_set_size            (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#gint">gint</a> length);</pre><p>
Sets the size of the array, expanding it if necessary.
New elements are set to <tt class="literal">NULL</tt>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>array</tt></i> :</span></td><td>a <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>length</tt></i> :</span></td><td>the new length of the pointer array.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3297724"></a><h3><a name="g-ptr-array-index"></a>g_ptr_array_index()</h3><a class="indexterm" name="id3297735"></a><pre class="programlisting">#define     g_ptr_array_index(array,index_)</pre><p>
Returns the pointer at the given index of the pointer array.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>array</tt></i> :</span></td><td>a <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>index_</tt></i> :</span></td><td>the index of the pointer to return.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the pointer at the given index.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3297802"></a><h3><a name="g-ptr-array-free"></a>g_ptr_array_free ()</h3><a class="indexterm" name="id3297812"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gpointer">gpointer</a>*   g_ptr_array_free                (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <a href="glib-Basic-Types.html#gboolean">gboolean</a> free_seg);</pre><p>
Frees all of the memory allocated for the pointer array.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>array</tt></i> :</span></td><td>a <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>free_seg</tt></i> :</span></td><td>if <tt class="literal">TRUE</tt> the actual element data is freed as well.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3297905"></a><h3><a name="g-ptr-array-foreach"></a>g_ptr_array_foreach ()</h3><a class="indexterm" name="id3297916"></a><pre class="programlisting">void        g_ptr_array_foreach             (<a href="glib-Pointer-Arrays.html#GPtrArray">GPtrArray</a> *array,
                                             <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-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>.</p><p>

</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>array</tt></i> :</span></td><td> a <a href="glib-Pointer-Arrays.html#GPtrArray"><span class="type">GPtrArray</span></a>
</td></tr><tr><td><span class="term"><i class="parameter"><tt>func</tt></i> :</span></td><td> the function to call for each array element
</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><p>Since  2.4
</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-Arrays.html"><b>&lt;&lt; Arrays</b></a></td><td align="right"><a accesskey="n" href="glib-Byte-Arrays.html"><b>Byte Arrays &gt;&gt;</b></a></td></tr></table></body></html>