lemon/bits/edge_set_extender.h
changeset 783 ef88c0a30f85
parent 617 4137ef9aacc6
child 877 141f9c0db4a3
child 962 4efe7b32b134
     1.1 --- a/lemon/bits/edge_set_extender.h	Mon Jan 12 23:11:39 2009 +0100
     1.2 +++ b/lemon/bits/edge_set_extender.h	Thu Nov 05 15:48:01 2009 +0100
     1.3 @@ -19,22 +19,25 @@
     1.4  #ifndef LEMON_BITS_EDGE_SET_EXTENDER_H
     1.5  #define LEMON_BITS_EDGE_SET_EXTENDER_H
     1.6  
     1.7 +#include <lemon/core.h>
     1.8  #include <lemon/error.h>
     1.9  #include <lemon/bits/default_map.h>
    1.10 +#include <lemon/bits/map_extender.h>
    1.11  
    1.12 -///\ingroup digraphbits
    1.13 -///\file
    1.14 -///\brief Extenders for the arc set types
    1.15 +//\ingroup digraphbits
    1.16 +//\file
    1.17 +//\brief Extenders for the arc set types
    1.18  namespace lemon {
    1.19  
    1.20 -  /// \ingroup digraphbits
    1.21 -  ///
    1.22 -  /// \brief Extender for the ArcSets
    1.23 +  // \ingroup digraphbits
    1.24 +  //
    1.25 +  // \brief Extender for the ArcSets
    1.26    template <typename Base>
    1.27    class ArcSetExtender : public Base {
    1.28 +    typedef Base Parent;
    1.29 +
    1.30    public:
    1.31  
    1.32 -    typedef Base Parent;
    1.33      typedef ArcSetExtender Digraph;
    1.34  
    1.35      // Base extensions
    1.36 @@ -70,7 +73,7 @@
    1.37  
    1.38      // Alteration notifier extensions
    1.39  
    1.40 -    /// The arc observer registry.
    1.41 +    // The arc observer registry.
    1.42      typedef AlterationNotifier<ArcSetExtender, Arc> ArcNotifier;
    1.43  
    1.44    protected:
    1.45 @@ -81,9 +84,7 @@
    1.46  
    1.47      using Parent::notifier;
    1.48  
    1.49 -    /// \brief Gives back the arc alteration notifier.
    1.50 -    ///
    1.51 -    /// Gives back the arc alteration notifier.
    1.52 +    // Gives back the arc alteration notifier.
    1.53      ArcNotifier& notifier(Arc) const {
    1.54        return arc_notifier;
    1.55      }
    1.56 @@ -183,30 +184,30 @@
    1.57  
    1.58      };
    1.59  
    1.60 -    /// \brief Base node of the iterator
    1.61 -    ///
    1.62 -    /// Returns the base node (ie. the source in this case) of the iterator
    1.63 +    // \brief Base node of the iterator
    1.64 +    //
    1.65 +    // Returns the base node (ie. the source in this case) of the iterator
    1.66      Node baseNode(const OutArcIt &e) const {
    1.67        return Parent::source(static_cast<const Arc&>(e));
    1.68      }
    1.69 -    /// \brief Running node of the iterator
    1.70 -    ///
    1.71 -    /// Returns the running node (ie. the target in this case) of the
    1.72 -    /// iterator
    1.73 +    // \brief Running node of the iterator
    1.74 +    //
    1.75 +    // Returns the running node (ie. the target in this case) of the
    1.76 +    // iterator
    1.77      Node runningNode(const OutArcIt &e) const {
    1.78        return Parent::target(static_cast<const Arc&>(e));
    1.79      }
    1.80  
    1.81 -    /// \brief Base node of the iterator
    1.82 -    ///
    1.83 -    /// Returns the base node (ie. the target in this case) of the iterator
    1.84 +    // \brief Base node of the iterator
    1.85 +    //
    1.86 +    // Returns the base node (ie. the target in this case) of the iterator
    1.87      Node baseNode(const InArcIt &e) const {
    1.88        return Parent::target(static_cast<const Arc&>(e));
    1.89      }
    1.90 -    /// \brief Running node of the iterator
    1.91 -    ///
    1.92 -    /// Returns the running node (ie. the source in this case) of the
    1.93 -    /// iterator
    1.94 +    // \brief Running node of the iterator
    1.95 +    //
    1.96 +    // Returns the running node (ie. the source in this case) of the
    1.97 +    // iterator
    1.98      Node runningNode(const InArcIt &e) const {
    1.99        return Parent::source(static_cast<const Arc&>(e));
   1.100      }
   1.101 @@ -218,10 +219,9 @@
   1.102      template <typename _Value>
   1.103      class ArcMap 
   1.104        : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
   1.105 -    public:
   1.106 -      typedef ArcSetExtender Digraph;
   1.107        typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
   1.108  
   1.109 +    public:
   1.110        explicit ArcMap(const Digraph& _g) 
   1.111  	: Parent(_g) {}
   1.112        ArcMap(const Digraph& _g, const _Value& _v) 
   1.113 @@ -269,22 +269,21 @@
   1.114    };
   1.115  
   1.116  
   1.117 -  /// \ingroup digraphbits
   1.118 -  ///
   1.119 -  /// \brief Extender for the EdgeSets
   1.120 +  // \ingroup digraphbits
   1.121 +  //
   1.122 +  // \brief Extender for the EdgeSets
   1.123    template <typename Base>
   1.124    class EdgeSetExtender : public Base {
   1.125 +    typedef Base Parent;
   1.126  
   1.127    public:
   1.128  
   1.129 -    typedef Base Parent;
   1.130 -    typedef EdgeSetExtender Digraph;
   1.131 +    typedef EdgeSetExtender Graph;
   1.132  
   1.133      typedef typename Parent::Node Node;
   1.134      typedef typename Parent::Arc Arc;
   1.135      typedef typename Parent::Edge Edge;
   1.136  
   1.137 -
   1.138      int maxId(Node) const {
   1.139        return Parent::maxNodeId();
   1.140      }
   1.141 @@ -350,22 +349,22 @@
   1.142  
   1.143  
   1.144      class NodeIt : public Node { 
   1.145 -      const Digraph* digraph;
   1.146 +      const Graph* graph;
   1.147      public:
   1.148  
   1.149        NodeIt() {}
   1.150  
   1.151        NodeIt(Invalid i) : Node(i) { }
   1.152  
   1.153 -      explicit NodeIt(const Digraph& _graph) : digraph(&_graph) {
   1.154 +      explicit NodeIt(const Graph& _graph) : graph(&_graph) {
   1.155  	_graph.first(static_cast<Node&>(*this));
   1.156        }
   1.157  
   1.158 -      NodeIt(const Digraph& _graph, const Node& node) 
   1.159 -	: Node(node), digraph(&_graph) {}
   1.160 +      NodeIt(const Graph& _graph, const Node& node) 
   1.161 +	: Node(node), graph(&_graph) {}
   1.162  
   1.163        NodeIt& operator++() { 
   1.164 -	digraph->next(*this);
   1.165 +	graph->next(*this);
   1.166  	return *this; 
   1.167        }
   1.168  
   1.169 @@ -373,22 +372,22 @@
   1.170  
   1.171  
   1.172      class ArcIt : public Arc { 
   1.173 -      const Digraph* digraph;
   1.174 +      const Graph* graph;
   1.175      public:
   1.176  
   1.177        ArcIt() { }
   1.178  
   1.179        ArcIt(Invalid i) : Arc(i) { }
   1.180  
   1.181 -      explicit ArcIt(const Digraph& _graph) : digraph(&_graph) {
   1.182 +      explicit ArcIt(const Graph& _graph) : graph(&_graph) {
   1.183  	_graph.first(static_cast<Arc&>(*this));
   1.184        }
   1.185  
   1.186 -      ArcIt(const Digraph& _graph, const Arc& e) : 
   1.187 -	Arc(e), digraph(&_graph) { }
   1.188 +      ArcIt(const Graph& _graph, const Arc& e) : 
   1.189 +	Arc(e), graph(&_graph) { }
   1.190  
   1.191        ArcIt& operator++() { 
   1.192 -	digraph->next(*this);
   1.193 +	graph->next(*this);
   1.194  	return *this; 
   1.195        }
   1.196  
   1.197 @@ -396,23 +395,23 @@
   1.198  
   1.199  
   1.200      class OutArcIt : public Arc { 
   1.201 -      const Digraph* digraph;
   1.202 +      const Graph* graph;
   1.203      public:
   1.204  
   1.205        OutArcIt() { }
   1.206  
   1.207        OutArcIt(Invalid i) : Arc(i) { }
   1.208  
   1.209 -      OutArcIt(const Digraph& _graph, const Node& node) 
   1.210 -	: digraph(&_graph) {
   1.211 +      OutArcIt(const Graph& _graph, const Node& node) 
   1.212 +	: graph(&_graph) {
   1.213  	_graph.firstOut(*this, node);
   1.214        }
   1.215  
   1.216 -      OutArcIt(const Digraph& _graph, const Arc& arc) 
   1.217 -	: Arc(arc), digraph(&_graph) {}
   1.218 +      OutArcIt(const Graph& _graph, const Arc& arc) 
   1.219 +	: Arc(arc), graph(&_graph) {}
   1.220  
   1.221        OutArcIt& operator++() { 
   1.222 -	digraph->nextOut(*this);
   1.223 +	graph->nextOut(*this);
   1.224  	return *this; 
   1.225        }
   1.226  
   1.227 @@ -420,23 +419,23 @@
   1.228  
   1.229  
   1.230      class InArcIt : public Arc { 
   1.231 -      const Digraph* digraph;
   1.232 +      const Graph* graph;
   1.233      public:
   1.234  
   1.235        InArcIt() { }
   1.236  
   1.237        InArcIt(Invalid i) : Arc(i) { }
   1.238  
   1.239 -      InArcIt(const Digraph& _graph, const Node& node) 
   1.240 -	: digraph(&_graph) {
   1.241 +      InArcIt(const Graph& _graph, const Node& node) 
   1.242 +	: graph(&_graph) {
   1.243  	_graph.firstIn(*this, node);
   1.244        }
   1.245  
   1.246 -      InArcIt(const Digraph& _graph, const Arc& arc) : 
   1.247 -	Arc(arc), digraph(&_graph) {}
   1.248 +      InArcIt(const Graph& _graph, const Arc& arc) : 
   1.249 +	Arc(arc), graph(&_graph) {}
   1.250  
   1.251        InArcIt& operator++() { 
   1.252 -	digraph->nextIn(*this);
   1.253 +	graph->nextIn(*this);
   1.254  	return *this; 
   1.255        }
   1.256  
   1.257 @@ -444,22 +443,22 @@
   1.258  
   1.259  
   1.260      class EdgeIt : public Parent::Edge { 
   1.261 -      const Digraph* digraph;
   1.262 +      const Graph* graph;
   1.263      public:
   1.264  
   1.265        EdgeIt() { }
   1.266  
   1.267        EdgeIt(Invalid i) : Edge(i) { }
   1.268  
   1.269 -      explicit EdgeIt(const Digraph& _graph) : digraph(&_graph) {
   1.270 +      explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
   1.271  	_graph.first(static_cast<Edge&>(*this));
   1.272        }
   1.273  
   1.274 -      EdgeIt(const Digraph& _graph, const Edge& e) : 
   1.275 -	Edge(e), digraph(&_graph) { }
   1.276 +      EdgeIt(const Graph& _graph, const Edge& e) : 
   1.277 +	Edge(e), graph(&_graph) { }
   1.278  
   1.279        EdgeIt& operator++() { 
   1.280 -	digraph->next(*this);
   1.281 +	graph->next(*this);
   1.282  	return *this; 
   1.283        }
   1.284  
   1.285 @@ -467,7 +466,7 @@
   1.286  
   1.287      class IncEdgeIt : public Parent::Edge {
   1.288        friend class EdgeSetExtender;
   1.289 -      const Digraph* digraph;
   1.290 +      const Graph* graph;
   1.291        bool direction;
   1.292      public:
   1.293  
   1.294 @@ -475,58 +474,58 @@
   1.295  
   1.296        IncEdgeIt(Invalid i) : Edge(i), direction(false) { }
   1.297  
   1.298 -      IncEdgeIt(const Digraph& _graph, const Node &n) : digraph(&_graph) {
   1.299 +      IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
   1.300  	_graph.firstInc(*this, direction, n);
   1.301        }
   1.302  
   1.303 -      IncEdgeIt(const Digraph& _graph, const Edge &ue, const Node &n)
   1.304 -	: digraph(&_graph), Edge(ue) {
   1.305 +      IncEdgeIt(const Graph& _graph, const Edge &ue, const Node &n)
   1.306 +	: graph(&_graph), Edge(ue) {
   1.307  	direction = (_graph.source(ue) == n);
   1.308        }
   1.309  
   1.310        IncEdgeIt& operator++() {
   1.311 -	digraph->nextInc(*this, direction);
   1.312 +	graph->nextInc(*this, direction);
   1.313  	return *this; 
   1.314        }
   1.315      };
   1.316  
   1.317 -    /// \brief Base node of the iterator
   1.318 -    ///
   1.319 -    /// Returns the base node (ie. the source in this case) of the iterator
   1.320 +    // \brief Base node of the iterator
   1.321 +    //
   1.322 +    // Returns the base node (ie. the source in this case) of the iterator
   1.323      Node baseNode(const OutArcIt &e) const {
   1.324        return Parent::source(static_cast<const Arc&>(e));
   1.325      }
   1.326 -    /// \brief Running node of the iterator
   1.327 -    ///
   1.328 -    /// Returns the running node (ie. the target in this case) of the
   1.329 -    /// iterator
   1.330 +    // \brief Running node of the iterator
   1.331 +    //
   1.332 +    // Returns the running node (ie. the target in this case) of the
   1.333 +    // iterator
   1.334      Node runningNode(const OutArcIt &e) const {
   1.335        return Parent::target(static_cast<const Arc&>(e));
   1.336      }
   1.337  
   1.338 -    /// \brief Base node of the iterator
   1.339 -    ///
   1.340 -    /// Returns the base node (ie. the target in this case) of the iterator
   1.341 +    // \brief Base node of the iterator
   1.342 +    //
   1.343 +    // Returns the base node (ie. the target in this case) of the iterator
   1.344      Node baseNode(const InArcIt &e) const {
   1.345        return Parent::target(static_cast<const Arc&>(e));
   1.346      }
   1.347 -    /// \brief Running node of the iterator
   1.348 -    ///
   1.349 -    /// Returns the running node (ie. the source in this case) of the
   1.350 -    /// iterator
   1.351 +    // \brief Running node of the iterator
   1.352 +    //
   1.353 +    // Returns the running node (ie. the source in this case) of the
   1.354 +    // iterator
   1.355      Node runningNode(const InArcIt &e) const {
   1.356        return Parent::source(static_cast<const Arc&>(e));
   1.357      }
   1.358  
   1.359 -    /// Base node of the iterator
   1.360 -    ///
   1.361 -    /// Returns the base node of the iterator
   1.362 +    // Base node of the iterator
   1.363 +    //
   1.364 +    // Returns the base node of the iterator
   1.365      Node baseNode(const IncEdgeIt &e) const {
   1.366        return e.direction ? u(e) : v(e);
   1.367      }
   1.368 -    /// Running node of the iterator
   1.369 -    ///
   1.370 -    /// Returns the running node of the iterator
   1.371 +    // Running node of the iterator
   1.372 +    //
   1.373 +    // Returns the running node of the iterator
   1.374      Node runningNode(const IncEdgeIt &e) const {
   1.375        return e.direction ? v(e) : u(e);
   1.376      }
   1.377 @@ -534,14 +533,13 @@
   1.378  
   1.379      template <typename _Value>
   1.380      class ArcMap 
   1.381 -      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
   1.382 +      : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
   1.383 +      typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
   1.384 +
   1.385      public:
   1.386 -      typedef EdgeSetExtender Digraph;
   1.387 -      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
   1.388 -
   1.389 -      ArcMap(const Digraph& _g) 
   1.390 +      explicit ArcMap(const Graph& _g) 
   1.391  	: Parent(_g) {}
   1.392 -      ArcMap(const Digraph& _g, const _Value& _v) 
   1.393 +      ArcMap(const Graph& _g, const _Value& _v) 
   1.394  	: Parent(_g, _v) {}
   1.395  
   1.396        ArcMap& operator=(const ArcMap& cmap) {
   1.397 @@ -559,15 +557,14 @@
   1.398  
   1.399      template <typename _Value>
   1.400      class EdgeMap 
   1.401 -      : public MapExtender<DefaultMap<Digraph, Edge, _Value> > {
   1.402 +      : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
   1.403 +      typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
   1.404 +
   1.405      public:
   1.406 -      typedef EdgeSetExtender Digraph;
   1.407 -      typedef MapExtender<DefaultMap<Digraph, Edge, _Value> > Parent;
   1.408 -
   1.409 -      EdgeMap(const Digraph& _g) 
   1.410 +      explicit EdgeMap(const Graph& _g) 
   1.411  	: Parent(_g) {}
   1.412  
   1.413 -      EdgeMap(const Digraph& _g, const _Value& _v) 
   1.414 +      EdgeMap(const Graph& _g, const _Value& _v) 
   1.415  	: Parent(_g, _v) {}
   1.416  
   1.417        EdgeMap& operator=(const EdgeMap& cmap) {