insert_sorted
Description:
Inserts data
into this using func
to determine the new position.
Example: Insert sorted:
public static int main () {
Queue<string> queue = new Queue<string> ();
bool asc = true;
CompareDataFunc<string> cmpfunc = (a, b) => {
return (asc)? strcmp (a, b) : strcmp (b, a);
};
queue.insert_sorted ("2", cmpfunc);
queue.insert_sorted ("1", cmpfunc);
queue.insert_sorted ("3", cmpfunc);
// Output: ``1 2 3 ``
string item = null;
while ((item = queue.pop_head ()) != null) {
print ("%s ", item);
}
print ("\n");
return 0;
}
valac --pkg glib-2.0 GLib.Queue.insert_sorted.vala
Parameters:
this |
a Queue |
data |
the data to insert |
func |
the CompareDataFunc used to compare elements in the queue. It is
called with two elements of the this and |
user_data |
user data passed to |