Queue
Object Hierarchy:
Description:
[
Compact ]
[
CCode ( dup_function =
"g_queue_copy" , free_function =
"g_queue_free" ) ]
public class Queue<
G>
Contains the public fields of a Queue.
Example: Queues and Stacks:
public static int main () {
Queue<string> queue = new Queue<string> ();
queue.push_tail ("1");
queue.push_tail ("2");
queue.push_tail ("3");
// Output: ``1 2 3 ``
string item = null;
while ((item = queue.pop_head ()) != null) {
print ("%s ", item);
}
print ("\n");
Queue<string> stack = new Queue<string> ();
stack.push_head ("1");
stack.push_head ("2");
stack.push_head ("3");
// Output: ``3 2 1 ``
while ((item = stack.pop_head ()) != null) {
print ("%s ", item);
}
print ("\n");
return 0;
}
valac --pkg glib-2.0 GLib.Queue.vala
Content:
Creation methods:
Methods:
- public void clear ()
Removes all the elements in this.
- public void clear_full (DestroyNotify? free_func)
Convenience method, which frees all the memory used by a
Queue, and calls the provided free_func
on each item in the Queue.
- public Queue<G> copy ()
Copies a this.
- public void delete_link (List<G> link)
Removes link_
from this and
frees it.
- public unowned List<G> find (G data)
Finds the first link in this which
contains data
.
- public unowned List<G> find_custom (G data, CompareFunc<G> func)
- public uint get_length ()
Returns the number of items in this.
- public int index (G data)
Returns the position of the first element in this
which contains data
.
- public void insert_after (List<G> sibling, owned G data)
Inserts data
into this after
sibling
.
- public void insert_after_link (List<G> sibling, owned List<G> link_)
Inserts link_
into this after
sibling
.
- public void insert_before (List<G> sibling, owned G data)
Inserts data
into this before
sibling
.
- public void insert_before_link (List<G> sibling, owned List<G> link_)
Inserts link_
into this
before sibling
.
- public void insert_sorted (owned G data, CompareDataFunc<G> func)
Inserts data
into this using
func
to determine the new position.
- public bool is_empty ()
Returns true if the queue is empty.
- public unowned G peek_head ()
Returns the first element of the queue.
- public unowned G peek_nth (uint n)
Returns the n
'th element of this
.
- public unowned G peek_tail ()
Returns the last element of the queue.
- public G pop_head ()
Removes the first element of the queue and returns its data.
- public G pop_nth (uint n)
Removes the n
'th element of this
and returns its data.
- public G pop_tail ()
Removes the last element of the queue and returns its data.
- public void push_head (owned G data)
Adds a new element at the head of the queue.
- public void push_nth (owned G data, int n)
Inserts a new element into this at the
given position.
- public void push_tail (owned G data)
Adds a new element at the tail of the queue.
- public bool remove (G data)
Removes the first element in this that
contains data
.
- public uint remove_all (G data)
Remove all elements whose data equals data
from
this.
- public uint remove_all_full (G data, FreeFunc? func)
- public bool remove_full (G data, FreeFunc? func)
- public void reverse ()
Reverses the order of the items in this.
- public unowned List<G> search<T> (T data, SearchFunc<G,T> func)
Finds an element in a Queue, using a supplied
function to find the desired element.
- public void sort (CompareDataFunc<G> compare_func)
Sorts this using compare_func
.
- public void unlink (List<G> link)
Unlinks link_
so that it will no longer be part of
this.
Fields: