GLib.Queue
Description: Reference for GLib.Queue

### Struct

# GLibQueue

#### Description [src]

    struct GQueue {
      gpointer head;
      gpointer tail;
      guint length;
    }

Contains the public fields of a Queue.

###### Structure members

`head:` `gpointer`

  A pointer to the first element of the queue.

`tail:` `gpointer`

  A pointer to the last element of the queue.

`length:` `guint`

  The number of elements in the queue.

#### Functions

###### g_queue_new

Creates a new `GQueue`.

#### Instance methods

###### g_queue_clear

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

since: 2.14

###### g_queue_clear_full

Convenience method, which frees all the memory used by a `GQueue`, and calls the provided `free_func` on each item in the `GQueue`.

since: 2.60

###### g_queue_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

###### g_queue_delete_link

Removes `link_` from `queue` and frees it.

since: 2.4

###### g_queue_find

Finds the first link in `queue` which contains `data`.

since: 2.4

###### g_queue_find_custom

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

###### g_queue_foreach

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

since: 2.4

###### g_queue_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.

###### g_queue_free_full

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

###### g_queue_get_length

Returns the number of items in `queue`.

since: 2.4

###### g_queue_index

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

since: 2.4

###### g_queue_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

###### g_queue_insert_after

Inserts `data` into `queue` after `sibling`.

since: 2.4

###### g_queue_insert_after_link

Inserts `link_` into `queue` after `sibling`.

since: 2.62

###### g_queue_insert_before

Inserts `data` into `queue` before `sibling`.

since: 2.4

###### g_queue_insert_before_link

Inserts `link_` into `queue` before `sibling`.

since: 2.62

###### g_queue_insert_sorted

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

since: 2.4

###### g_queue_is_empty

Returns `TRUE` if the queue is empty.

###### g_queue_link_index

Returns the position of `link_` in `queue`.

since: 2.4

###### g_queue_peek_head

Returns the first element of the queue.

###### g_queue_peek_head_link

Returns the first link in `queue`.

since: 2.4

###### g_queue_peek_nth

Returns the `n`‘th element of `queue`.

since: 2.4

###### g_queue_peek_nth_link

Returns the link at the given position.

since: 2.4

###### g_queue_peek_tail

Returns the last element of the queue.

###### g_queue_peek_tail_link

Returns the last link in `queue`.

since: 2.4

###### g_queue_pop_head

Removes the first element of the queue and returns its data.

###### g_queue_pop_head_link

Removes and returns the first element of the queue.

###### g_queue_pop_nth

Removes the `n`‘th element of `queue` and returns its data.

since: 2.4

###### g_queue_pop_nth_link

Removes and returns the link at the given position.

since: 2.4

###### g_queue_pop_tail

Removes the last element of the queue and returns its data.

###### g_queue_pop_tail_link

Removes and returns the last element of the queue.

###### g_queue_push_head

Adds a new element at the head of the queue.

###### g_queue_push_head_link

Adds a new element at the head of the queue.

###### g_queue_push_nth

Inserts a new element into `queue` at the given position.

since: 2.4

###### g_queue_push_nth_link

Inserts `link` into `queue` at the given position.

since: 2.4

###### g_queue_push_tail

Adds a new element at the tail of the queue.

###### g_queue_push_tail_link

Adds a new element at the tail of the queue.

###### g_queue_remove

Removes the first element in `queue` that contains `data`.

since: 2.4

###### g_queue_remove_all

Remove all elements whose data equals `data` from `queue`.

since: 2.4

###### g_queue_reverse

Reverses the order of the items in `queue`.

since: 2.4

###### g_queue_sort

Sorts `queue` using `compare_func`.

since: 2.4

###### g_queue_unlink

Unlinks `link_` so that it will no longer be part of `queue`. The link is not freed.

since: 2.4