push_nth


Description:

[ Version ( since = "2.4" ) ]
public void push_nth (owned G data, int n)

Inserts a new element into this at the given position.

Example: Push nth:

public static int main (string[] args) {
Queue<string> queue = new Queue<string> ();
queue.push_tail ("1");
queue.push_tail ("3");
queue.push_tail ("4");

queue.push_nth ("2", 1);

// Output: ``1 2 3 4``
string item;
while ((item = queue.pop_head ()) != null) {
print ("%s ", item);
}
print ("\n");

return 0;
}

valac --pkg glib-2.0 GLib.Queue.push_nth.vala

Parameters:

this

a Queue

data

the data for the new element

n

the position to insert the new element. If n is negative or larger than the number of elements in the this, the element is added to the end of the queue.