IpatchIter

IpatchIter — Item iterator.

Synopsis




                    IpatchIter;
                    IpatchIterMethods;
#define             IPATCH_TYPE_ITER
GType               ipatch_iter_get_type                (void);
IpatchIter*         ipatch_iter_alloc                   (void);
void                ipatch_iter_free                    (IpatchIter *iter);
IpatchIter*         ipatch_iter_duplicate               (IpatchIter *iter);
#define             ipatch_iter_get                     (iter)
#define             ipatch_iter_next                    (iter)
#define             ipatch_iter_first                   (iter)
#define             ipatch_iter_last                    (iter)
#define             ipatch_iter_index                   (iter, pos)
#define             ipatch_iter_insert                  (iter, item)
#define             ipatch_iter_remove                  (iter)
#define             ipatch_iter_count                   (iter)
void                ipatch_iter_GSList_init             (IpatchIter *iter,
                                                         GSList **list);
gpointer            ipatch_iter_GSList_get              (IpatchIter *iter);
gpointer            ipatch_iter_GSList_next             (IpatchIter *iter);
gpointer            ipatch_iter_GSList_first            (IpatchIter *iter);
gpointer            ipatch_iter_GSList_last             (IpatchIter *iter);
gpointer            ipatch_iter_GSList_index            (IpatchIter *iter,
                                                         int index);
void                ipatch_iter_GSList_insert           (IpatchIter *iter,
                                                         gpointer item);
void                ipatch_iter_GSList_remove           (IpatchIter *iter);
int                 ipatch_iter_GSList_count            (IpatchIter *iter);
void                ipatch_iter_GList_init              (IpatchIter *iter,
                                                         GList **list);
gpointer            ipatch_iter_GList_get               (IpatchIter *iter);
gpointer            ipatch_iter_GList_next              (IpatchIter *iter);
gpointer            ipatch_iter_GList_first             (IpatchIter *iter);
gpointer            ipatch_iter_GList_last              (IpatchIter *iter);
gpointer            ipatch_iter_GList_index             (IpatchIter *iter,
                                                         int index);
void                ipatch_iter_GList_insert            (IpatchIter *iter,
                                                         gpointer item);
void                ipatch_iter_GList_remove            (IpatchIter *iter);
int                 ipatch_iter_GList_count             (IpatchIter *iter);

Description

Iterators provide a common high performance low level interface to lists of data of possibly differing underlying structure. This allows for future backwards compatible changes to the underlying structure, as long as this interface is used. If high performance is not of concern then the IpatchList object is probably a better option (which itself can use the IpatchIter interface). Certain IpatchIter lists require locking during usage, including most IpatchContainer child lists.

Examples of lists covered by this interface include: IpatchContainer child lists, IpatchList objects, and IpatchSF2Zone generator arrays.

Details

IpatchIter

typedef struct {
} IpatchIter;

Object iterator structure. All fields are public and can be freely manipulated as long as any objects added to the list are ref'd and any objects removed are unref'd. Also, the pos field should be set to NULL if it points to a list node that gets removed.


IpatchIterMethods

typedef struct {
  gpointer (*get)(IpatchIter *iter); /* get item method */
  gpointer (*next)(IpatchIter *iter); /* next item method */
  gpointer (*first)(IpatchIter *iter);	/* first item method */
  gpointer (*last)(IpatchIter *iter); /* last item method */
  gpointer (*index)(IpatchIter *iter, int index); /* index item method */
  void (*insert)(IpatchIter *iter, gpointer item); /* insert item method */
  void (*remove)(IpatchIter *iter); /* remove current item method */
  int (*count)(IpatchIter *iter); /* count items method */
} IpatchIterMethods;


IPATCH_TYPE_ITER

#define IPATCH_TYPE_ITER   (ipatch_iter_get_type ())

Gets the GType of patch iterators (GBoxed type).


ipatch_iter_get_type ()

GType               ipatch_iter_get_type                (void);

Gets the GBoxed derived type for IpatchIter structures.

Returns : GType of IpatchIter structures.

ipatch_iter_alloc ()

IpatchIter*         ipatch_iter_alloc                   (void);

Allocates an item iterator. This function is seldom used since IpatchIter structures are usually allocated on the stack.

Returns : Newly allocated item iterator. Should be freed with ipatch_iter_free() when finished with it.

ipatch_iter_free ()

void                ipatch_iter_free                    (IpatchIter *iter);

Frees an item iterator that was allocated with ipatch_iter_alloc(). Seldom used since IpatchIter structures are usually allocated on the stack.

iter : Item iterator

ipatch_iter_duplicate ()

IpatchIter*         ipatch_iter_duplicate               (IpatchIter *iter);

Duplicates a patch iterator. Seldom used since IpatchIter structures are usually allocated on the stack and can be copied directly.

iter : Patch iterator to duplicate
Returns : Newly allocated patch iter identical to iter. Free it with ipatch_iter_free() when finished.

ipatch_iter_get()

#define ipatch_iter_get(iter) (((iter)->methods->get)(iter))

iter :

ipatch_iter_next()

#define ipatch_iter_next(iter) (((iter)->methods->next)(iter))

iter :
Returns :

ipatch_iter_first()

#define ipatch_iter_first(iter) (((iter)->methods->first)(iter))

iter :
Returns :

ipatch_iter_last()

#define ipatch_iter_last(iter) (((iter)->methods->last)(iter))

iter :
Returns :

ipatch_iter_index()

#define ipatch_iter_index(iter, pos) (((iter)->methods->index)(iter, pos))

iter :
pos :

ipatch_iter_insert()

#define ipatch_iter_insert(iter, item) (((iter)->methods->insert)(iter, item))

iter :
item :

ipatch_iter_remove()

#define ipatch_iter_remove(iter) (((iter)->methods->remove)(iter))

iter :

ipatch_iter_count()

#define ipatch_iter_count(iter) (((iter)->methods->count)(iter))

iter :

ipatch_iter_GSList_init ()

void                ipatch_iter_GSList_init             (IpatchIter *iter,
                                                         GSList **list);

Initialize an iterator to iterate over a GSList.

iter : Iterator to initialize
list : Pointer to root GSList pointer to initialize iterator to

ipatch_iter_GSList_get ()

gpointer            ipatch_iter_GSList_get              (IpatchIter *iter);

GSList item iterator method to get the current item.

iter : Item iterator initialized with a GSList
Returns : Current item or NULL if no current item.

ipatch_iter_GSList_next ()

gpointer            ipatch_iter_GSList_next             (IpatchIter *iter);

GSList item iterator method to get the next item and advance the iterator's position.

iter : Item iterator initialized with a GSList
Returns : Next item or NULL if no more items.

ipatch_iter_GSList_first ()

gpointer            ipatch_iter_GSList_first            (IpatchIter *iter);

GSList item iterator method to get the first item and set the iterator's position to it.

iter : Item iterator initialized with a GSList
Returns : First item or NULL if GSList is empty.

ipatch_iter_GSList_last ()

gpointer            ipatch_iter_GSList_last             (IpatchIter *iter);

GSList item iterator method to get the last item and set the iterator's position to it.

iter : Item iterator initialized with a GSList
Returns : Last item or NULL if GSList is empty.

ipatch_iter_GSList_index ()

gpointer            ipatch_iter_GSList_index            (IpatchIter *iter,
                                                         int index);

GSList item iterator method to get an item at a given index and set the iterator's position to it.

iter : Item iterator initialized with a GSList
index : Index, from 0, of item to get
Returns : item at the index position or NULL if index is off the end of the GSList.

ipatch_iter_GSList_insert ()

void                ipatch_iter_GSList_insert           (IpatchIter *iter,
                                                         gpointer item);

GSList item iterator method to insert an item pointer.

iter : Item iterator initialized with a GSList
item : Pointer to insert

ipatch_iter_GSList_remove ()

void                ipatch_iter_GSList_remove           (IpatchIter *iter);

GSList item iterator method to remove the current item and advance the current position.

iter : Item iterator initialized with a GSList

ipatch_iter_GSList_count ()

int                 ipatch_iter_GSList_count            (IpatchIter *iter);

GSList item iterator method to get the count of items.

iter : Item iterator initialized with a GSList
Returns : Count of items in GSList iterator.

ipatch_iter_GList_init ()

void                ipatch_iter_GList_init              (IpatchIter *iter,
                                                         GList **list);

Initialize an iterator to iterate over a GList.

iter : Iterator to initialize
list : Pointer to root GList pointer to initialize iterator to

ipatch_iter_GList_get ()

gpointer            ipatch_iter_GList_get               (IpatchIter *iter);

GList item iterator method to get the current item.

iter : Item iterator initialized with a GList
Returns : Current item or NULL if no current item.

ipatch_iter_GList_next ()

gpointer            ipatch_iter_GList_next              (IpatchIter *iter);

GList item iterator method to get the next item and advance the iterator's position.

iter : Item iterator initialized with a GList
Returns : Next item or NULL if no more items.

ipatch_iter_GList_first ()

gpointer            ipatch_iter_GList_first             (IpatchIter *iter);

GList item iterator method to get the first item and set the iterator's position to it.

iter : Item iterator initialized with a GList
Returns : First item or NULL if GList is empty.

ipatch_iter_GList_last ()

gpointer            ipatch_iter_GList_last              (IpatchIter *iter);

GList item iterator method to get the last item and set the iterator's position to it.

iter : Item iterator initialized with a GList
Returns : Last item or NULL if GList is empty.

ipatch_iter_GList_index ()

gpointer            ipatch_iter_GList_index             (IpatchIter *iter,
                                                         int index);

GList item iterator method to get an item at a given index and set the iterator's position to it.

iter : Item iterator initialized with a GList
index : Index, from 0, of item to get
Returns : item at the index position or NULL if index is off the end of the GList.

ipatch_iter_GList_insert ()

void                ipatch_iter_GList_insert            (IpatchIter *iter,
                                                         gpointer item);

GList item iterator method to insert an item pointer.

iter : Item iterator initialized with a GList
item : Pointer to insert

ipatch_iter_GList_remove ()

void                ipatch_iter_GList_remove            (IpatchIter *iter);

GList item iterator method to remove the current item and advance the current position.

iter : Item iterator initialized with a GList

ipatch_iter_GList_count ()

int                 ipatch_iter_GList_count             (IpatchIter *iter);

GList item iterator method to get the count of items.

iter : Item iterator initialized with a GList
Returns : Count of items in GList iterator.

See Also

IpatchList, IpatchContainer