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.
- foreach(func, *user_data)[source]¶
- Parameters:
Calls func for each element in the queue passing user_data to the function.
It is safe for func to remove the element from self, but it must not modify any part of the queue after that element.
New in version 2.4.
- 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.
- insert_sorted(data, func, *user_data)[source]¶
- Parameters:
func (
GLib.CompareDataFunc
) – theGLib.CompareDataFunc
used to compare elements in the queue. It is called with two elements of the self and user_data. It should return 0 if the elements are equal, a negative value if the first element comes before the second, and a positive value if the second element comes before the first.
Inserts data into self using func to determine the new position.
New in version 2.4.
- 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.
- remove_all(data)[source]¶
- Parameters:
- Returns:
the number of elements removed from self
- Return type:
Remove all elements whose data equals data from self.
New in version 2.4.
- sort(compare_func, *user_data)[source]¶
- Parameters:
compare_func (
GLib.CompareDataFunc
) – theGLib.CompareDataFunc
used to sort self. This function is passed two elements of the queue and should return 0 if they are equal, a negative value if the first comes before the second, and a positive value if the second comes before the first.user_data (
object
orNone
) – user data passed to compare_func
Sorts self using compare_func.
New in version 2.4.