valueset: Remove the unused link field.
[libfirm] / ir / ir / iredgeset.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  * @author    Matthias Braun
23  * @date      12.01.2008
24  * @brief     An edgeset.
25  */
26 #ifndef _FIRM_IREDGESET_H_
27 #define _FIRM_IREDGESET_H_
28
29 #include "firm_types.h"
30
31 #define HashSet          ir_edgeset_t
32 #define HashSetIterator  ir_edgeset_iterator_t
33 #define ValueType        ir_edge_t*
34 #define DO_REHASH
35
36 #include "hashset.h"
37
38 #undef DO_REHASH
39 #undef ValueType
40 #undef HashSetIterator
41 #undef HashSet
42
43 typedef struct ir_edgeset_t          ir_edgeset_t;
44 typedef struct ir_edgeset_iterator_t ir_edgeset_iterator_t;
45
46 /**
47  * Initializes a edgeset with default size.
48  *
49  * @param edgeset      Pointer to allocated space for the edgeset
50  */
51 void ir_edgeset_init(ir_edgeset_t *edgeset);
52
53 /**
54  * Destroys a edgeset and frees the memory allocated for hashtable. The memory of
55  * the edgeset itself is not freed.
56  *
57  * @param edgeset   Pointer to the edgeset
58  */
59 void ir_edgeset_destroy(ir_edgeset_t *edgeset);
60
61 /**
62  * Inserts a edge into a edgeset.
63  *
64  * @param edgeset   Pointer to the edgeset
65  * @param edge      edge to insert into the edgeset
66  */
67 ir_edge_t *ir_edgeset_insert(ir_edgeset_t *edgeset, ir_edge_t *edge);
68
69
70 /**
71  * Removes a edge from a edgeset. Does nothing if the edgeset doesn't contain
72  * the edge.
73  *
74  * @param edgeset  Pointer to the edgeset
75  * @param edge     Node to remove from the edgeset
76  */
77 void ir_edgeset_remove(ir_edgeset_t *edgeset, const ir_edge_t *edge);
78
79 /**
80  * Tests whether a edgeset contains a specific edge
81  *
82  * @param edgeset   Pointer to the edgeset
83  * @param edge      The pointer to find
84  * @returns         1 if edgeset contains the edge, 0 else
85  */
86 int ir_edgeset_contains(const ir_edgeset_t *edgeset, const ir_edge_t *edge);
87
88 /**
89  * Initializes a edgeset iterator. Sets the iterator before the first element in
90  * the edgeset.
91  *
92  * @param iterator   Pointer to already allocated iterator memory
93  * @param edgeset       Pointer to the edgeset
94  */
95 void ir_edgeset_iterator_init(ir_edgeset_iterator_t *iterator,
96                               const ir_edgeset_t *edgeset);
97
98 /**
99  * Advances the iterator and returns the current element or NULL if all elements
100  * in the edgeset have been processed.
101  * @attention It is not allowed to use edgeset_insert or edgeset_remove while
102  *            iterating over a edgeset.
103  *
104  * @param iterator  Pointer to the edgeset iterator.
105  * @returns         Next element in the edgeset or NULL
106  */
107 ir_edge_t *ir_edgeset_iterator_next(ir_edgeset_iterator_t *iterator);
108
109 /**
110  * Removes the element the iterator currently points to
111  *
112  * @param edgeset   Pointer to the edgeset
113  * @param iterator  Pointer to the edgeset iterator.
114  */
115 void ir_edgeset_remove_iterator(ir_edgeset_t *edgeset,
116                                 const ir_edgeset_iterator_t *iterator);
117
118 #define foreach_ir_edgeset(edgeset, edge, iter) \
119         for(ir_edgeset_iterator_init(&iter, edgeset), \
120         edge = ir_edgeset_iterator_next(&iter);    \
121                 edge != NULL; edge = ir_edgeset_iterator_next(&iter))
122
123 #endif