sort_changed_iter
Description:
[ CCode ( cname = "g_sequence_sort_changed_iter" ) ]
public void sort_changed_iter (SequenceIterCompareFunc<G> iter_cmp)
public void sort_changed_iter (SequenceIterCompareFunc<G> iter_cmp)
Like sort_changed, but uses a SequenceIterCompareFunc instead of a CompareDataFunc as the compare function.
iter_cmp
is called with two iterators pointing into the Sequence that
iter
points into. It should return 0 if the iterators are equal, a negative value if the first iterator comes before the second,
and a positive value if the second iterator comes before the first.
Example: Moves the data pointed to a new position as indicated by cmp_func (iter-based):
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_iter ((a, b) => {
return strcmp (a.get (), b.get ());
});
// 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_iter.vala
Parameters:
iter_cmp |
the function used to compare iterators in the sequence |
cmp_data |
user data passed to |
iter |