]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/include/boost/graph/adjacency_iterator.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / graph / include / boost / graph / adjacency_iterator.hpp
1 //=======================================================================
2 // Copyright 2002 Indiana University.
3 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
4 //
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //=======================================================================
9
10 #ifndef BOOST_ADJACENCY_ITERATOR_HPP
11 #define BOOST_ADJACENCY_ITERATOR_HPP
12
13 #include <boost/detail/iterator.hpp>
14 #include <boost/iterator/iterator_adaptor.hpp>
15 #include <boost/graph/graph_traits.hpp>
16
17 namespace boost
18 {
19
20 template <class Graph, class Vertex, class OutEdgeIter, class Difference>
21 struct adjacency_iterator
22 : iterator_adaptor<
23 adjacency_iterator<Graph,Vertex,OutEdgeIter,Difference>
24 , OutEdgeIter
25 , Vertex
26 , use_default
27 , Vertex
28 , Difference
29 >
30 {
31 typedef iterator_adaptor<
32 adjacency_iterator<Graph,Vertex,OutEdgeIter,Difference>
33 , OutEdgeIter
34 , Vertex
35 , use_default
36 , Vertex
37 , Difference
38 > super_t;
39
40 inline adjacency_iterator() {}
41 inline adjacency_iterator(OutEdgeIter const& i, const Graph* g) : super_t(i), m_g(g) { }
42
43 inline Vertex
44 dereference() const
45 { return target(*this->base(), *m_g); }
46
47 const Graph* m_g;
48 };
49
50 template <class Graph,
51 class Vertex = typename graph_traits<Graph>::vertex_descriptor,
52 class OutEdgeIter=typename graph_traits<Graph>::out_edge_iterator>
53 class adjacency_iterator_generator
54 {
55 typedef typename boost::detail::iterator_traits<OutEdgeIter>
56 ::difference_type difference_type;
57 public:
58 typedef adjacency_iterator<Graph,Vertex,OutEdgeIter,difference_type> type;
59 };
60
61 template <class Graph, class Vertex, class InEdgeIter, class Difference>
62 struct inv_adjacency_iterator
63 : iterator_adaptor<
64 inv_adjacency_iterator<Graph,Vertex,InEdgeIter,Difference>
65 , InEdgeIter
66 , Vertex
67 , use_default
68 , Vertex
69 , Difference
70 >
71 {
72 typedef iterator_adaptor<
73 inv_adjacency_iterator<Graph,Vertex,InEdgeIter,Difference>
74 , InEdgeIter
75 , Vertex
76 , use_default
77 , Vertex
78 , Difference
79 > super_t;
80
81 inline inv_adjacency_iterator() { }
82 inline inv_adjacency_iterator(InEdgeIter const& i, const Graph* g) : super_t(i), m_g(g) { }
83
84 inline Vertex
85 dereference() const
86 { return source(*this->base(), *m_g); }
87
88 const Graph* m_g;
89 };
90
91 template <class Graph,
92 class Vertex = typename graph_traits<Graph>::vertex_descriptor,
93 class InEdgeIter = typename graph_traits<Graph>::in_edge_iterator>
94 class inv_adjacency_iterator_generator {
95 typedef typename boost::detail::iterator_traits<InEdgeIter>
96 ::difference_type difference_type;
97 public:
98 typedef inv_adjacency_iterator<Graph, Vertex, InEdgeIter, difference_type> type;
99 };
100
101 } // namespace boost
102
103 #endif // BOOST_DETAIL_ADJACENCY_ITERATOR_HPP