Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:43:05

0001 
0002 // (C) Copyright Francois Faure, iMAGIS-GRAVIR / UJF, 2001.
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See
0005 // accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // Revision History:
0009 // 03 May 2001   Jeremy Siek
0010 //      Generalized the property map iterator and moved that
0011 //      part to boost/property_map.hpp. Also modified to
0012 //      differentiate between const/mutable graphs and
0013 //      added a workaround to avoid partial specialization.
0014 
0015 // 02 May 2001   Francois Faure
0016 //     Initial version.
0017 
0018 #ifndef BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
0019 #define BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
0020 
0021 #include <boost/property_map/property_map_iterator.hpp>
0022 #include <boost/graph/properties.hpp>
0023 #include <boost/mpl/if.hpp>
0024 #include <boost/type_traits/same_traits.hpp>
0025 
0026 namespace boost
0027 {
0028 
0029 //======================================================================
0030 // graph property iterator range
0031 
0032 template < class Graph, class PropertyTag > class graph_property_iter_range
0033 {
0034     typedef typename property_map< Graph, PropertyTag >::type map_type;
0035     typedef
0036         typename property_map< Graph, PropertyTag >::const_type const_map_type;
0037     typedef typename property_kind< PropertyTag >::type Kind;
0038     typedef typename mpl::if_c< is_same< Kind, vertex_property_tag >::value,
0039         typename graph_traits< Graph >::vertex_iterator,
0040         typename graph_traits< Graph >::edge_iterator >::type iter;
0041 
0042 public:
0043     typedef typename property_map_iterator_generator< map_type, iter >::type
0044         iterator;
0045     typedef
0046         typename property_map_iterator_generator< const_map_type, iter >::type
0047             const_iterator;
0048     typedef std::pair< iterator, iterator > type;
0049     typedef std::pair< const_iterator, const_iterator > const_type;
0050 };
0051 
0052 namespace detail
0053 {
0054 
0055     template < class Graph, class Tag >
0056     typename graph_property_iter_range< Graph, Tag >::type
0057     get_property_iter_range_kind(
0058         Graph& graph, const Tag& tag, const vertex_property_tag&)
0059     {
0060         typedef typename graph_property_iter_range< Graph, Tag >::iterator iter;
0061         return std::make_pair(iter(vertices(graph).first, get(tag, graph)),
0062             iter(vertices(graph).second, get(tag, graph)));
0063     }
0064 
0065     template < class Graph, class Tag >
0066     typename graph_property_iter_range< Graph, Tag >::const_type
0067     get_property_iter_range_kind(
0068         const Graph& graph, const Tag& tag, const vertex_property_tag&)
0069     {
0070         typedef typename graph_property_iter_range< Graph, Tag >::const_iterator
0071             iter;
0072         return std::make_pair(iter(vertices(graph).first, get(tag, graph)),
0073             iter(vertices(graph).second, get(tag, graph)));
0074     }
0075 
0076     template < class Graph, class Tag >
0077     typename graph_property_iter_range< Graph, Tag >::type
0078     get_property_iter_range_kind(
0079         Graph& graph, const Tag& tag, const edge_property_tag&)
0080     {
0081         typedef typename graph_property_iter_range< Graph, Tag >::iterator iter;
0082         return std::make_pair(iter(edges(graph).first, get(tag, graph)),
0083             iter(edges(graph).second, get(tag, graph)));
0084     }
0085 
0086     template < class Graph, class Tag >
0087     typename graph_property_iter_range< Graph, Tag >::const_type
0088     get_property_iter_range_kind(
0089         const Graph& graph, const Tag& tag, const edge_property_tag&)
0090     {
0091         typedef typename graph_property_iter_range< Graph, Tag >::const_iterator
0092             iter;
0093         return std::make_pair(iter(edges(graph).first, get(tag, graph)),
0094             iter(edges(graph).second, get(tag, graph)));
0095     }
0096 
0097 } // namespace detail
0098 
0099 //======================================================================
0100 // get an iterator range of properties
0101 
0102 template < class Graph, class Tag >
0103 typename graph_property_iter_range< Graph, Tag >::type get_property_iter_range(
0104     Graph& graph, const Tag& tag)
0105 {
0106     typedef typename property_kind< Tag >::type Kind;
0107     return detail::get_property_iter_range_kind(graph, tag, Kind());
0108 }
0109 
0110 template < class Graph, class Tag >
0111 typename graph_property_iter_range< Graph, Tag >::const_type
0112 get_property_iter_range(const Graph& graph, const Tag& tag)
0113 {
0114     typedef typename property_kind< Tag >::type Kind;
0115     return detail::get_property_iter_range_kind(graph, tag, Kind());
0116 }
0117 
0118 } // namespace boost
0119 
0120 #endif // BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP