copy
Description:
Copies a this.
Note that is a shallow copy. If the elements in the queue consist of pointers to data, the pointers are copied, but the actual data is not.
Example: Copy:
public static int main () {
Queue<int> queue = new Queue<int> ();
queue.push_tail (1);
queue.push_tail (2);
queue.push_tail (3);
Queue<int> copy = queue.copy ();
// Output: ``Queue: 1 2 3 ``
print ("Queue: ");
int item = 0;
while ((item = queue.pop_head ()) != 0) {
print (@"$item ");
}
print ("\n");
// Output: ``Stats: queue: 0, copy: 3``
print ("Stats: queue: %u, copy: %u\n", queue.get_length (), copy.get_length ());
// Output: ``copy: 1 2 3 ``
print ("Copy: ");
while ((item = copy.pop_head ()) != 0) {
print (@"$item ");
}
print ("\n");
// Output: ``Stats: queue: 0, copy: 0``
print ("Stats: queue: %u, copy: %u\n", queue.get_length (), copy.get_length ());
return 0;
}
valac --pkg glib-2.0 GLib.Queue.copy.vala
Parameters:
this |
a Queue |
Returns:
a copy of this |