GLib.Queue¶
Fields¶
Name | Type | Access | Description |
---|---|---|---|
head | [object ] |
r/w | a pointer to the first element of the queue |
length | int |
r/w | the number of elements in the queue |
tail | [object ] |
r/w | a pointer to the last element of the queue |
Methods¶
clear () |
|
clear_full (free_func) |
|
free () |
|
free_full (free_func) |
|
get_length () |
|
index (data) |
|
init () |
|
is_empty () |
|
peek_head () |
|
peek_nth (n) |
|
peek_tail () |
|
pop_head () |
|
pop_nth (n) |
|
pop_tail () |
|
push_head (data) |
|
push_nth (data, n) |
|
push_tail (data) |
|
remove (data) |
|
remove_all (data) |
|
reverse () |
Details¶
-
class
GLib.
Queue
¶ Contains the public fields of a Queue.
-
clear
()[source]¶ Removes all the elements in self. If queue elements contain dynamically-allocated memory, they should be freed first.
New in version 2.14.
-
clear_full
(free_func)[source]¶ Parameters: free_func ( GLib.DestroyNotify
orNone
) – the function to be called to free memory allocatedConvenience method, which frees all the memory used by a
GLib.Queue
, and calls the provided free_func on each item in theGLib.Queue
.New in version 2.60.
-
free
()[source]¶ Frees the memory allocated for the
GLib.Queue
. Only call this function if self was created with g_queue_new(). If queue elements contain dynamically-allocated memory, they should be freed first.If queue elements contain dynamically-allocated memory, you should either use
GLib.Queue.free_full
() or free them manually first.
-
free_full
(free_func)[source]¶ Parameters: free_func ( GLib.DestroyNotify
) – the function to be called to free each element’s dataConvenience method, which frees all the memory used by a
GLib.Queue
, and calls the specified destroy function on every element’s data.free_func should not modify the queue (eg, by removing the freed element from it).
New in version 2.32.
-
get_length
()[source]¶ Returns: the number of items in self Return type: int
Returns the number of items in self.
New in version 2.4.
-
index
(data)[source]¶ Parameters: data ( object
orNone
) – the data to findReturns: the position of the first element in self which contains data, or -1 if no element in self contains data Return type: int
Returns the position of the first element in self which contains data.
New in version 2.4.
-
init
()[source]¶ A statically-allocated
GLib.Queue
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().New in version 2.14.
-
is_empty
()[source]¶ Returns: True
if the queue is emptyReturn type: bool
Returns
True
if the queue is empty.
-
peek_head
()[source]¶ Returns: the data of the first element in the queue, or None
if the queue is emptyReturn type: object
orNone
Returns the first element of the queue.
-
peek_nth
(n)[source]¶ Parameters: n ( int
) – the position of the elementReturns: the data for the n’th element of self, or None
if n is off the end of selfReturn type: object
orNone
Returns the n’th element of self.
New in version 2.4.
-
peek_tail
()[source]¶ Returns: the data of the last element in the queue, or None
if the queue is emptyReturn type: object
orNone
Returns the last element of the queue.
-
pop_head
()[source]¶ Returns: the data of the first element in the queue, or None
if the queue is emptyReturn type: object
orNone
Removes the first element of the queue and returns its data.
-
pop_nth
(n)[source]¶ Parameters: n ( int
) – the position of the elementReturns: the element’s data, or None
if n is off the end of selfReturn type: object
orNone
Removes the n’th element of self and returns its data.
New in version 2.4.
-
pop_tail
()[source]¶ Returns: the data of the last element in the queue, or None
if the queue is emptyReturn type: object
orNone
Removes the last element of the queue and returns its data.
-
push_head
(data)[source]¶ Parameters: data ( object
orNone
) – the data for the new element.Adds a new element at the head of the queue.
-
push_nth
(data, n)[source]¶ Parameters: Inserts a new element into self at the given position.
New in version 2.4.
-
push_tail
(data)[source]¶ Parameters: data ( object
orNone
) – the data for the new elementAdds a new element at the tail of the queue.
-
remove
(data)[source]¶ Parameters: data ( object
orNone
) – the data to removeReturns: True
if data was found and removed from selfReturn type: bool
Removes the first element in self that contains data.
New in version 2.4.
-