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. |
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.
iter | the iterator |
void fts_iterator_next | ( | fts_iterator_t * | iter, | |
fts_atom_t * | a | |||
) |
Store value and advance to next element in iteration.
iter | the iterator | |
a | the atom |