remove $Id$, it doesn't work with git anyway
[libfirm] / ir / adt / iterator.c
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
23  * @author  Sebastian Hack
24  */
25 #include "config.h"
26
27 #include <string.h>
28
29 #include "pset.h"
30 #include "list.h"
31 #include "iterator.h"
32
33
34 static void *it_pset_start(void *collection)
35 {
36         return pset_first((pset*) collection);
37 }
38
39 static void *it_pset_next(void *collection, void *curr)
40 {
41         (void) curr;
42         return pset_next((pset*) collection);
43 }
44
45 static void it_pset_finish(void *collection, void *curr)
46 {
47         (void) collection;
48         (void) curr;
49 }
50
51 static const iterator_t iterator_pset = {
52         ITERATOR_MAGIC,
53         it_pset_start,
54         it_pset_next,
55         it_pset_finish
56 };
57
58 const iterator_t *pset_iterator = &iterator_pset;
59
60
61 static void *it_list_next(void *coll, void *it)
62 {
63         struct list_head *head = (list_head*) coll;
64         struct list_head *curr = (list_head*) it;
65         return curr->next != head ? curr->next : NULL;
66 }
67
68 static void *it_list_start(void *coll)
69 {
70         return it_list_next(coll, coll);
71 }
72
73 static void it_list_finish(void *coll, void *curr)
74 {
75         (void) coll;
76         (void) curr;
77 }
78
79 static const iterator_t iterator_list = {
80         ITERATOR_MAGIC,
81         it_list_start,
82         it_list_next,
83         it_list_finish
84 };
85
86 const iterator_t *list_iterator = &iterator_list;