SequenceIter
Object Hierarchy:
Description:
[
Compact ]
[
Version ( since =
"2.14" ) ]
[
CCode ( ref_function =
"" , unref_function =
"" ) ]
public class SequenceIter<
G>
The SequenceIter struct is an opaque data type representing an iterator pointing into a
Sequence.
Example: Sequence, iter:
public static int main (string[] args) {
Sequence<string> seq = new Sequence<string> ();
seq.append ("Lorem");
seq.append ("ipsum");
seq.append ("dolor");
seq.append ("sit");
seq.append ("amet");
// Output:
// ``Lorem
// ``ipsum``
// ``dolor``
// ``sit``
// ``amet``
for (SequenceIter<string> iter = seq.get_begin_iter (); !iter.is_end (); iter = iter.next ()) {
print ("%d: %s\n", iter.get_position (), iter.get ());
}
// Output:
// ``amet``
// ``sit``
// ``dolor``
// ``ipsum``
// ``Lorem``
SequenceIter<string> iter = seq.get_end_iter ().prev ();
bool has_next = !iter.is_begin ();
while (has_next) {
print ("%d: %s\n", iter.get_position (), iter.get ());
has_next = !iter.is_begin ();
iter = iter.prev ();
}
return 0;
}
valac --pkg glib-2.0 GLib.SequenceIter.vala
Content:
Methods:
- public unowned G @get ()
Returns the data that iter
points to.
- public void @set (owned G data)
Changes the data for the item pointed to by iter
to be
data
.
- public int compare (SequenceIter<G> other)
Returns a negative number if this comes
before b
, 0 if they are equal, and a positive number if this comes after b
.
- public void foreach_range (SequenceIter<G> end, Func<G> func)
Calls func
for each item in the range (begin
,
end
) passing user_data
to the function.
- public int get_position ()
Returns the position of this
- public unowned Sequence<G> get_sequence ()
Returns the Sequence
that this points into.
- public SequenceIter<G> insert_before (owned G data)
Inserts a new item just before the item pointed to by iter
.
- public bool is_begin ()
Returns whether this is the begin iterator
- public bool is_end ()
Returns whether this is the end iterator
- public SequenceIter<G> move (int delta)
Returns the SequenceIter which is delta
positions away from this.
- public void move_range (SequenceIter<G> begin, SequenceIter<G> end)
Inserts the (begin
, end
) range at the destination
pointed to by dest
.
- public void move_to (SequenceIter<G> dest)
Moves the item pointed to by src
to the position indicated by
dest
.
- public SequenceIter<G> next ()
Returns an iterator pointing to the next position after
this.
- public SequenceIter<G> prev ()
Returns an iterator pointing to the previous position before
this.
- public SequenceIter<G> range_get_midpoint (SequenceIter<G> end)
Finds an iterator somewhere in the range (begin
, end
).
- public void remove ()
Removes the item pointed to by iter
.
- public void remove_range (SequenceIter<G> end)
Removes all items in the (begin
, end
) range.
- public void sort_changed (CompareDataFunc<G> cmp_func)
Moves the data pointed to by iter
to a new position as
indicated by cmp_func
.
- public void sort_changed_iter (SequenceIterCompareFunc<G> iter_cmp)
- public void swap (SequenceIter<G> dest)
Swaps the items pointed to by a
and b
.