QueueG

The GQueue structure and its associated functions provide a standard queue data structure. Internally, GQueue uses the same data structure as GList to store elements.

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.

To create a new GQueue, use g_queue_new().

To initialize a statically-allocated GQueue, use G_QUEUE_INIT or g_queue_init().

To add elements, use g_queue_push_head(), g_queue_push_head_link(), g_queue_push_tail() and g_queue_push_tail_link().

To remove elements, use g_queue_pop_head() and g_queue_pop_tail().

To free the entire queue, use g_queue_free().

Constructors

this
this(GQueue* gQueue)

Sets our main struct and passes it to the parent class

this
this()

Creates a new GQueue.

Members

Functions

clear
void clear()

Removes all the elements in queue. If queue elements contain dynamically-allocated memory, they should be freed first. Since 2.14

copy
QueueG copy()

Copies a queue. Note that is a shallow copy. If the elements in the queue consist of pointers to data, the pointers are copied, but the actual data is not. Since 2.4

deleteLink
void deleteLink(ListG link)

Removes link_ from queue and frees it. link_ must be part of queue. Since 2.4

find
ListG find(void* data)

Finds the first link in queue which contains data. Since 2.4

findCustom
ListG findCustom(void* data, GCompareFunc func)

Finds an element in a GQueue, using a supplied function to find the desired element. It iterates over the queue, calling the given function which should return 0 when the desired element is found. The function takes two gconstpointer arguments, the GQueue element's data as the first argument and the given user data as the second argument. Since 2.4

foreac
void foreac(GFunc func, void* userData)

Calls func for each element in the queue passing user_data to the function. Since 2.4

free
void free()

Frees the memory allocated for the GQueue. Only call this function if queue was created with g_queue_new(). If queue elements contain dynamically-allocated memory, they should be freed first. Note If queue elements contain dynamically-allocated memory, you should either use g_queue_free_full() or free them manually first.

freeFull
void freeFull(GDestroyNotify freeFunc)

Convenience method, which frees all the memory used by a GQueue, and calls the specified destroy function on every element's data. Since 2.32

getLength
uint getLength()

Returns the number of items in queue. Since 2.4

getQueueGStruct
GQueue* getQueueGStruct()

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

index
int index(void* data)

Returns the position of the first element in queue which contains data. Since 2.4

init
void init()

A statically-allocated GQueue must be initialized with this function before it can be used. Alternatively you can initialize it with G_QUEUE_INIT. It is not necessary to initialize queues created with g_queue_new(). Since 2.14

insertAfter
void insertAfter(ListG sibling, void* data)

Inserts data into queue after sibling sibling must be part of queue Since 2.4

insertBefore
void insertBefore(ListG sibling, void* data)

Inserts data into queue before sibling. sibling must be part of queue. Since 2.4

insertSorted
void insertSorted(void* data, GCompareDataFunc func, void* userData)

Inserts data into queue using func to determine the new position. Since 2.4

isEmpty
int isEmpty()

Returns TRUE if the queue is empty.

linkIndex
int linkIndex(ListG link)

Returns the position of link_ in queue. Since 2.4

peekHead
void* peekHead()

Returns the first element of the queue.

peekHeadLink
ListG peekHeadLink()

Returns the first link in queue Since 2.4

peekNth
void* peekNth(uint n)

Returns the n'th element of queue. Since 2.4

peekNthLink
ListG peekNthLink(uint n)

Returns the link at the given position Since 2.4

peekTail
void* peekTail()

Returns the last element of the queue.

peekTailLink
ListG peekTailLink()

Returns the last link queue. Since 2.4

popHead
void* popHead()

Removes the first element of the queue.

popHeadLink
ListG popHeadLink()

Removes the first element of the queue.

popNth
void* popNth(uint n)

Removes the n'th element of queue. Since 2.4

popNthLink
ListG popNthLink(uint n)

Removes and returns the link at the given position. Since 2.4

popTail
void* popTail()

Removes the last element of the queue.

popTailLink
ListG popTailLink()

Removes the last element of the queue.

pushHead
void pushHead(void* data)

Adds a new element at the head of the queue.

pushHeadLink
void pushHeadLink(ListG link)

Adds a new element at the head of the queue.

pushNth
void pushNth(void* data, int n)

Inserts a new element into queue at the given position Since 2.4

pushNthLink
void pushNthLink(int n, ListG link)

Inserts link into queue at the given position. Since 2.4

pushTail
void pushTail(void* data)

Adds a new element at the tail of the queue.

pushTailLink
void pushTailLink(ListG link)

Adds a new element at the tail of the queue.

remove
int remove(void* data)

Removes the first element in queue that contains data. Since 2.4

removeAll
uint removeAll(void* data)

Remove all elements whose data equals data from queue. Since 2.4

reverse
void reverse()

Reverses the order of the items in queue. Since 2.4

sort
void sort(GCompareDataFunc compareFunc, void* userData)

Sorts queue using compare_func. Since 2.4

unlink
void unlink(ListG link)

Unlinks link_ so that it will no longer be part of queue. The link is not freed. link_ must be part of queue, Since 2.4

Variables

gQueue
GQueue* gQueue;

the main Gtk struct

Meta