Chris@16
|
1
|
Chris@16
|
2 // (C) Copyright Francois Faure, iMAGIS-GRAVIR / UJF, 2001.
|
Chris@16
|
3 //
|
Chris@16
|
4 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
5 // accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 //
|
Chris@16
|
8 // Revision History:
|
Chris@16
|
9 // 03 May 2001 Jeremy Siek
|
Chris@16
|
10 // Generalized the property map iterator and moved that
|
Chris@16
|
11 // part to boost/property_map.hpp. Also modified to
|
Chris@16
|
12 // differentiate between const/mutable graphs and
|
Chris@16
|
13 // added a workaround to avoid partial specialization.
|
Chris@16
|
14
|
Chris@16
|
15 // 02 May 2001 Francois Faure
|
Chris@16
|
16 // Initial version.
|
Chris@16
|
17
|
Chris@16
|
18 #ifndef BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
|
Chris@16
|
19 #define BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
|
Chris@16
|
20
|
Chris@16
|
21 #include <boost/property_map/property_map_iterator.hpp>
|
Chris@16
|
22 #include <boost/graph/properties.hpp>
|
Chris@16
|
23 #include <boost/mpl/if.hpp>
|
Chris@16
|
24 #include <boost/type_traits/same_traits.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 namespace boost {
|
Chris@16
|
27
|
Chris@16
|
28 //======================================================================
|
Chris@16
|
29 // graph property iterator range
|
Chris@16
|
30
|
Chris@16
|
31 template <class Graph, class PropertyTag>
|
Chris@16
|
32 class graph_property_iter_range {
|
Chris@16
|
33 typedef typename property_map<Graph, PropertyTag>::type map_type;
|
Chris@16
|
34 typedef typename property_map<Graph, PropertyTag>::const_type
|
Chris@16
|
35 const_map_type;
|
Chris@16
|
36 typedef typename property_kind<PropertyTag>::type Kind;
|
Chris@16
|
37 typedef typename mpl::if_c<is_same<Kind, vertex_property_tag>::value,
|
Chris@16
|
38 typename graph_traits<Graph>::vertex_iterator,
|
Chris@16
|
39 typename graph_traits<Graph>::edge_iterator>::type iter;
|
Chris@16
|
40 public:
|
Chris@16
|
41 typedef typename property_map_iterator_generator<map_type, iter>::type
|
Chris@16
|
42 iterator;
|
Chris@16
|
43 typedef typename property_map_iterator_generator<const_map_type, iter>
|
Chris@16
|
44 ::type const_iterator;
|
Chris@16
|
45 typedef std::pair<iterator, iterator> type;
|
Chris@16
|
46 typedef std::pair<const_iterator, const_iterator> const_type;
|
Chris@16
|
47 };
|
Chris@16
|
48
|
Chris@16
|
49 namespace detail {
|
Chris@16
|
50
|
Chris@16
|
51 template<class Graph,class Tag>
|
Chris@16
|
52 typename graph_property_iter_range<Graph,Tag>::type
|
Chris@16
|
53 get_property_iter_range_kind(Graph& graph, const Tag& tag,
|
Chris@16
|
54 const vertex_property_tag& )
|
Chris@16
|
55 {
|
Chris@16
|
56 typedef typename graph_property_iter_range<Graph,Tag>::iterator iter;
|
Chris@16
|
57 return std::make_pair(iter(vertices(graph).first, get(tag, graph)),
|
Chris@16
|
58 iter(vertices(graph).second, get(tag, graph)));
|
Chris@16
|
59 }
|
Chris@16
|
60
|
Chris@16
|
61 template<class Graph,class Tag>
|
Chris@16
|
62 typename graph_property_iter_range<Graph,Tag>::const_type
|
Chris@16
|
63 get_property_iter_range_kind(const Graph& graph, const Tag& tag,
|
Chris@16
|
64 const vertex_property_tag& )
|
Chris@16
|
65 {
|
Chris@16
|
66 typedef typename graph_property_iter_range<Graph,Tag>
|
Chris@16
|
67 ::const_iterator iter;
|
Chris@16
|
68 return std::make_pair(iter(vertices(graph).first, get(tag, graph)),
|
Chris@16
|
69 iter(vertices(graph).second, get(tag, graph)));
|
Chris@16
|
70 }
|
Chris@16
|
71
|
Chris@16
|
72
|
Chris@16
|
73 template<class Graph,class Tag>
|
Chris@16
|
74 typename graph_property_iter_range<Graph,Tag>::type
|
Chris@16
|
75 get_property_iter_range_kind(Graph& graph, const Tag& tag,
|
Chris@16
|
76 const edge_property_tag& )
|
Chris@16
|
77 {
|
Chris@16
|
78 typedef typename graph_property_iter_range<Graph,Tag>::iterator iter;
|
Chris@16
|
79 return std::make_pair(iter(edges(graph).first, get(tag, graph)),
|
Chris@16
|
80 iter(edges(graph).second, get(tag, graph)));
|
Chris@16
|
81 }
|
Chris@16
|
82
|
Chris@16
|
83 template<class Graph,class Tag>
|
Chris@16
|
84 typename graph_property_iter_range<Graph,Tag>::const_type
|
Chris@16
|
85 get_property_iter_range_kind(const Graph& graph, const Tag& tag,
|
Chris@16
|
86 const edge_property_tag& )
|
Chris@16
|
87 {
|
Chris@16
|
88 typedef typename graph_property_iter_range<Graph,Tag>
|
Chris@16
|
89 ::const_iterator iter;
|
Chris@16
|
90 return std::make_pair(iter(edges(graph).first, get(tag, graph)),
|
Chris@16
|
91 iter(edges(graph).second, get(tag, graph)));
|
Chris@16
|
92 }
|
Chris@16
|
93
|
Chris@16
|
94 } // namespace detail
|
Chris@16
|
95
|
Chris@16
|
96 //======================================================================
|
Chris@16
|
97 // get an iterator range of properties
|
Chris@16
|
98
|
Chris@16
|
99 template<class Graph, class Tag>
|
Chris@16
|
100 typename graph_property_iter_range<Graph, Tag>::type
|
Chris@16
|
101 get_property_iter_range(Graph& graph, const Tag& tag)
|
Chris@16
|
102 {
|
Chris@16
|
103 typedef typename property_kind<Tag>::type Kind;
|
Chris@16
|
104 return detail::get_property_iter_range_kind(graph, tag, Kind());
|
Chris@16
|
105 }
|
Chris@16
|
106
|
Chris@16
|
107 template<class Graph, class Tag>
|
Chris@16
|
108 typename graph_property_iter_range<Graph, Tag>::const_type
|
Chris@16
|
109 get_property_iter_range(const Graph& graph, const Tag& tag)
|
Chris@16
|
110 {
|
Chris@16
|
111 typedef typename property_kind<Tag>::type Kind;
|
Chris@16
|
112 return detail::get_property_iter_range_kind(graph, tag, Kind());
|
Chris@16
|
113 }
|
Chris@16
|
114
|
Chris@16
|
115 } // namespace boost
|
Chris@16
|
116
|
Chris@16
|
117
|
Chris@16
|
118 #endif // BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
|