TaPAS  0.2
Macros | Functions
ccl-iterator.h File Reference

A generic iterator interface. More...

#include <ccl/ccl-common.h>
#include <ccl/ccl-protos.h>

Go to the source code of this file.

Macros

#define CCL_ITERATOR_TYPEDEF(_typename_, _eltype_)
 Macro-function used to define and declare a new iterator type. More...
 
#define ccl_iterator_has_more_elements(i)   ((i)->has_more_elements (i))
 Checks if it remains elements to visit. More...
 
#define ccl_iterator_next_element(i)   ((i)->next_element (i))
 Returns the next element. More...
 
#define ccl_iterator_delete(i)   ((i)->delete_iterator (i))
 Releases the resources allocated to i. More...
 

Functions

 CCL_ITERATOR_TYPEDEF (ccl_pointer_iterator, void *)
 The type of iterators returning a void pointer.
 
 CCL_ITERATOR_TYPEDEF (ccl_int_iterator, int)
 The type of iterators returning an integer.
 

Detailed Description

A generic iterator interface.

Definition in file ccl-iterator.h.

Macro Definition Documentation

#define ccl_iterator_delete (   i)    ((i)->delete_iterator (i))

Releases the resources allocated to i.

Parameters
ithe iterator

Definition at line 81 of file ccl-iterator.h.

#define ccl_iterator_has_more_elements (   i)    ((i)->has_more_elements (i))

Checks if it remains elements to visit.

Parameters
ithe iterator
Returns
a non-null value if the underlying container has not been completely visited by the iterator i

Definition at line 67 of file ccl-iterator.h.

#define ccl_iterator_next_element (   i)    ((i)->next_element (i))

Returns the next element.

Parameters
ithe iterator
Returns
the next element accessible by the iterator. The iterator can assume that ccl_iterator_has_more_elements(i) has returned a non null value.

Definition at line 75 of file ccl-iterator.h.

#define CCL_ITERATOR_TYPEDEF (   _typename_,
  _eltype_ 
)
Value:
typedef struct ccl_iterator_ ## _typename_ ## _st _typename_; \
struct ccl_iterator_ ## _typename_ ## _st { \
int (*has_more_elements) (const _typename_ *i); \
_eltype_ (*next_element) (_typename_ *i); \
void (*delete_iterator) (_typename_ *i); \
}

Macro-function used to define and declare a new iterator type.

An iterator is a structure containing 3 pointers of functions:

  • int (*has_more_elements) (const typename *i) that has to return a non-null value if there remains elements to visit.
  • _eltype_ (*next_element) (typename *i) that returns the next element to visite.
  • void (*delete_iterator) (typename *i) that clean-up the resources allocated to the iterator.

The three methods have to be implemented.

Parameters
<em>typename</em>the name of the new type.
<em>eltype</em>the type of object handled by the iterator.

Definition at line 43 of file ccl-iterator.h.