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

Returns ( [transfer: full])

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

Returns ( [transfer: full])

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

Returns

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

Returns

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

Returns

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

Returns

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

Returns ( [transfer: full])

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) –
No description available

Constants

WP_TYPE_ITERATOR

#define WP_TYPE_ITERATOR (wp_iterator_get_type ())

The WpIterator GType


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

Returns

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.

Parameters:

item

the item

data

the data passed to wp_iterator_foreach


The results of the search are