FTS iterator
[FTS Utilitiy Data Structures]


Detailed Description

FTS iterator.

An FTS iterator is used to enumerate all the elements of a container. It is a generic interface that can be used with hashtables, lists....

Example of code using an iterator to enumerate the elements of a hashtable:

fts_hashtable_t h;
fts_iterator_t i;

fts_hashtable_get_keys( &h, &i);

while ( fts_iterator_has_more( &i) )
{
  fts_atom_t a;
  
  fts_iterator_next( &i, &a);
  fts_post( "%d\n", fts_get_int( a));
}

To enumerate the elements of an atomlist, the only line that will change in previous code is

 for ( fts_atomlist_get_atoms( &h, &i); fts_iterator_has_more( &i); )


Typedefs

typedef struct fts_iterator fts_iterator_t
 FTS iterator structure.

Functions

int fts_iterator_has_more (fts_iterator_t *iter)
 Check whether iterator contains more elements.
void fts_iterator_next (fts_iterator_t *iter, fts_atom_t *a)
 Store value and advance to next element in iteration.


Function Documentation

int fts_iterator_has_more ( fts_iterator_t iter  ) 

Check whether iterator contains more elements.

NOTE: once the iterator contains no more elements, its value is undefined. To reuse the same iterator, you must reinitialize if before calling any of its functions.

Parameters:
iter the iterator
Returns:
1 if iterator has more elements, 0 otherwise

void fts_iterator_next ( fts_iterator_t iter,
fts_atom_t *  a 
)

Store value and advance to next element in iteration.

Parameters:
iter the iterator
a the atom


Generated on Wed Aug 24 18:28:43 2011 for FTM API by  doxygen 1.5.6