Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54078 - in sandbox/SOC/2009/function_graph: boost/function_graph libs/test
From: mlopez7_at_[hidden]
Date: 2009-06-18 21:33:58


Author: lopezeant
Date: 2009-06-18 21:33:58 EDT (Thu, 18 Jun 2009)
New Revision: 54078
URL: http://svn.boost.org/trac/boost/changeset/54078

Log:
iterator is now range
Text files modified:
   sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp | 61 ++++++++++++++-------------------------
   sandbox/SOC/2009/function_graph/libs/test/test2.cpp | 24 ++++++---------
   2 files changed, 32 insertions(+), 53 deletions(-)

Modified: sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp
==============================================================================
--- sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp (original)
+++ sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp 2009-06-18 21:33:58 EDT (Thu, 18 Jun 2009)
@@ -75,23 +75,6 @@
 
 
 
-/** @name function_graph_range */
-template <typename Iterator>
-struct function_graph_range
-{
- typedef Iterator iterator_type;
- typedef typename iterator_range<iterator_type> iterator_range_type;
-
- /** Constructor - takes a pair of iterators */
- function_graph_range(iterator_range_type const& r)
- : range_(r)
- { }
-
- iterator_range_type range_;
-};
-
-
-
 /**
  * Empty function graph prevents instantiations such as function_graph<int> and
  * function_graph<bool (int, int)>.
@@ -110,15 +93,13 @@
  * set_edge is part of the interface. Paired with it is the default constructor.
  */
 
-template <typename Result, typename Vertex, typename Iterator>
-struct function_graph<function<Result(Vertex, Vertex)>, Iterator>
- : public function_graph_base<function<Result(Vertex, Vertex)> >,
- public function_graph_range<Range>
+template <typename Result, typename Vertex, typename Range>
+struct function_graph<function<Result(Vertex, Vertex)>, Range>
+ : public function_graph_base<function<Result(Vertex, Vertex)> >
 {
 private:
     typedef function_graph_base<function<Result(Vertex, Vertex)> > Base;
     typedef function_graph<function<Result(Vertex, Vertex)> > This;
- typedef function_graph_range<Iterator> RangeBase; //? not another Base
 
 public:
     typedef typename Base::function_type function_type;
@@ -128,13 +109,17 @@
     typedef directed_tag directed_category;
     typedef disallow_parallel_edge_tag edge_parallel_category;
     typedef adjacency_matrix_tag traversal_category;
- typedef typename RangeBase::iterator_range_type iterator_range_type;
- typedef typename RangeBase::iterator_type iterator_type;
+ typedef Range vertex_iterator_range_type;
+ typedef typename range_iterator<vertex_iterator_range_type>::type
+ vertex_iterator_type;
 
     /** Constructor: takes a functor and range */
- function_graph(function_type const& f, iterator_range_type const& r)
- : Base(f), Range(r)
+ function_graph(function_type const& f, vertex_iterator_range_type const& r)
+ : Base(f), range_(r)
     { }
+
+private:
+ Range range_;
 };
 
 template <typename Result, typename Vertex>
@@ -175,12 +160,12 @@
     return function_graph<function<Result(Vertex, Vertex)> >(f);
 }
 
-template <typename Result, typename Vertex, typename Iterator>
-function_graph<function<Result(Vertex, Vertex)>, Iterator>
+template <typename Result, typename Vertex, typename Range>
+function_graph<function<Result(Vertex, Vertex)>, Range>
     make_function_graph(function<Result(Vertex, Vertex)> const& f,
- Iterator const& r)
+ Range const& r)
 {
- return function_graph<function<Result(Vertex, Vertex)>, Iterator>(f,r);
+ return function_graph<function<Result(Vertex, Vertex)>, Range>(f,r);
 }
 //@}
 
@@ -199,18 +184,16 @@
 
 /** source(e, g) and target(e, g) are part of the incedence graph concept. */
 
-template <typename Result, typename Vertex, typename Iterator>
+template <typename Result, typename Vertex, typename Range>
 Vertex source(detail::func_graph_edge<Result, Vertex> const& e,
- function_graph<function<Result(Vertex, Vertex)>, Iterator > const&
- g)
+ function_graph<function<Result(Vertex, Vertex)>, Range > const& g)
 {
     return e.source;
 }
 
-template <typename Result, typename Vertex, typename Iterator>
+template <typename Result, typename Vertex, typename Range>
 Vertex target(detail::func_graph_edge<Result, Vertex> const& e,
- function_graph<function<Result(Vertex, Vertex)>, Iterator > const&
- g)
+ function_graph<function<Result(Vertex, Vertex)>, Range > const& g)
 {
     return e.target;
 }
@@ -219,7 +202,7 @@
 
 /** vertices(g) is part of the vertex list concept. */
 
-template <typename Result, typename Vertex, typename Iterator>
+template <typename Result, typename Vertex, typename Range>
 std::pair<typename function_graph<function<Result(Vertex, Vertex)>,
           Range>::iterator_type,
           typename function_graph<function<Result(Vertex, Vertex)>,
@@ -268,9 +251,9 @@
 
 } // detail namespace
 
-#define FUNC_GRAPH function_graph<function<Result(Vertex, Vertex)>, Iterator>
+#define FUNC_GRAPH function_graph<function<Result(Vertex, Vertex)>, Range>
 
-template <typename Result, typename Vertex, typename Iterator>
+template <typename Result, typename Vertex, typename Range>
 std::pair<typename FUNC_GRAPH::edge_descriptor, bool>
 edge(typename FUNC_GRAPH::vertex_descriptor u,
      typename FUNC_GRAPH::vertex_descriptor v,

Modified: sandbox/SOC/2009/function_graph/libs/test/test2.cpp
==============================================================================
--- sandbox/SOC/2009/function_graph/libs/test/test2.cpp (original)
+++ sandbox/SOC/2009/function_graph/libs/test/test2.cpp 2009-06-18 21:33:58 EDT (Thu, 18 Jun 2009)
@@ -8,7 +8,7 @@
 #include <algorithm>
 #include <vector>
 //#include <utility>
-#include "function_graph_alt.hpp"
+#include "function_graph.hpp"
 #include <cmath>
 #include <boost/range.hpp>
 
@@ -27,22 +27,18 @@
     ////////
     // Create typedefs for functions and function graphs
     typedef boost::function<bool(int,int)> function_boolean;
- typedef boost::function_graph<function_boolean> graph_boolean;
+ typedef std::pair<std::vector<unsigned int>::iterator,
+ std::vector<unsigned int>::iterator> iterator_range;
+ typedef boost::function_graph<function_boolean> G;
+ typedef boost::function_graph<function_boolean, iterator_range> GwithRange;
 
     ////////
     // Create functions, graphs and edges
- graph_boolean funcGraph_boolean(std::less<int>());
+ //G funcGraph = boost::make_function_graph(less_than<int>());
+ G funcGraph(less_than<int>());
+ GwithRange funcGraphWithRange(less_than<int>(),
+ std::make_pair(vectorOfInts.begin(),
+ vectorOfInts.end()));
 
- typedef std::pair<std::vector<unsigned int>::iterator,
- std::vector<unsigned int>::iterator> iter_pair;
-
-
- boost::iterator_range<std::vector<unsigned int>::iterator>
- rangeIter(vectorOfInts.begin(), vectorOfInts.end());
- boost::iterator_range<std::vector<unsigned int>::iterator>
- rangeIter2(vectorOfInts);
- boost::iterator_range<std::vector<unsigned int>::iterator>
- rangeIter3(std::make_pair(vectorOfInts.begin(), vectorOfInts.end()));
-
     return 0;
 }


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