ListG

The #GList struct is used for each element in a doubly-linked list.

Constructors

this
this(GList* gList, bool ownedRef)

Sets our main struct and passes it to the parent class.

Members

Aliases

foreac
alias foreac = foreach_
Undocumented in source.

Functions

append
ListG append(void* data)

Adds a new element on to the end of the list.

concat
ListG concat(ListG 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.

copy
ListG copy()

Copies a #GList.

copyDeep
ListG copyDeep(GCopyFunc func, void* userData)

Makes a full (deep) copy of a #GList.

deleteLink
ListG deleteLink(ListG link)

Removes the node link_ from the list and frees it. Compare this to g_list_remove_link() which removes the node without freeing it.

find
ListG find(void* data)

Finds the element in a #GList which contains the given data.

findCustom
ListG findCustom(void* 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 as the first argument and the given user data.

first
ListG first()

Gets the first element in a #GList.

foreach_
void foreach_(GFunc func, void* userData)

Calls a function for each element of a #GList.

free
void free()

Frees all of the memory used by a #GList. The freed elements are returned to the slice allocator.

free1
void free1()

Frees one #GList element, but does not update links from the next and previous elements in the list, so you should not call this function on an element that is currently part of a list.

freeFull
void freeFull(GDestroyNotify freeFunc)

Convenience method, which frees all the memory used by a #GList, and calls @free_func on every element's data.

getListGStruct
GList* getListGStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

index
int index(void* data)

Gets the position of the element containing the given data (starting from 0).

insert
ListG insert(void* data, int position)

Inserts a new element into the list at the given position.

insertBefore
ListG insertBefore(ListG sibling, void* data)

Inserts a new element into the list before the given position.

insertBeforeLink
ListG insertBeforeLink(ListG sibling, ListG link)

Inserts @link_ into the list before the given position.

insertSorted
ListG insertSorted(void* data, GCompareFunc func)

Inserts a new element into the list, using the given comparison function to determine its position.

insertSortedWithData
ListG insertSortedWithData(void* data, GCompareDataFunc func, void* userData)

Inserts a new element into the list, using the given comparison function to determine its position.

last
ListG last()

Gets the last element in a #GList.

length
uint length()

Gets the number of elements in a #GList.

nth
ListG nth(uint n)

Gets the element at the given position in a #GList.

nthData
void* nthData(uint n)

Gets the data of the element at the given position.

nthPrev
ListG nthPrev(uint n)

Gets the element @n places before @list.

position
int position(ListG llink)

Gets the position of the given element in the #GList (starting from 0).

prepend
ListG prepend(void* data)

Prepends a new element on to the start of the list.

remove
ListG remove(void* 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.

removeAll
ListG removeAll(void* data)

Removes all list nodes with data equal to @data. Returns the new head of the list. Contrast with g_list_remove() which removes only the first node matching the given data.

removeLink
ListG removeLink(ListG llink)

Removes an element from a #GList, without freeing the element. The removed element's prev and next links are set to %NULL, so that it becomes a self-contained list with one element.

reverse
ListG reverse()

Reverses a #GList. It simply switches the next and prev pointers of each element.

sort
ListG sort(GCompareFunc compareFunc)

Sorts a #GList using the given comparison function. The algorithm used is a stable sort.

sortWithData
ListG sortWithData(GCompareDataFunc compareFunc, void* userData)

Like g_list_sort(), but the comparison function accepts a user data argument.

toArray
T[] toArray()

Turn the list into a D array of the desiered type. Type T wraps should match the type of the data.

Properties

data
void* data [@property getter]
next
ListG next [@property getter]

get the next element

previous
ListG previous [@property getter]

get the previous element

Static functions

alloc
ListG alloc()

Allocates space for one #GList element. It is called by g_list_append(), g_list_prepend(), g_list_insert() and g_list_insert_sorted() and so is rarely used on its own.

clearList
void clearList(ListG listPtr, GDestroyNotify destroy)

Clears a pointer to a #GList, freeing it and, optionally, freeing its elements using @destroy.

Variables

gList
GList* gList;

the main Gtk struct

ownedRef
bool ownedRef;
Undocumented in source.

Meta