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
27 #ifndef FIRM_ADT_ITERATOR_H
28 #define FIRM_ADT_ITERATOR_H
35 * The iterator magic word.
37 #define ITERATOR_MAGIC FOURCC('I', 'T', 'E', 'R')
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.
44 #define is_iterator(ptr) (((const iterator_t *) (ptr))->magic == ITERATOR_MAGIC)
46 typedef struct iterator_t {
48 void *(*start)(void *collection);
49 void *(*next)(void *collection, void *curr);
50 void (*finish)(void *collection, void *curr);
54 * An iterator implementation for linked lists.
56 extern const iterator_t *list_iterator;
59 * An iterator implementation for psets.
61 extern const iterator_t *pset_iterator;