epoc32/include/stdapis/boost/graph/property_iter_range.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/graph/property_iter_range.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,118 @@
     1.4 +
     1.5 +// (C) Copyright François Faure, iMAGIS-GRAVIR / UJF, 2001.
     1.6 +//
     1.7 +// Distributed under the Boost Software License, Version 1.0. (See
     1.8 +// accompanying file LICENSE_1_0.txt or copy at
     1.9 +// http://www.boost.org/LICENSE_1_0.txt)
    1.10 +//
    1.11 +// Revision History:
    1.12 +// 03 May 2001   Jeremy Siek
    1.13 +//      Generalized the property map iterator and moved that
    1.14 +//      part to boost/property_map.hpp. Also modified to
    1.15 +//      differentiate between const/mutable graphs and
    1.16 +//      added a workaround to avoid partial specialization.
    1.17 +
    1.18 +// 02 May 2001   François Faure
    1.19 +//     Initial version.
    1.20 +
    1.21 +#ifndef BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
    1.22 +#define BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP
    1.23 +
    1.24 +#include <boost/property_map_iterator.hpp>
    1.25 +#include <boost/graph/properties.hpp>
    1.26 +#include <boost/pending/ct_if.hpp>
    1.27 +#include <boost/type_traits/same_traits.hpp>
    1.28 +
    1.29 +namespace boost {
    1.30 +
    1.31 +//======================================================================
    1.32 +// graph property iterator range
    1.33 +
    1.34 +  template <class Graph, class PropertyTag>
    1.35 +  class graph_property_iter_range {
    1.36 +    typedef typename property_map<Graph, PropertyTag>::type map_type;
    1.37 +    typedef typename property_map<Graph, PropertyTag>::const_type 
    1.38 +      const_map_type;
    1.39 +    typedef typename property_kind<PropertyTag>::type Kind;
    1.40 +    typedef typename ct_if<is_same<Kind, vertex_property_tag>::value,
    1.41 +       typename graph_traits<Graph>::vertex_iterator,
    1.42 +       typename graph_traits<Graph>::edge_iterator>::type iter;
    1.43 +  public:
    1.44 +    typedef typename property_map_iterator_generator<map_type, iter>::type 
    1.45 +      iterator;
    1.46 +    typedef typename property_map_iterator_generator<const_map_type, iter>
    1.47 +      ::type const_iterator;
    1.48 +    typedef std::pair<iterator, iterator> type;
    1.49 +    typedef std::pair<const_iterator, const_iterator> const_type;
    1.50 +  };
    1.51 +
    1.52 +  namespace detail {
    1.53 +
    1.54 +    template<class Graph,class Tag>
    1.55 +    typename graph_property_iter_range<Graph,Tag>::type
    1.56 +    get_property_iter_range_kind(Graph& graph, const Tag& tag, 
    1.57 +                                 const vertex_property_tag& )
    1.58 +    {
    1.59 +      typedef typename graph_property_iter_range<Graph,Tag>::iterator iter;
    1.60 +      return std::make_pair(iter(vertices(graph).first, get(tag, graph)),
    1.61 +                            iter(vertices(graph).second, get(tag, graph)));
    1.62 +    }
    1.63 +
    1.64 +    template<class Graph,class Tag>
    1.65 +    typename graph_property_iter_range<Graph,Tag>::const_type
    1.66 +    get_property_iter_range_kind(const Graph& graph, const Tag& tag, 
    1.67 +                                 const vertex_property_tag& )
    1.68 +    {
    1.69 +      typedef typename graph_property_iter_range<Graph,Tag>
    1.70 +        ::const_iterator iter;
    1.71 +      return std::make_pair(iter(vertices(graph).first, get(tag, graph)),
    1.72 +                            iter(vertices(graph).second, get(tag, graph)));
    1.73 +    }
    1.74 +
    1.75 +
    1.76 +    template<class Graph,class Tag>
    1.77 +    typename graph_property_iter_range<Graph,Tag>::type
    1.78 +    get_property_iter_range_kind(Graph& graph, const Tag& tag, 
    1.79 +                                 const edge_property_tag& )
    1.80 +    {
    1.81 +      typedef typename graph_property_iter_range<Graph,Tag>::iterator iter;
    1.82 +      return std::make_pair(iter(edges(graph).first, get(tag, graph)),
    1.83 +                            iter(edges(graph).second, get(tag, graph)));
    1.84 +    }
    1.85 +
    1.86 +    template<class Graph,class Tag>
    1.87 +    typename graph_property_iter_range<Graph,Tag>::const_type
    1.88 +    get_property_iter_range_kind(const Graph& graph, const Tag& tag, 
    1.89 +                                 const edge_property_tag& )
    1.90 +    {
    1.91 +      typedef typename graph_property_iter_range<Graph,Tag>
    1.92 +        ::const_iterator iter;
    1.93 +      return std::make_pair(iter(edges(graph).first, get(tag, graph)),
    1.94 +                            iter(edges(graph).second, get(tag, graph)));
    1.95 +    }
    1.96 +
    1.97 +  } // namespace detail
    1.98 +
    1.99 +  //======================================================================
   1.100 +  // get an iterator range of properties
   1.101 +
   1.102 +  template<class Graph, class Tag>
   1.103 +  typename graph_property_iter_range<Graph, Tag>::type
   1.104 +  get_property_iter_range(Graph& graph, const Tag& tag)
   1.105 +  {
   1.106 +    typedef typename property_kind<Tag>::type Kind;
   1.107 +    return detail::get_property_iter_range_kind(graph, tag, Kind());
   1.108 +  }
   1.109 +
   1.110 +  template<class Graph, class Tag>
   1.111 +  typename graph_property_iter_range<Graph, Tag>::const_type
   1.112 +  get_property_iter_range(const Graph& graph, const Tag& tag)
   1.113 +  {
   1.114 +    typedef typename property_kind<Tag>::type Kind;
   1.115 +    return detail::get_property_iter_range_kind(graph, tag, Kind());
   1.116 +  }
   1.117 +
   1.118 +} // namespace boost
   1.119 +
   1.120 +
   1.121 +#endif // BOOST_GRAPH_PROPERTY_ITER_RANGE_HPP