lemon/bits/edge_set_extender.h
changeset 2013 02e70e25aac5
parent 1996 5dc13b93f8b4
child 2031 080d51024ac5
equal deleted inserted replaced
2:f95b686d61b6 3:d2b2bf30584b
    71 
    71 
    72 
    72 
    73     // Alteration notifier extensions
    73     // Alteration notifier extensions
    74 
    74 
    75     /// The edge observer registry.
    75     /// The edge observer registry.
    76     typedef AlterationNotifier<Edge> EdgeNotifier;
    76     typedef AlterationNotifier<EdgeSetExtender, Edge> EdgeNotifier;
    77 
    77 
    78   protected:
    78   protected:
    79 
    79 
    80     mutable EdgeNotifier edge_notifier;
    80     mutable EdgeNotifier edge_notifier;
    81 
    81 
   217 
   217 
   218     // Mappable extension
   218     // Mappable extension
   219     
   219     
   220     template <typename _Value>
   220     template <typename _Value>
   221     class EdgeMap 
   221     class EdgeMap 
   222       : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
   222       : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
   223     public:
   223     public:
   224       typedef EdgeSetExtender Graph;
   224       typedef EdgeSetExtender Graph;
   225       typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
   225       typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
   226 
   226 
   227       EdgeMap(const Graph& _g) 
   227       EdgeMap(const Graph& _g) 
   228 	: Parent(_g) {}
   228 	: Parent(_g) {}
   229       EdgeMap(const Graph& _g, const _Value& _v) 
   229       EdgeMap(const Graph& _g, const _Value& _v) 
   230 	: Parent(_g, _v) {}
   230 	: Parent(_g, _v) {}
   262     void erase(const Edge& edge) {
   262     void erase(const Edge& edge) {
   263       getNotifier(Edge()).erase(edge);
   263       getNotifier(Edge()).erase(edge);
   264       Parent::erase(edge);
   264       Parent::erase(edge);
   265     }
   265     }
   266 
   266 
       
   267     EdgeSetExtender() {
       
   268       edge_notifier.setContainer(*this);
       
   269     }
   267 
   270 
   268     ~EdgeSetExtender() {
   271     ~EdgeSetExtender() {
   269       edge_notifier.clear();
   272       edge_notifier.clear();
   270     }
   273     }
   271 
   274 
   328     using Parent::direct;
   331     using Parent::direct;
   329     Edge direct(const UEdge &ue, const Node &s) const {
   332     Edge direct(const UEdge &ue, const Node &s) const {
   330       return Parent::direct(ue, Parent::source(ue) == s);
   333       return Parent::direct(ue, Parent::source(ue) == s);
   331     }
   334     }
   332 
   335 
   333     typedef AlterationNotifier<Edge> EdgeNotifier;
   336     typedef AlterationNotifier<UEdgeSetExtender, Edge> EdgeNotifier;
   334     typedef AlterationNotifier<UEdge> UEdgeNotifier;
   337     typedef AlterationNotifier<UEdgeSetExtender, UEdge> UEdgeNotifier;
   335 
   338 
   336 
   339 
   337   protected:
   340   protected:
   338 
   341 
   339     mutable EdgeNotifier edge_notifier;
   342     mutable EdgeNotifier edge_notifier;
   535     }
   538     }
   536 
   539 
   537 
   540 
   538     template <typename _Value>
   541     template <typename _Value>
   539     class EdgeMap 
   542     class EdgeMap 
   540       : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
   543       : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
   541     public:
   544     public:
   542       typedef UEdgeSetExtender Graph;
   545       typedef UEdgeSetExtender Graph;
   543       typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
   546       typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
   544 
   547 
   545       EdgeMap(const Graph& _g) 
   548       EdgeMap(const Graph& _g) 
   546 	: Parent(_g) {}
   549 	: Parent(_g) {}
   547       EdgeMap(const Graph& _g, const _Value& _v) 
   550       EdgeMap(const Graph& _g, const _Value& _v) 
   548 	: Parent(_g, _v) {}
   551 	: Parent(_g, _v) {}
   564     };
   567     };
   565 
   568 
   566 
   569 
   567     template <typename _Value>
   570     template <typename _Value>
   568     class UEdgeMap 
   571     class UEdgeMap 
   569       : public IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > {
   572       : public MapExtender<DefaultMap<Graph, UEdge, _Value> > {
   570     public:
   573     public:
   571       typedef UEdgeSetExtender Graph;
   574       typedef UEdgeSetExtender Graph;
   572       typedef IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > Parent;
   575       typedef MapExtender<DefaultMap<Graph, UEdge, _Value> > Parent;
   573 
   576 
   574       UEdgeMap(const Graph& _g) 
   577       UEdgeMap(const Graph& _g) 
   575 	: Parent(_g) {}
   578 	: Parent(_g) {}
   576       UEdgeMap(const Graph& _g, const _Value& _v) 
   579       UEdgeMap(const Graph& _g, const _Value& _v) 
   577 	: Parent(_g, _v) {}
   580 	: Parent(_g, _v) {}
   615       getNotifier(UEdge()).erase(uedge);
   618       getNotifier(UEdge()).erase(uedge);
   616       Parent::erase(uedge);
   619       Parent::erase(uedge);
   617     }
   620     }
   618 
   621 
   619 
   622 
       
   623     UEdgeSetExtender() {
       
   624       edge_notifier.setContainer(*this);
       
   625       uedge_notifier.setContainer(*this);
       
   626     }
       
   627 
   620     ~UEdgeSetExtender() {
   628     ~UEdgeSetExtender() {
   621       getNotifier(Edge()).clear();
   629       uedge_notifier.clear();
   622       getNotifier(UEdge()).clear();
   630       edge_notifier.clear();
   623     }
   631     }
   624     
   632     
   625   };
   633   };
   626 
   634 
   627 }
   635 }