Software: Apache/2.0.54 (Fedora). PHP/5.0.4 uname -a: Linux mina-info.me 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 uid=48(apache) gid=48(apache) groups=48(apache) Safe-mode: OFF (not secure) /usr/share/gtk-doc/html/glib/ drwxr-xr-x |
Viewing file: Select action/file-type:
Synopsis#include <glib.h> GArray; GArray* g_array_new (gboolean zero_terminated, gboolean clear_, guint element_size); GArray* g_array_sized_new (gboolean zero_terminated, gboolean clear_, guint element_size, guint reserved_size); #define g_array_append_val (a,v) GArray* g_array_append_vals (GArray *array, gconstpointer data, guint len); #define g_array_prepend_val (a,v) GArray* g_array_prepend_vals (GArray *array, gconstpointer data, guint len); #define g_array_insert_val (a,i,v) GArray* g_array_insert_vals (GArray *array, guint index_, gconstpointer data, guint len); GArray* g_array_remove_index (GArray *array, guint index_); GArray* g_array_remove_index_fast (GArray *array, guint index_); GArray* g_array_remove_range (GArray *array, guint index_, guint length); void g_array_sort (GArray *array, GCompareFunc compare_func); void g_array_sort_with_data (GArray *array, GCompareDataFunc compare_func, gpointer user_data); #define g_array_index (a,t,i) GArray* g_array_set_size (GArray *array, guint length); gchar* g_array_free (GArray *array, gboolean free_segment); DescriptionArrays are similar to standard C arrays, except that they grow automatically as elements are added. Array elements can be of any size (though all elements of one array are the same size), and the array can be automatically cleared to '0's and zero-terminated.
To create a new array use
To add elements to an array, use
To access an element of an array, use
To set the size of an array, use
To free an array, use Example 3. Using a GArray to store gint values GArray *garray; gint i; /* We create a new array to store gint values. We don't want it zero-terminated or cleared to 0's. */ garray = g_array_new (FALSE, FALSE, sizeof (gint)); for (i = 0; i < 10000; i++) g_array_append_val (garray, i); for (i = 0; i < 10000; i++) if (g_array_index (garray, gint, i) != i) g_print ("ERROR: got %d instead of %d\n", g_array_index (garray, gint, i), i); g_array_free (garray, TRUE); Detailsg_array_new ()GArray* g_array_new (gboolean zero_terminated, gboolean clear_, guint element_size); Creates a new GArray. g_array_sized_new ()GArray* g_array_sized_new (gboolean zero_terminated, gboolean clear_, guint element_size, guint reserved_size);
Creates a new GArray with
g_array_append_val()#define g_array_append_val(a,v) Adds the value on to the end of the array. The array will grow in size automatically if necessary. Note
g_array_append_vals ()GArray* g_array_append_vals (GArray *array, gconstpointer data, guint len);
Adds g_array_prepend_val()#define g_array_prepend_val(a,v) Adds the value on to the start of the array. The array will grow in size automatically if necessary.
This operation is slower than Note
g_array_prepend_vals ()GArray* g_array_prepend_vals (GArray *array, gconstpointer data, guint len);
Adds
This operation is slower than g_array_insert_val()#define g_array_insert_val(a,i,v) Inserts an element into an array at the given index. Note
g_array_insert_vals ()GArray* g_array_insert_vals (GArray *array, guint index_, gconstpointer data, guint len);
Inserts g_array_remove_index ()GArray* g_array_remove_index (GArray *array, guint index_); Removes the element at the given index from a GArray. The following elements are moved down one place. g_array_remove_index_fast ()GArray* g_array_remove_index_fast (GArray *array, guint index_);
Removes the element at the given index from a GArray.
The last element in the array is used to fill in the space, so this function
does not preserve the order of the GArray. But it is faster than
g_array_remove_range ()GArray* g_array_remove_range (GArray *array, guint index_, guint length); Removes the given number of elements starting at the given index from a GArray. The following elements are moved to close the gap.
Since 2.4 g_array_sort ()void g_array_sort (GArray *array, GCompareFunc compare_func);
Sorts a GArray using
g_array_sort_with_data ()void g_array_sort_with_data (GArray *array, GCompareDataFunc compare_func, gpointer user_data);
Like
g_array_index()#define g_array_index(a,t,i) Returns the element of a GArray at the given index. The return value is cast to the given type. Example 4. Getting a pointer to an element in a GArray EDayViewEvent *event; /* This gets a pointer to the 3rd element in the array of EDayViewEvent structs. */ event = &g_array_index (events, EDayViewEvent, 3);
g_array_set_size ()GArray* g_array_set_size (GArray *array, guint length);
Sets the size of the array, expanding it if necessary.
If the array was created with g_array_free ()gchar* g_array_free (GArray *array, gboolean free_segment);
Frees the memory allocated for the GArray.
If
|
:: Command execute :: | |
--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0035 ]-- |