2 #ifndef HUGO_FOR_EACH_MACROS_H
3 #define HUGO_FOR_EACH_MACROS_H
5 // /// \ingroup gwrappers
7 /// \brief Iteration macros.
9 /// This file contains several macros which make easier writting
10 /// for cycles in HUGO using HUGO iterators.
12 /// \author Marton Makai
16 /// This macro provides a comfortable interface for iterating with HUGO
22 /// FOR_EACH_GLOB(n, g) {
26 /// FOR_EACH_GLOB(e, g) {
30 /// Note that the iterated variables \c n and \c e are global ones.
31 #define FOR_EACH_GLOB(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
33 /// This macro provides a comfortable interface for iterating with HUGO
39 /// Graph::OutEdgeIt e;
40 /// FOR_EACH_INC_GLOB(e, g, v) {
43 /// typedef BipartiteGraph<Graph> BGraph;
46 /// BGraph::ClassNodeIt n;
47 /// FOR_EACH_INC_GLOB(BGraph::ClassNodeIt, n, h, h.S_CLASS) {
51 /// Note that iterated variables \c e and \c n are global ones.
52 #define FOR_EACH_INC_GLOB(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
55 //#define FOR_EACH_EDGE_GLOB(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
57 //#define FOR_EACH_NODE_GLOB(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
59 //#define FOR_EACH_INEDGE_GLOB(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
61 //#define FOR_EACH_OUTEDGE_GLOB(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
63 // template<typename It, typename Graph>
64 // It loopFirst(const Graph& g) const {
65 // It e; g.first(e); return e;
68 // template<typename It, typename Graph>
69 // It loopFirst(const Graph& g, const Node& v) const {
70 // It e; g.first(e, v); return e;
73 // template<typename Graph>
74 // typename Graph::NodeIt loopFirstNode(const Graph& g) const {
75 // typename Graph::NodeIt e; g.first(e); return e;
77 // template<typename Graph>
78 // typename Graph::EdgeIt loopFirstEdge(const Graph& g) const {
79 // typename Graph::EdgeIt e; g.first(e); return e;
81 // template<typename Graph>
82 // typename Graph::OutEdgeIt
83 // loopFirstOutEdge(const Graph& g, const Node& n) const {
84 // typename Graph::OutEdgeIt e; g.first(e, n); return e;
86 // template<typename Graph>
87 // typename Graph::InEdgeIt
88 // loopFirstIn Edge(const Graph& g, const Node& n) const {
89 // typename Graph::InEdgeIt e; g.first(e, n); return e;
92 //FIXME ezt hogy a gorcsbe birja levezetni. Csak ugy leveszi a const-ot??
93 template<typename It, typename Graph>
94 It loopFirst(const It&, const Graph& g) {
95 It e; g.first(e); return e;
98 template<typename It, typename Graph, typename Node>
99 It loopFirst(const It&, const Graph& g, const Node& v) {
100 It e; g.first(e, v); return e;
103 // template<typename Graph>
104 // typename Graph::NodeIt loopFirstNode(const Graph& g) const {
105 // typename Graph::NodeIt e; g.first(e); return e;
107 // template<typename Graph>
108 // typename Graph::EdgeIt loopFirstEdge(const Graph& g) const {
109 // typename Graph::EdgeIt e; g.first(e); return e;
111 // template<typename Graph>
112 // typename Graph::OutEdgeIt
113 // loopFirstOutEdge(const Graph& g, const Node& n) const {
114 // typename Graph::OutEdgeIt e; g.first(e, n); return e;
116 // template<typename Graph>
117 // typename Graph::InEdgeIt
118 // loopFirstIn Edge(const Graph& g, const Node& n) const {
119 // typename Graph::InEdgeIt e; g.first(e, n); return e;
122 /// This macro provides a comfortable interface for iterating with HUGO
127 /// FOR_EACH_LOC(Graph::NodeIt, n, g) {
130 /// FOR_EACH_LOC(Graph::EdgeIt, e, g) {
134 /// Note that the iterated variables \c n and \c e are local ones.
135 #define FOR_EACH_LOC(Ittype, e, g) for(Ittype e=loopFirst(Ittype(), (g)); (g).valid(e); (g).next(e))
137 /// This macro provides a comfortable interface for iterating with HUGO
143 /// FOR_EACH_INC_LOC(Graph::OutEdgeIt, e, g, v) {
146 /// typedef BipartiteGraph<Graph> BGraph;
149 /// FOR_EACH_INC_LOC(BGraph::ClassNodeIt, n, h, h.S_CLASS) {
153 /// Note that the iterated variables \c e and \c n are local ones.
154 #define FOR_EACH_INC_LOC(Ittype, e, g, v) for(Ittype e=loopFirst(Ittype(), (g), (v)); (g).valid(e); (g).next(e))
156 // #define FOR_EACH_EDGE_LOC(e, g) ezt nem tom hogy kell for((g).first((e)); (g).valid((e)); (g).next((e)))
157 // #define FOR_EACH_NODE_LOC(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
158 // #define FOR_EACH_INEDGE_LOC(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
159 // #define FOR_EACH_OUTEDGE_LOC(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
164 #endif //HUGO_FOR_EACH_MACROS_H