Wp.Iterator

Fields

None

Methods

class

new (methods, user_size)

fold (func, ret, *data)

foreach (func, *data)

get_user_data ()

next ()

ref ()

reset ()

unref ()

Details

class Wp.Iterator

A generic iterator API

classmethod new(methods, user_size)
Parameters:
  • methods (Wp.IteratorMethods) – method implementations for the new iterator

  • user_size (int) – size of the user_data structure to be allocated

Returns:

a new custom iterator

Return type:

Wp.Iterator

Constructs an iterator that uses the provided methods to implement its API.

The Wp.Iterator 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.

fold(func, ret, *data)
Parameters:
Returns:

True if all the items were processed, False otherwise.

ret:

the accumulator data

Return type:

(bool, ret: GObject.Value)

Fold a function over the items of the iterator.

foreach(func, *data)
Parameters:
Returns:

True if all the items were processed, False otherwise.

Return type:

bool

Iterates over all items of the iterator calling a function.

get_user_data()
Returns:

a pointer to the implementation-specific storage area

Return type:

object or None

Gets the implementation-specific storage of an iterator.

this only for use by implementations of Wp.Iterator

next()
Returns:

True if next iterator was obtained, False when the iterator has no more items to iterate through.

item:

the next item of the iterator

Return type:

(bool, item: GObject.Value)

Gets the next item of the iterator.

ref()
Returns:

self with an additional reference count on it

Return type:

Wp.Iterator

Increases the reference count of an iterator.

reset()

Resets the iterator so we can iterate again from the beginning.

unref()

Decreases the reference count on self and frees it when the ref count reaches zero.