GLib.Queue¶
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
head |
[ |
r/w |
a pointer to the first element of the queue |
length |
r/w |
the number of elements in the queue |
|
tail |
[ |
r/w |
a pointer to the last element of the queue |
Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 allocated
Convenience 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 data
Convenience 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:
Returns the number of items in self.
New in version 2.4.
- index(data)[source]¶
- Parameters:
- Returns:
the position of the first element in self which contains data, or -1 if no element in self contains data
- Return type:
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.
- peek_head()[source]¶
- Returns:
the data of the first element in the queue, or
None
if the queue is empty- Return type:
Returns the first element of the queue.
- peek_nth(n)[source]¶
- Parameters:
n (
int
) – the position of the element- Returns:
the data for the n'th element of self, or
None
if n is off the end of self- Return type:
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 empty- Return type:
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 empty- Return type:
Removes the first element of the queue and returns its data.
- pop_nth(n)[source]¶
- Parameters:
n (
int
) – the position of the element- Returns:
the element’s data, or
None
if n is off the end of self- Return type:
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 empty- Return type:
Removes the last element of the queue and returns its data.
- push_nth(data, n)[source]¶
- Parameters:
Inserts a new element into self at the given position.
New in version 2.4.
- remove(data)[source]¶
- Parameters:
- Returns:
True
if data was found and removed from self- Return type:
Removes the first element in self that contains data.
New in version 2.4.