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