![]() |
![]() |
![]() |
Reference Manual of the tinymail framework | ![]() |
---|---|---|---|---|
TnyIterator; TnyIteratorIface; void tny_iterator_next (TnyIterator *self); void tny_iterator_prev (TnyIterator *self); void tny_iterator_first (TnyIterator *self); void tny_iterator_nth (TnyIterator *self, guint nth); GObject* tny_iterator_get_current (TnyIterator *self); gboolean tny_iterator_is_done (TnyIterator *self); TnyList* tny_iterator_get_list (TnyIterator *self);
An iterator for a TnyList is used for iterating over a list. The iterator is an instance that keeps the position state information. The TnyList instance will not by itself keep a position state. Only iterators can keep a position state for a list.
typedef struct { GTypeInterface parent; void (*next_func) (TnyIterator *self); void (*prev_func) (TnyIterator *self); void (*first_func) (TnyIterator *self); void (*nth_func) (TnyIterator *self, guint nth); GObject* (*get_current_func) (TnyIterator *self); gboolean (*is_done) (TnyIterator *self); TnyList* (*get_list_func) (TnyIterator *self); } TnyIteratorIface;
void tny_iterator_next (TnyIterator *self);
Moves the iterator to the next node
self : |
A TnyIterator instance |
void tny_iterator_prev (TnyIterator *self);
Moves the iterator to the previous node
self : |
A TnyIterator instance |
void tny_iterator_first (TnyIterator *self);
Moves the iterator to the first node
self : |
A TnyIterator instance |
void tny_iterator_nth (TnyIterator *self, guint nth);
Moves the iterator to the nth node
self : |
A TnyIterator instance |
nth : |
The nth position |
GObject* tny_iterator_get_current (TnyIterator *self);
Does not move the iterator. Returns the object at the current position. If there's no current position, this method returns NULL. If not NULL, the returned value must be unreferenced after use.
self : |
A TnyIterator instance |
Returns : | the currect object or NULL |
gboolean tny_iterator_is_done (TnyIterator *self);
Does the iterator point to some valid list item? You can use this property to make loops like:
Example:
TnyList *list = tny_simple_list_new (); TnyIterator *iter = tny_list_create_iterator (list); while (!tny_iterator_is_done (iter)) { GObject *cur = tny_iterator_get_current (iter); ... g_object_unref (cur); tny_iterator_next (iter); } g_object_unref (G_OBJECT (iter)); g_object_unref (G_OBJECT (list));
self : |
A TnyIterator instance |
Returns : | TRUE if it points to a valid list item, FALSE otherwise |
TnyList* tny_iterator_get_list (TnyIterator *self);
Does not move the iterator. Returns the list of which this iterator is an iterator. The returned list object should be unreferenced after use. Remember when using this property that lists shouldn't change while iterating them.
self : |
A TnyIterator instance |
Returns : | The TnyList instance being iterated |