GLib.Queue¶
record (struct)
Contains the public fields of a Queue.
Methods¶
clear¶
Removes all the elements in queue. If queue elements contain
dynamically-allocated memory, they should be freed first.
clear_full¶
Convenience method, which frees all the memory used by a Queue,
and calls the provided free_func on each item in the Queue.
Parameters:
free_func— the function to be called to free memory allocated
foreach¶
Calls func for each element in the queue passing user_data to the
function.
It is safe for func to remove the element from queue, but it must
not modify any part of the queue after that element.
Parameters:
func— the function to call for each element's data
free¶
Frees the memory allocated for the Queue. Only call this function
if queue 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 Queue.free_full or free them manually first.
free_full¶
Convenience method, which frees all the memory used by a 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).
Parameters:
free_func— the function to be called to free each element's data
get_length¶
Returns the number of items in queue.
index¶
Returns the position of the first element in queue which contains data.
Parameters:
data— the data to find
init¶
A statically-allocated 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().
insert_sorted¶
Inserts data into queue using func to determine the new position.
Parameters:
data— the data to insertfunc— theGCompareDataFuncused to compare elements in the queue. It is called with two elements of thequeueanduser_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.
is_empty¶
Returns True if the queue is empty.
peek_head¶
Returns the first element of the queue.
peek_nth¶
Returns the n'th element of queue.
Parameters:
n— the position of the element
peek_tail¶
Returns the last element of the queue.
pop_head¶
Removes the first element of the queue and returns its data.
pop_nth¶
Removes the n'th element of queue and returns its data.
Parameters:
n— the position of the element
pop_tail¶
Removes the last element of the queue and returns its data.
push_head¶
Adds a new element at the head of the queue.
Parameters:
data— the data for the new element.
push_nth¶
Inserts a new element into queue at the given position.
Parameters:
data— the data for the new elementn— the position to insert the new element. Ifnis negative or larger than the number of elements in thequeue, the element is added to the end of the queue.
push_tail¶
Adds a new element at the tail of the queue.
Parameters:
data— the data for the new element
remove¶
Removes the first element in queue that contains data.
Parameters:
data— the data to remove
remove_all¶
Remove all elements whose data equals data from queue.
Parameters:
data— the data to remove
reverse¶
Reverses the order of the items in queue.
sort¶
Sorts queue using compare_func.
Parameters:
compare_func— theGCompareDataFuncused to sortqueue. 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.