Struct
GLibSList
Description [src]
struct GSList {
gpointer data;
GSList* next;
}
The GSList
struct is used for each element in the singly-linked list.
Structure members
data
Holds the element’s data, which can be a pointer to any kind of data, or any integer value using the [Type Conversion Macros][glib-Type-Conversion-Macros].
next
Contains the link to the next element in the list.
Functions
g_slist_alloc
Allocates space for one GSList
element. It is called by the
g_slist_append(), g_slist_prepend(), g_slist_insert()
and
g_slist_insert_sorted()
functions and so is rarely used on its own.
g_slist_concat
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.
g_slist_delete_link
Removes the node link_ from the list and frees it.
Compare this to g_slist_remove_link()
which removes the node
without freeing it.
g_slist_find_custom
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.
g_slist_free
Frees all of the memory used by a GSList
.
The freed elements are returned to the slice allocator.
g_slist_free_full
Convenience method, which frees all the memory used by a GSList
, and
calls the specified destroy function on every element’s data.
since: 2.28
g_slist_insert_sorted
Inserts a new element into the list, using the given comparison function to determine its position.
g_slist_insert_sorted_with_data
Inserts a new element into the list, using the given comparison function to determine its position.
since: 2.10
g_slist_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.
g_slist_remove_all
Removes all list nodes with data equal to data
.
Returns the new head of the list. Contrast with
g_slist_remove()
which removes only the first node
matching the given data.
g_slist_remove_link
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.
g_slist_sort
Sorts a GSList
using the given comparison function. The algorithm
used is a stable sort.