Add the return type as parameter to the macros set_find() and set_insert().
[libfirm] / ir / adt / iterator.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Iterators for the several collection types used in firm.
23  *          Useful for formatted and unified dumping of collections of objects.
24  * @author  Sebastian Hack
25  * @date    29.11.2004
26  */
27 #ifndef FIRM_ADT_ITERATOR_H
28 #define FIRM_ADT_ITERATOR_H
29
30 #include "fourcc.h"
31
32 #include "../begin.h"
33
34 /**
35  * The iterator magic word.
36  */
37 #define ITERATOR_MAGIC FOURCC('I', 'T', 'E', 'R')
38
39 /**
40  * Check, if some memory object appears to be an iterator.
41  * @param ptr Some memory.
42  * @return 1, if that memory area appears to be an iterator, 0 if not.
43  */
44 #define is_iterator(ptr) (((const iterator_t *) (ptr))->magic == ITERATOR_MAGIC)
45
46 typedef struct iterator_t {
47         unsigned magic;
48         void *(*start)(void *collection);
49         void *(*next)(void *collection, void *curr);
50         void (*finish)(void *collection, void *curr);
51 } iterator_t;
52
53 /**
54  * An iterator implementation for linked lists.
55  */
56 extern const iterator_t *list_iterator;
57
58 /**
59  * An iterator implementation for psets.
60  */
61 extern const iterator_t *pset_iterator;
62
63 #include "../end.h"
64
65 #endif