sort_changed
Description:
[ CCode ( cname = "g_sequence_sort_changed" ) ]
public void sort_changed (CompareDataFunc<G> cmp_func)
public void sort_changed (CompareDataFunc<G> cmp_func)
Moves the data pointed to by iter
to a new position as indicated by cmp_func
.
This function should be called for items in a sequence already sorted according to cmp_func
whenever some aspect of an item
changes so that cmp_func
may return different values for that item.
cmp_func
is called with two items of the seq
, and cmp_data
. It should return 0 if the items are equal, a
negative value if the first item comes before the second, and a positive value if the second item comes before the first.
Example: Moves the data pointed to a new position as indicated by cmp_func:
public static int main (string[] args) {
Sequence<string> seq = new Sequence<string> ();
// Sorted data:
seq.append ("1. Lorem");
seq.append ("2. ipsum");
seq.append ("4. sit");
seq.append ("5. amet");
seq.append ("3. dolor");
SequenceIter<string> iter = seq.get_end_iter ().prev ();
iter.sort_changed ((a, b) => {
return strcmp (a, b);
});
// Output:
// ``1. Lorem``
// ``2. ipsum``
// ``3. dolor``
// ``4. sit``
// ``5. amet``
seq.foreach ((item) => {
print ("%s\n", item);
});
return 0;
}
valac --pkg glib-2.0 GLib.SequenceIter.sort_changed.vala
Parameters:
cmp_func |
the function used to compare items in the sequence |
cmp_data |
user data passed to |
iter |