Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53481 - trunk/boost/graph
From: jewillco_at_[hidden]
Date: 2009-05-31 00:20:53


Author: jewillco
Date: 2009-05-31 00:20:52 EDT (Sun, 31 May 2009)
New Revision: 53481
URL: http://svn.boost.org/trac/boost/changeset/53481

Log:
Changed new-style named parameter code for BGL to use shared_array_property_map, greatly simplifying interface
Text files modified:
   trunk/boost/graph/depth_first_search.hpp | 3 -
   trunk/boost/graph/named_function_params.hpp | 46 +++++++++++++--------------------------
   2 files changed, 17 insertions(+), 32 deletions(-)

Modified: trunk/boost/graph/depth_first_search.hpp
==============================================================================
--- trunk/boost/graph/depth_first_search.hpp (original)
+++ trunk/boost/graph/depth_first_search.hpp 2009-05-31 00:20:52 EDT (Sun, 31 May 2009)
@@ -289,11 +289,10 @@
     using namespace boost::graph::keywords;
     typedef bgl_named_params<P, T, R> params_type;
     BOOST_GRAPH_DECLARE_CONVERTED_PARAMETERS(params_type, params)
- BOOST_GRAPH_MAKE_COLOR_MAP_IF_NEEDED(VertexListGraph, arg_pack_type, g, arg_pack, color_map);
     depth_first_search
       (g,
        arg_pack[_visitor | make_dfs_visitor(null_visitor())],
- color_map,
+ boost::detail::color_map_maker<VertexListGraph, arg_pack_type>::make_map(g, arg_pack),
        arg_pack[_root_vertex | *vertices(g).first]
       );
   }

Modified: trunk/boost/graph/named_function_params.hpp
==============================================================================
--- trunk/boost/graph/named_function_params.hpp (original)
+++ trunk/boost/graph/named_function_params.hpp 2009-05-31 00:20:52 EDT (Sun, 31 May 2009)
@@ -18,6 +18,8 @@
 #include <boost/mpl/not.hpp>
 #include <boost/type_traits/add_reference.hpp>
 #include <boost/graph/named_function_params.hpp>
+#include <boost/property_map/property_map.hpp>
+#include <boost/property_map/shared_array_property_map.hpp>
 
 namespace boost {
 
@@ -436,15 +438,9 @@
 
     template <bool Exists, typename Graph, typename ArgPack, typename Value, typename PM>
     struct color_map_maker_helper {
- typedef int data_type;
       typedef PM map_type;
- typedef std::pair<data_type, map_type> pm_pair_type;
- static void make_pm_pair(const Graph&,
- Value,
- const PM& pm,
- const ArgPack&,
- pm_pair_type& result) {
- result.second = pm;
+ static PM make_map(const Graph&, Value, const PM& pm, const ArgPack&) {
+ return pm;
       }
     };
 
@@ -459,24 +455,20 @@
           boost::detail::parameter_exists<
             ArgPack, boost::graph::keywords::tag::vertex_index_map>::value
>::result_type>::type vi_map_type;
- typedef std::vector<Value> data_type;
       typedef
- boost::iterator_property_map<typename data_type::iterator, vi_map_type, Value>
+ boost::shared_array_property_map<Value, vi_map_type>
         map_type;
- typedef std::pair<data_type, map_type> pm_pair_type;
- static void make_pm_pair(const Graph& g,
+ static map_type make_map(const Graph& g,
                                Value v,
                                const PM&,
- const ArgPack& ap,
- pm_pair_type& result) {
- result.first.clear();
- result.first.resize(num_vertices(g), v);
- result.second = map_type(
- result.first.begin(),
- override_const_property(
- ap,
- boost::graph::keywords::_vertex_index_map,
- g, vertex_index));
+ const ArgPack& ap) {
+ return make_shared_array_property_map(
+ num_vertices(g),
+ v,
+ override_const_property(
+ ap,
+ boost::graph::keywords::_vertex_index_map,
+ g, vertex_index));
       }
     };
 
@@ -496,17 +488,11 @@
>::type
>::type> helper;
       typedef typename helper::map_type map_type;
- typedef typename helper::pm_pair_type pm_pair_type;
- static void make_pm_pair(const Graph& g, const ArgPack& ap, pm_pair_type& result) {
- helper::make_pm_pair(g, white_color, ap[boost::graph::keywords::_color_map | 0], ap, result);
+ static map_type make_map(const Graph& g, const ArgPack& ap) {
+ return helper::make_map(g, white_color, ap[boost::graph::keywords::_color_map | 0], ap);
       }
     };
 
-#define BOOST_GRAPH_MAKE_COLOR_MAP_IF_NEEDED(GraphT, ArgPackT, graph, arg_pack, color_map) \
- typename boost::detail::color_map_maker<GraphT, ArgPackT>::pm_pair_type BOOST_PP_CAT(cm_pair_, __LINE__); \
- boost::detail::color_map_maker<GraphT, ArgPackT>::make_pm_pair(graph, arg_pack, BOOST_PP_CAT(cm_pair_, __LINE__)); \
- typename boost::detail::color_map_maker<GraphT, ArgPackT>::map_type& color_map = BOOST_PP_CAT(cm_pair_, __LINE__).second;
-
   }
 
 } // namespace boost


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk