1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/graph/iteration_macros.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,129 @@
1.4 +//=======================================================================
1.5 +// Copyright 2001 Indiana University
1.6 +// Author: Jeremy G. Siek
1.7 +//
1.8 +// Distributed under the Boost Software License, Version 1.0. (See
1.9 +// accompanying file LICENSE_1_0.txt or copy at
1.10 +// http://www.boost.org/LICENSE_1_0.txt)
1.11 +//=======================================================================
1.12 +
1.13 +#ifndef BOOST_GRAPH_ITERATION_MACROS_HPP
1.14 +#define BOOST_GRAPH_ITERATION_MACROS_HPP
1.15 +
1.16 +#define BGL_CAT(x,y) x ## y
1.17 +#define BGL_FIRST(linenum) BGL_CAT(bgl_first_,linenum)
1.18 +#define BGL_LAST(linenum) BGL_CAT(bgl_last_,linenum)
1.19 +
1.20 +/*
1.21 + BGL_FORALL_VERTICES_T(v, g, graph_t) // This is on line 9
1.22 + expands to the following, but all on the same line
1.23 +
1.24 + for (typename boost::graph_traits<graph_t>::vertex_iterator
1.25 + bgl_first_9 = vertices(g).first, bgl_last_9 = vertices(g).second;
1.26 + bgl_first_9 != bgl_last_9; bgl_first_9 = bgl_last_9)
1.27 + for (typename boost::graph_traits<graph_t>::vertex_descriptor v;
1.28 + bgl_first_9 != bgl_last ? (v = *bgl_first_9, true) : false;
1.29 + ++bgl_first_9)
1.30 +
1.31 + The purpose of having two for-loops is just to provide a place to
1.32 + declare both the iterator and value variables. There is really only
1.33 + one loop. The stopping condition gets executed two more times than it
1.34 + usually would be, oh well. The reason for the bgl_first_9 = bgl_last_9
1.35 + in the outer for-loop is in case the user puts a break statement
1.36 + in the inner for-loop.
1.37 +
1.38 + The other macros work in a similar fashion.
1.39 +
1.40 + Use the _T versions when the graph type is a template parameter or
1.41 + dependent on a template parameter. Otherwise use the non _T versions.
1.42 +
1.43 + */
1.44 +
1.45 +
1.46 +#define BGL_FORALL_VERTICES_T(VNAME, GNAME, GraphType) \
1.47 +for (typename boost::graph_traits<GraphType>::vertex_iterator \
1.48 + BGL_FIRST(__LINE__) = vertices(GNAME).first, BGL_LAST(__LINE__) = vertices(GNAME).second; \
1.49 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
1.50 + for (typename boost::graph_traits<GraphType>::vertex_descriptor VNAME; \
1.51 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (VNAME = *BGL_FIRST(__LINE__), true):false; \
1.52 + ++BGL_FIRST(__LINE__))
1.53 +
1.54 +#define BGL_FORALL_VERTICES(VNAME, GNAME, GraphType) \
1.55 +for (boost::graph_traits<GraphType>::vertex_iterator \
1.56 + BGL_FIRST(__LINE__) = vertices(GNAME).first, BGL_LAST(__LINE__) = vertices(GNAME).second; \
1.57 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
1.58 + for (boost::graph_traits<GraphType>::vertex_descriptor VNAME; \
1.59 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (VNAME = *BGL_FIRST(__LINE__), true):false; \
1.60 + ++BGL_FIRST(__LINE__))
1.61 +
1.62 +#define BGL_FORALL_EDGES_T(ENAME, GNAME, GraphType) \
1.63 +for (typename boost::graph_traits<GraphType>::edge_iterator \
1.64 + BGL_FIRST(__LINE__) = edges(GNAME).first, BGL_LAST(__LINE__) = edges(GNAME).second; \
1.65 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
1.66 + for (typename boost::graph_traits<GraphType>::edge_descriptor ENAME; \
1.67 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (ENAME = *BGL_FIRST(__LINE__), true):false; \
1.68 + ++BGL_FIRST(__LINE__))
1.69 +
1.70 +#define BGL_FORALL_EDGES(ENAME, GNAME, GraphType) \
1.71 +for (boost::graph_traits<GraphType>::edge_iterator \
1.72 + BGL_FIRST(__LINE__) = edges(GNAME).first, BGL_LAST(__LINE__) = edges(GNAME).second; \
1.73 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
1.74 + for (boost::graph_traits<GraphType>::edge_descriptor ENAME; \
1.75 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (ENAME = *BGL_FIRST(__LINE__), true):false; \
1.76 + ++BGL_FIRST(__LINE__))
1.77 +
1.78 +#define BGL_FORALL_ADJ_T(UNAME, VNAME, GNAME, GraphType) \
1.79 +for (typename boost::graph_traits<GraphType>::adjacency_iterator \
1.80 + BGL_FIRST(__LINE__) = adjacent_vertices(UNAME, GNAME).first,\
1.81 + BGL_LAST(__LINE__) = adjacent_vertices(UNAME, GNAME).second; \
1.82 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
1.83 +for (typename boost::graph_traits<GraphType>::vertex_descriptor VNAME; \
1.84 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (VNAME = *BGL_FIRST(__LINE__), true) : false; \
1.85 + ++BGL_FIRST(__LINE__))
1.86 +
1.87 +#define BGL_FORALL_ADJ(UNAME, VNAME, GNAME, GraphType) \
1.88 +for (boost::graph_traits<GraphType>::adjacency_iterator \
1.89 + BGL_FIRST(__LINE__) = adjacent_vertices(UNAME, GNAME).first,\
1.90 + BGL_LAST(__LINE__) = adjacent_vertices(UNAME, GNAME).second; \
1.91 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
1.92 +for (boost::graph_traits<GraphType>::vertex_descriptor VNAME; \
1.93 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (VNAME = *BGL_FIRST(__LINE__), true) : false; \
1.94 + ++BGL_FIRST(__LINE__))
1.95 +
1.96 +#define BGL_FORALL_OUTEDGES_T(UNAME, ENAME, GNAME, GraphType) \
1.97 +for (typename boost::graph_traits<GraphType>::out_edge_iterator \
1.98 + BGL_FIRST(__LINE__) = out_edges(UNAME, GNAME).first,\
1.99 + BGL_LAST(__LINE__) = out_edges(UNAME, GNAME).second; \
1.100 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
1.101 +for (typename boost::graph_traits<GraphType>::edge_descriptor ENAME; \
1.102 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (ENAME = *BGL_FIRST(__LINE__), true) : false; \
1.103 + ++BGL_FIRST(__LINE__))
1.104 +
1.105 +#define BGL_FORALL_OUTEDGES(UNAME, ENAME, GNAME, GraphType) \
1.106 +for (boost::graph_traits<GraphType>::out_edge_iterator \
1.107 + BGL_FIRST(__LINE__) = out_edges(UNAME, GNAME).first,\
1.108 + BGL_LAST(__LINE__) = out_edges(UNAME, GNAME).second; \
1.109 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
1.110 +for (boost::graph_traits<GraphType>::edge_descriptor ENAME; \
1.111 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (ENAME = *BGL_FIRST(__LINE__), true) : false; \
1.112 + ++BGL_FIRST(__LINE__))
1.113 +
1.114 +#define BGL_FORALL_INEDGES_T(UNAME, ENAME, GNAME, GraphType) \
1.115 +for (typename boost::graph_traits<GraphType>::in_edge_iterator \
1.116 + BGL_FIRST(__LINE__) = in_edges(UNAME, GNAME).first,\
1.117 + BGL_LAST(__LINE__) = in_edges(UNAME, GNAME).second; \
1.118 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
1.119 +for (typename boost::graph_traits<GraphType>::edge_descriptor ENAME; \
1.120 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (ENAME = *BGL_FIRST(__LINE__), true) : false; \
1.121 + ++BGL_FIRST(__LINE__))
1.122 +
1.123 +#define BGL_FORALL_INEDGES(UNAME, ENAME, GNAME, GraphType) \
1.124 +for (boost::graph_traits<GraphType>::in_edge_iterator \
1.125 + BGL_FIRST(__LINE__) = in_edges(UNAME, GNAME).first,\
1.126 + BGL_LAST(__LINE__) = in_edges(UNAME, GNAME).second; \
1.127 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__); BGL_FIRST(__LINE__) = BGL_LAST(__LINE__)) \
1.128 +for (boost::graph_traits<GraphType>::edge_descriptor ENAME; \
1.129 + BGL_FIRST(__LINE__) != BGL_LAST(__LINE__) ? (ENAME = *BGL_FIRST(__LINE__), true) : false; \
1.130 + ++BGL_FIRST(__LINE__))
1.131 +
1.132 +#endif // BOOST_GRAPH_ITERATION_MACROS_HPP