Iterator
WpIterator
Constructors
wp_iterator_new
WpIterator * wp_iterator_new (const WpIteratorMethods * methods, size_t user_size)
Constructs an iterator that uses the provided methods to implement its API. The WpIterator structure is internally allocated with user_size additional space at the end. A pointer to this space can be retrieved with wp_iterator_get_user_data and is available for implementation-specific storage.
Parameters:
methods
–
method implementations for the new iterator
user_size
–
size of the user_data structure to be allocated
a new custom iterator
wp_iterator_new_ptr_array
WpIterator * wp_iterator_new_ptr_array (GPtrArray* items, GType item_type)
Parameters:
items
(
[transfer: full])
–
the items to iterate over
item_type
–
the type of each item
a new iterator that iterates over items
Methods
wp_iterator_fold
gboolean wp_iterator_fold (WpIterator * self, WpIteratorFoldFunc func, GValue* ret, gpointer data)
Iterates over all items of the iterator calling a function.
Parameters:
self
–
the iterator
func
(
[scope call])
–
the fold function
ret
(
[inout])
–
the accumulator data
data
(
[closure])
–
the user data
TRUE if all the items were processed, FALSE otherwise.
wp_iterator_foreach
gboolean wp_iterator_foreach (WpIterator * self, WpIteratorForeachFunc func, gpointer data)
Fold a function over the items of the iterator.
Parameters:
self
–
the iterator
func
(
[scope call])
–
the foreach function
data
(
[closure])
–
the user data
TRUE if all the items were processed, FALSE otherwise.
wp_iterator_get_user_data
gpointer wp_iterator_get_user_data (WpIterator * self)
Note: this only for use by implementations of WpIterator
Parameters:
self
–
an iterator object
a pointer to the implementation-specific storage area
wp_iterator_next
gboolean wp_iterator_next (WpIterator * self, GValue* item)
Gets the next item of the iterator.
Parameters:
self
–
the iterator
item
(
[out])
–
the next item of the iterator
TRUE if next iterator was obtained, FALSE when the iterator has no more items to iterate through.
wp_iterator_ref
WpIterator * wp_iterator_ref (WpIterator * self)
Parameters:
self
–
an iterator object
self with an additional reference count on it
wp_iterator_reset
wp_iterator_reset (WpIterator * self)
Resets the iterator so we can iterate again from the beginning.
Parameters:
self
–
the iterator
wp_iterator_unref
wp_iterator_unref (WpIterator * self)
Decreases the reference count on self and frees it when the ref count reaches zero.
Parameters:
self
(
[transfer: full])
–
an iterator object
WpIteratorMethods
Members
version
(guint32)
–
Constants
Callbacks
WpIteratorFoldFunc
gboolean (*WpIteratorFoldFunc) (const GValue* item, GValue* ret, gpointer data)
A function to be passed to wp_iterator_fold.
Parameters:
item
–
the item to fold
ret
–
the value collecting the result
data
–
data passed to wp_iterator_fold
TRUE if the fold should continue, FALSE if it should stop.
WpIteratorForeachFunc
(*WpIteratorForeachFunc) (const GValue* item, gpointer data)
A function that is called by wp_iterator_foreach for every element.
The results of the search are