Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54296 - in sandbox/SOC/2009/function_graph: boost/function_graph libs/test
From: mlopez7_at_[hidden]
Date: 2009-06-23 21:28:25


Author: lopezeant
Date: 2009-06-23 21:28:24 EDT (Tue, 23 Jun 2009)
New Revision: 54296
URL: http://svn.boost.org/trac/boost/changeset/54296

Log:
In edge iterator includes edge now and test1 works again.
Text files modified:
   sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp | 73 +++++++++++++++++++++++++--------------
   sandbox/SOC/2009/function_graph/libs/test/test1.cpp | 6 +-
   2 files changed, 49 insertions(+), 30 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-23 21:28:24 EDT (Tue, 23 Jun 2009)
@@ -28,15 +28,15 @@
     typedef Result result_type;
     typedef Vertex vertex_descriptor;
 
- func_graph_edge(result_type rslt,
- vertex_descriptor src,
- vertex_descriptor trg)
- : result(rslt), source(src), target(trg)
+ func_graph_edge(result_type result,
+ vertex_descriptor source,
+ vertex_descriptor target)
+ : result_(result), source_(source), target_(target)
     { }
 
- result_type result;
- vertex_descriptor source;
- vertex_descriptor target;
+ result_type result_;
+ vertex_descriptor source_;
+ vertex_descriptor target_;
 };
 
 } // detail namespace
@@ -77,16 +77,21 @@
 
 
 /** @name function_graph_in_edge_iterator
- * Iterates through the in edges of a vertex
+ * Iterates through the in edges of a vertex.
  * @note The name of this data type is 31 characters long. I need some brevity.
  */
 
-template<typename Edge, typename Range>
+template<typename Function, typename Edge, typename Range>
 struct function_graph_in_edge_iterator {
+private:
+ typedef function_graph_in_edge_iterator<Function, Edge, Range> This;
+
+public:
     typedef Range vertex_iterator_range;
     typedef typename iterator_range<vertex_iterator_range>::type
             vertex_iterator;
     typedef Edge edge_descriptor;
+ typedef Function function_type;
 
     /** Iterator traits */
     typedef std::bidirectional_iterator_tag iterator_category;
@@ -95,26 +100,40 @@
     typedef value_type* pointer;
     typedef value_type& reference;
 
- /** Default constructor which looks for the first edge. */
- function_graph_in_edge_iterator()
- : range_()
+ /** Constructors */
+ //@{
+ function_graph_in_edge_iterator(function_type const& f)
+ : edge_(f), range_()
+ { };
+
+ function_graph_in_edge_iterator(function_type const& f,
+ vertex_iterator_range const& r)
+ : edge_(f), range_(r)
     { };
 
- /** Constructor taking a vertex range */
- function_graph_in_edge_iterator(vertex_iterator_range const& cp)
- : range_(cp)
+ function_graph_in_edge_iterator(This const& cp)
+ : edge_(cp.edge_), range_(cp.range_)
     { };
+ //@}
 
     /** Bidirectional Iterator operator overloads */
     function_graph_in_edge_iterator& operator++()
- { };
+ {
+ ++begin(range_);
+ return begin(range_);
+ };
 
     function_graph_in_edge_iterator& operator--()
     { };
 
- vertex_iterator& operator*()
- { };
+ edge_descriptor& operator*()
+ {
+ return edge_descriptor(edge_(*begin(range_), *end(range_)),
+ begin(range_),
+ end(range_));
+ };
 
+ function_type edge_;
     vertex_iterator_range range_;
 };
 
@@ -157,7 +176,7 @@
     typedef Range vertex_iterator_range;
     typedef typename range_iterator<vertex_iterator_range>::type
                          vertex_iterator;
- typedef function_graph_in_edge_iterator<edge_descriptor,
+ typedef function_graph_in_edge_iterator<function_type, edge_descriptor,
             vertex_iterator_range> in_edge_iterator;
 
     /** Constructor: takes a functor and range */
@@ -213,14 +232,14 @@
 Vertex source(detail::func_graph_edge<Result, Vertex> const& e,
               function_graph<function<Result(Vertex, Vertex)>, Range > const& g)
 {
- return e.source;
+ return e.source_;
 }
 
 template <typename Result, typename Vertex, typename Range>
 Vertex target(detail::func_graph_edge<Result, Vertex> const& e,
               function_graph<function<Result(Vertex, Vertex)>, Range > const& g)
 {
- return e.target;
+ return e.target_;
 }
 
 
@@ -241,14 +260,14 @@
     typedef typename Graph::vertex_iterator vertex_iterator;
     typedef std::pair<in_edge_iterator, in_edge_iterator> iter_range;
 
- vertex_iterator first_vertex_pair = boost::begin(g.range_);
- vertex_iterator vertex_end = boost::end(g.range_);
+ vertex_iterator first_vertex_pair = begin(g.range_);
+ vertex_iterator vertex_end = end(g.range_);
     while((first_vertex_pair != vertex_end) || !g.edge_(first_vertex_pair, v))
     { ++first_vertex_pair; }
- in_edge_iterator begin(first_vertex_pair, v);
- in_edge_iterator end(vertex_end, v);
+ in_edge_iterator in_edge_begin(first_vertex_pair, v);
+ in_edge_iterator in_edge_end(vertex_end, v);
 
- return std::make_pair(begin, end);
+ return std::make_pair(in_edge_begin, in_edge_end);
 }
 
 
@@ -315,7 +334,7 @@
     typedef FUNC_GRAPH graph_type;
     typedef typename FUNC_GRAPH::result_type result_type;
     result_type result = g.edge(u, v);
- return bind_edge(result, u, v);
+ return detail::bind_edge(result, u, v);
 }
 
 #undef FUNC_GRAPH

Modified: sandbox/SOC/2009/function_graph/libs/test/test1.cpp
==============================================================================
--- sandbox/SOC/2009/function_graph/libs/test/test1.cpp (original)
+++ sandbox/SOC/2009/function_graph/libs/test/test1.cpp 2009-06-23 21:28:24 EDT (Tue, 23 Jun 2009)
@@ -79,17 +79,17 @@
     graph_boolean::edge_descriptor e1 = edge(x, y, funcGraph_boolean).first;
     assert(source(e1, funcGraph_boolean) == x);
     assert(target(e1, funcGraph_boolean) == y);
- assert(e1.result == (1 < 2));
+ assert(e1.result_ == (1 < 2));
 
     graph_normal::edge_descriptor e2 = edge(u, v, funcGraph_normal).first;
     assert(source(e2, funcGraph_normal) == u);
     assert(target(e2, funcGraph_normal) == v);
- assert(e2.result == (u + v));
+ assert(e2.result_ == (u + v));
 
     graph_optional::edge_descriptor e3 = edge(r, s, funcGraph_optional).first;
     assert(source(e3, funcGraph_optional) == r);
     assert(target(e3, funcGraph_optional) == s);
- assert(e2.result == -1);
+ assert(e2.result_ == -1);
     
     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