2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
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
28 #ifndef FIRM_ADT_ITERATOR_H
29 #define FIRM_ADT_ITERATOR_H
34 * The iterator magic word.
36 #define ITERATOR_MAGIC FOURCC('I', 'T', 'E', 'R')
39 * Check, if some memory object appears to be an iterator.
40 * @param ptr Some memory.
41 * @return 1, if that memory area appears to be an iterator, 0 if not.
43 #define is_iterator(ptr) (((const iterator_t *) (ptr))->magic == ITERATOR_MAGIC)
45 typedef struct _iterator_t {
47 void *(*start)(void *collection);
48 void *(*next)(void *collection, void *curr);
49 void (*finish)(void *collection, void *curr);
53 * An iterator implementation for linked lists.
55 extern const iterator_t *list_iterator;
58 * An iterator implementation for psets.
60 extern const iterator_t *pset_iterator;