typedef typedefG_BEGIN_DECLS struct _GSList | GSList |
IMPORT_C GSList * | g_slist_alloc | ( | void | ) |
IMPORT_C void | g_slist_free | ( | GSList * | list | ) |
g_slist_free: : a GSList
Frees all of the memory used by a GSList. The freed elements are returned to the slice allocator.
IMPORT_C void | g_slist_free_1 | ( | GSList * | list | ) |
g_slist_free_1: : a GSList element
Frees one GSList element. It is usually used after g_slist_remove_link().
g_slist_append: : a GSList : the data for the new element
Adds a new element on to the end of the list.
<note>
The return value is the new start of the list, which may have changed, so make sure you store the new value.
</note>
<note>
Note that g_slist_append() has to traverse the entire list to find the end, which is inefficient when adding multiple elements. A common idiom to avoid the inefficiency is to prepend the elements and reverse the list when all elements have been added.
</note>
|[ / Notice that these are initialized to the empty list. / GSList *list = NULL, *number_list = NULL;
/ This is a list of strings. / list = g_slist_append (list, "first"); list = g_slist_append (list, "second");
/ This is a list of integers. / number_list = g_slist_append (number_list, GINT_TO_POINTER (27)); number_list = g_slist_append (number_list, GINT_TO_POINTER (14)); ]|
Returns: the new start of the GSList
g_slist_prepend: : a GSList : the data for the new element
Adds a new element on to the start of the list.
<note>
The return value is the new start of the list, which may have changed, so make sure you store the new value.
</note>
|[ / Notice that it is initialized to the empty list. / GSList *list = NULL; list = g_slist_prepend (list, "last"); list = g_slist_prepend (list, "first"); ]|
Returns: the new start of the GSList
g_slist_insert: : a GSList : the data for the new element : the position to insert the element. If this is negative, or is larger than the number of elements in the list, the new element is added on to the end of the list.
Inserts a new element into the list at the given position.
Returns: the new start of the GSList
IMPORT_C GSList * | g_slist_insert_sorted | ( | GSList * | list, |
gpointer | data, | |||
GCompareFunc | func | |||
) |
g_slist_insert_sorted: : a GSList : the data for the new element : the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order.
Inserts a new element into the list, using the given comparison function to determine its position.
Returns: the new start of the GSList
IMPORT_C GSList * | g_slist_insert_sorted_with_data | ( | GSList * | list, |
gpointer | data, | |||
GCompareDataFunc | func, | |||
gpointer | user_data | |||
) |
g_slist_insert_sorted_with_data: : a GSList : the data for the new element : the function to compare elements in the list. It should return a number > 0 if the first parameter comes after the second parameter in the sort order. : data to pass to comparison function
Inserts a new element into the list, using the given comparison function to determine its position.
Returns: the new start of the GSList
Since: 2.10
g_slist_insert_before: : a GSList : node to insert before : data to put in the newly-inserted node
Inserts a node before containing .
Returns: the new head of the list.
g_slist_concat: : a GSList : the GSList to add to the end of the first GSList
Adds the second GSList onto the end of the first GSList. Note that the elements of the second GSList are not copied. They are used directly.
Returns: the start of the new GSList
IMPORT_C GSList * | g_slist_remove | ( | GSList * | list, |
gconstpointer | data | |||
) |
g_slist_remove: : a GSList : the data of the element to remove
Removes an element from a GSList. If two elements contain the same data, only the first is removed. If none of the elements contain the data, the GSList is unchanged.
Returns: the new start of the GSList
IMPORT_C GSList * | g_slist_remove_all | ( | GSList * | list, |
gconstpointer | data | |||
) |
g_slist_remove_all: : a GSList : data to remove
Removes all list nodes with data equal to . Returns the new head of the list. Contrast with g_slist_remove() which removes only the first node matching the given data.
Returns: new head of
g_slist_remove_link: : a GSList : an element in the GSList
Removes an element from a GSList, without freeing the element. The removed element's next link is set to NULL, so that it becomes a self-contained list with one element.
Returns: the new start of the GSList, without the element
g_slist_delete_link: : a GSList : node to delete
Removes the node link_ from the list and frees it. Compare this to g_slist_remove_link() which removes the node without freeing it.
Returns: the new head of
g_slist_copy: : a GSList
Copies a GSList.
<note>
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.
</note>
Returns: a copy of
g_slist_nth: : a GSList : the position of the element, counting from 0
Gets the element at the given position in a GSList.
Returns: the element, or NULL if the position is off the end of the GSList
IMPORT_C GSList * | g_slist_find | ( | GSList * | list, |
gconstpointer | data | |||
) |
g_slist_find: : a GSList : the element data to find
Finds the element in a GSList which contains the given data.
Returns: the found GSList element, or NULL if it is not found
IMPORT_C GSList * | g_slist_find_custom | ( | GSList * | list, |
gconstpointer | data, | |||
GCompareFunc | func | |||
) |
g_slist_find_custom: : a GSList : user data passed to the function : the function to call for each element. It should return 0 when the desired element is found
Finds an element in a GSList, 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 GSList element's data as the first argument and the given user data.
Returns: the found GSList element, or NULL if it is not found
g_slist_position: : a GSList : an element in the GSList
Gets the position of the given element in the GSList (starting from 0).
Returns: the position of the element in the GSList, or -1 if the element is not found
IMPORT_C gint | g_slist_index | ( | GSList * | list, |
gconstpointer | data | |||
) |
g_slist_index: : a GSList : the data to find
Gets the position of the element containing the given data (starting from 0).
Returns: the index of the element containing the data, or -1 if the data is not found
g_slist_last: : a GSList
Gets the last element in a GSList.
<note>
This function iterates over the whole list.
</note>
Returns: the last element in the GSList, or NULL if the GSList has no elements
g_slist_length: : a GSList
Gets the number of elements in a GSList.
<note>
This function iterates over the whole list to count its elements.
</note>
Returns: the number of elements in the GSList
g_slist_foreach: : a GSList : the function to call with each element's data : user data to pass to the function
Calls a function for each element of a GSList.
IMPORT_C GSList * | g_slist_sort | ( | GSList * | list, |
GCompareFunc | compare_func | |||
) |
g_slist_sort: : a GSList : the comparison function used to sort the GSList. This function is passed the data from 2 elements of the GSList and should return 0 if they are equal, a negative value if the first element comes before the second, or a positive value if the first element comes after the second.
Sorts a GSList using the given comparison function.
Returns: the start of the sorted GSList
IMPORT_C GSList * | g_slist_sort_with_data | ( | GSList * | list, |
GCompareDataFunc | compare_func, | |||
gpointer | user_data | |||
) |
g_slist_sort_with_data: : a GSList : comparison function : data to pass to comparison function
Like g_slist_sort(), but the sort function accepts a user data argument.
Returns: new head of the list
g_slist_nth_data: : a GSList : the position of the element
Gets the data of the element at the given position.
Returns: the element's data, or NULL if the position is off the end of the GSList