range_get_midpoint


Description:

[ CCode ( cname = "g_sequence_range_get_midpoint" ) ]
public SequenceIter<G> range_get_midpoint (SequenceIter<G> end)

Finds an iterator somewhere in the range (begin, end).

This iterator will be close to the middle of the range, but is not guaranteed to be exactly in the middle.

The begin and end iterators must both point to the same sequence and begin must come before or be equal to end in the sequence.

Example: Get the midpoint of a range:

public static int main (string[] args) {
Sequence<string> seq = new Sequence<string> ();
seq.append ("Lorem");
seq.append ("ipsum");
seq.append ("sit");
seq.append ("amet");

SequenceIter<string> iter1 = seq.get_iter_at_pos (0);
SequenceIter<string> iter2 = seq.get_iter_at_pos (3);

// Output: ``1``
SequenceIter<string> res = iter1.range_get_midpoint (iter2);
print ("%u\n", res.get_position ());

// Output: ``2``
iter1 = seq.get_iter_at_pos (1);
res = iter1.range_get_midpoint (iter2);
print ("%u\n", res.get_position ());

return 0;
}

valac --pkg glib-2.0 GLib.SequenceIter.range_get_midpoint.vala

Parameters:

end

a SequenceIter

begin

a SequenceIter

Returns:

a SequenceIter pointing somewhere in the (begin, end ) range