insert_sorted_iter
Description:
Like insert_sorted, but uses a SequenceIterCompareFunc instead of a CompareDataFunc as the compare function.
iter_cmp
is called with two iterators pointing into this. 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.
Note that when adding a large amount of data to a Sequence, it is more efficient to do unsorted insertions and then call sort or sort_iter.
Example: Insert sorted, iter:
public static int main (string[] args) {
Sequence<string> seq = new Sequence<string> ();
seq.append ("1. Lorem");
seq.append ("2. ipsum");
seq.append ("4. sit");
seq.append ("5. amet");
seq.insert_sorted_iter ("3. dolor", (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.Sequence.insert_sorted_iter.vala
Parameters:
this |
a Sequence |
data |
data for the new item |
iter_cmp |
the function used to compare iterators in the sequence |
cmp_data |
user data passed to |
Returns:
a SequenceIter pointing to the new item |