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> GList; GList* g_list_append (GList *list, gpointer data); GList* g_list_prepend (GList *list, gpointer data); GList* g_list_insert (GList *list, gpointer data, gint position); GList* g_list_insert_before (GList *list, GList *sibling, gpointer data); GList* g_list_insert_sorted (GList *list, gpointer data, GCompareFunc func); GList* g_list_remove (GList *list, gconstpointer data); GList* g_list_remove_link (GList *list, GList *llink); GList* g_list_delete_link (GList *list, GList *link_); GList* g_list_remove_all (GList *list, gconstpointer data); void g_list_free (GList *list); GList* g_list_alloc (void); void g_list_free_1 (GList *list); guint g_list_length (GList *list); GList* g_list_copy (GList *list); GList* g_list_reverse (GList *list); GList* g_list_sort (GList *list, GCompareFunc compare_func); gint (*GCompareFunc) (gconstpointer a, gconstpointer b); GList* g_list_sort_with_data (GList *list, GCompareDataFunc compare_func, gpointer user_data); gint (*GCompareDataFunc) (gconstpointer a, gconstpointer b, gpointer user_data); GList* g_list_concat (GList *list1, GList *list2); void g_list_foreach (GList *list, GFunc func, gpointer user_data); void (*GFunc) (gpointer data, gpointer user_data); GList* g_list_first (GList *list); GList* g_list_last (GList *list); #define g_list_previous (list) #define g_list_next (list) GList* g_list_nth (GList *list, guint n); gpointer g_list_nth_data (GList *list, guint n); GList* g_list_nth_prev (GList *list, guint n); GList* g_list_find (GList *list, gconstpointer data); GList* g_list_find_custom (GList *list, gconstpointer data, GCompareFunc func); gint g_list_position (GList *list, GList *llink); gint g_list_index (GList *list, gconstpointer data); void g_list_push_allocator (GAllocator *allocator); void g_list_pop_allocator (void); DescriptionThe GList structure and its associated functions provide a standard doubly-linked list data structure. Each element in the list contains a piece of data, together with pointers which link to the previous and next elements in the list. Using these pointers it is possible to move through the list in both directions (unlike the Singly-Linked Lists which only allows movement through the list in the forward direction). The data contained in each element can be either integer values, by using one of the Type Conversion Macros, or simply pointers to any type of data. List elements are allocated in blocks using a GAllocator, which is more efficient than allocating elements individually. Note that most of the GList functions expect to be passed a pointer to the first element in the list. The functions which insert elements return the new start of the list, which may have changed.
There is no function to create a GList.
To add elements, use
To remove elements, use
To find elements in the list use
To find the index of an element use
To call a function for each element in the list use
To free the entire list, use DetailsGListtypedef struct { gpointer data; GList *next; GList *prev; } GList;
The GList struct is used for each element in a doubly-linked list.
The g_list_append ()GList* g_list_append (GList *list, gpointer data); Adds a new element on to the end of the list. NoteThe return value is the new start of the list, which may have changed, so make sure you store the new value. /* Notice that these are initialized to the empty list. */ GList *list = NULL, *number_list = NULL; /* This is a list of strings. */ list = g_list_append (list, "first"); list = g_list_append (list, "second"); /* This is a list of integers. */ number_list = g_list_append (number_list, GINT_TO_POINTER (27)); number_list = g_list_append (number_list, GINT_TO_POINTER (14)); g_list_prepend ()GList* g_list_prepend (GList *list, gpointer data); Adds a new element on to the start of the list. NoteThe return value is the new start of the list, which may have changed, so make sure you store the new value. /* Notice that it is initialized to the empty list. */ GList *list = NULL; list = g_list_prepend (list, "last"); list = g_list_prepend (list, "first"); g_list_insert ()GList* g_list_insert (GList *list, gpointer data, gint position); Inserts a new element into the list at the given position. g_list_insert_before ()GList* g_list_insert_before (GList *list, GList *sibling, gpointer data); Inserts a new element into the list before the given position. g_list_insert_sorted ()GList* g_list_insert_sorted (GList *list, gpointer data, GCompareFunc func); Inserts a new element into the list, using the given comparison function to determine its position. g_list_remove ()GList* g_list_remove (GList *list, gconstpointer data); Removes an element from a GList. If two elements contain the same data, only the first is removed. If none of the elements contain the data, the GList is unchanged. g_list_remove_link ()GList* g_list_remove_link (GList *list, GList *llink);
Removes an element from a GList, without freeing the element.
The removed element's prev and next links are set to g_list_delete_link ()GList* g_list_delete_link (GList *list, GList *link_);
Deletes the node
g_list_remove_all ()GList* g_list_remove_all (GList *list, gconstpointer data);
Removes all list nodes with data equal to
g_list_free ()void g_list_free (GList *list); Frees all of the memory used by a GList. The freed elements are added to the GAllocator free list. NoteIf list elements contain dynamically-allocated memory, they should be freed first.
g_list_alloc ()GList* g_list_alloc (void);
Allocates space for one GList element.
It is called by
g_list_free_1 ()void g_list_free_1 (GList *list);
Frees one GList element.
It is usually used after
g_list_copy ()GList* g_list_copy (GList *list); Copies a GList. Note that this is a "shallow" copy. If the list elements consist of pointers to data, the pointers are copied but the actual data isn't.
g_list_reverse ()GList* g_list_reverse (GList *list); Reverses a GList. It simply switches the next and prev pointers of each element. g_list_sort ()GList* g_list_sort (GList *list, GCompareFunc compare_func); Sorts a GList using the given comparison function.
GCompareFunc ()gint (*GCompareFunc) (gconstpointer a, gconstpointer b); Specifies the type of a comparison function used to compare two values. The function should return a negative integer if the first value comes before the second, 0 if they are equal, or a positive integer if the first value comes after the second.
g_list_sort_with_data ()GList* g_list_sort_with_data (GList *list, GCompareDataFunc compare_func, gpointer user_data);
Like
GCompareDataFunc ()gint (*GCompareDataFunc) (gconstpointer a, gconstpointer b, gpointer user_data); Specifies the type of a comparison function used to compare two values. The function should return a negative integer if the first value comes before the second, 0 if they are equal, or a positive integer if the first value comes after the second.
g_list_concat ()GList* g_list_concat (GList *list1, GList *list2); Adds the second GList onto the end of the first GList. Note that the elements of the second GList are not copied. They are used directly. g_list_foreach ()void g_list_foreach (GList *list, GFunc func, gpointer user_data); Calls a function for each element of a GList.
GFunc ()void (*GFunc) (gpointer data, gpointer user_data);
Specifies the type of functions passed to
g_list_previous()#define g_list_previous(list) A convenience macro to gets the previous element in a GList.
g_list_next()#define g_list_next(list) A convenience macro to gets the next element in a GList.
g_list_nth ()GList* g_list_nth (GList *list, guint n); Gets the element at the given position in a GList. g_list_nth_data ()gpointer g_list_nth_data (GList *list, guint n); Gets the data of the element at the given position. g_list_nth_prev ()GList* g_list_nth_prev (GList *list, guint n);
Gets the element g_list_find ()GList* g_list_find (GList *list, gconstpointer data); Finds the element in a GList which contains the given data. g_list_find_custom ()GList* g_list_find_custom (GList *list, gconstpointer data, GCompareFunc func); Finds an element in a GList, using a supplied function to find the desired element. It iterates over the list, calling the given function which should return 0 when the desired element is found. The function takes two gconstpointer arguments, the GList element's data and the given user data. g_list_position ()gint g_list_position (GList *list, GList *llink); Gets the position of the given element in the GList (starting from 0). g_list_index ()gint g_list_index (GList *list, gconstpointer data); Gets the position of the element containing the given data (starting from 0).
g_list_push_allocator ()void g_list_push_allocator (GAllocator *allocator);
Sets the allocator to use to allocate GList elements.
Use
Note that this function is not available if GLib has been compiled
with
g_list_pop_allocator ()void g_list_pop_allocator (void); Restores the previous GAllocator, used when allocating GList elements.
Note that this function is not available if GLib has been compiled
with
|
:: Command execute :: | |
--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0045 ]-- |