Removed arning
[libfirm] / ir / adt / iterator.h
1 /**
2  * Iterators for the several collection types used in firm.
3  * Useful for formatted and unified dumping of collections of objects.
4  * @author Sebastian Hack
5  * @date 29.11.2004
6  */
7 #ifndef _ITERATOR_H
8 #define _ITERATOR_H
9
10 #include "fourcc.h"
11
12 /**
13  * The iterator magic word.
14  */
15 #define ITERATOR_MAGIC FOURCC('I', 'T', 'E', 'R')
16
17 /**
18  * Check, if some memory object appears to be an iterator.
19  * @param ptr Some memory.
20  * @return 1, if that memory area appears to be an iterator, 0 if not.
21  */
22 #define is_iterator(ptr) (((const iterator_t *) (ptr))->magic == ITERATOR_MAGIC)
23
24 typedef struct _iterator_t {
25         unsigned magic;
26         void *(*start)(void *collection);
27         void *(*next)(void *collection, void *curr);
28         void (*finish)(void *collection, void *curr);
29 } iterator_t;
30
31 /**
32  * An iterator implementation for linked lists.
33  */
34 extern const iterator_t *list_iterator;
35
36 /**
37  * An iterator implementation for psets.
38  */
39 extern const iterator_t *pset_iterator;
40
41 #endif