lemon/bits/default_map.h
changeset 1909 2d806130e700
parent 1875 98698b69a902
child 1910 f95eea8c34b0
equal deleted inserted replaced
7:f558466b1364 8:0f3ca6c0d6a1
   264     
   264     
   265   };
   265   };
   266 
   266 
   267   /// \e
   267   /// \e
   268   template <typename _Base> 
   268   template <typename _Base> 
   269   class MappableUndirGraphExtender : 
   269   class MappableUGraphExtender : 
   270     public MappableGraphExtender<_Base> {
   270     public MappableGraphExtender<_Base> {
   271   public:
   271   public:
   272 
   272 
   273     typedef MappableUndirGraphExtender Graph;
   273     typedef MappableUGraphExtender Graph;
   274     typedef MappableGraphExtender<_Base> Parent;
   274     typedef MappableGraphExtender<_Base> Parent;
   275 
   275 
   276     typedef typename Parent::UndirEdge UndirEdge;
   276     typedef typename Parent::UEdge UEdge;
   277 
   277 
   278     template <typename _Value>
   278     template <typename _Value>
   279     class UndirEdgeMap 
   279     class UEdgeMap 
   280       : public IterableMapExtender<DefaultMap<Graph, UndirEdge, _Value> > {
   280       : public IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > {
   281     public:
   281     public:
   282       typedef MappableUndirGraphExtender Graph;
   282       typedef MappableUGraphExtender Graph;
   283       typedef IterableMapExtender<
   283       typedef IterableMapExtender<
   284 	DefaultMap<Graph, UndirEdge, _Value> > Parent;
   284 	DefaultMap<Graph, UEdge, _Value> > Parent;
   285 
   285 
   286       UndirEdgeMap(const Graph& _g) 
   286       UEdgeMap(const Graph& _g) 
   287 	: Parent(_g) {}
   287 	: Parent(_g) {}
   288       UndirEdgeMap(const Graph& _g, const _Value& _v) 
   288       UEdgeMap(const Graph& _g, const _Value& _v) 
   289 	: Parent(_g, _v) {}
   289 	: Parent(_g, _v) {}
   290 
   290 
   291       UndirEdgeMap& operator=(const UndirEdgeMap& cmap) {
   291       UEdgeMap& operator=(const UEdgeMap& cmap) {
   292 	return operator=<UndirEdgeMap>(cmap);
   292 	return operator=<UEdgeMap>(cmap);
   293       }
   293       }
   294 
   294 
   295       template <typename CMap>
   295       template <typename CMap>
   296       UndirEdgeMap& operator=(const CMap& cmap) {
   296       UEdgeMap& operator=(const CMap& cmap) {
   297 	checkConcept<concept::ReadMap<UndirEdge, _Value>, CMap>();
   297 	checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
   298 	const typename Parent::Graph* graph = Parent::getGraph();
   298 	const typename Parent::Graph* graph = Parent::getGraph();
   299 	UndirEdge it;
   299 	UEdge it;
   300 	for (graph->first(it); it != INVALID; graph->next(it)) {
   300 	for (graph->first(it); it != INVALID; graph->next(it)) {
   301 	  Parent::set(it, cmap[it]);
   301 	  Parent::set(it, cmap[it]);
   302 	}
   302 	}
   303 	return *this;
   303 	return *this;
   304       }
   304       }
   307 
   307 
   308   };
   308   };
   309 
   309 
   310   /// \e
   310   /// \e
   311   template <typename _Base> 
   311   template <typename _Base> 
   312   class MappableUndirEdgeSetExtender : 
   312   class MappableUEdgeSetExtender : 
   313     public MappableEdgeSetExtender<_Base> {
   313     public MappableEdgeSetExtender<_Base> {
   314   public:
   314   public:
   315 
   315 
   316     typedef MappableUndirEdgeSetExtender Graph;
   316     typedef MappableUEdgeSetExtender Graph;
   317     typedef MappableEdgeSetExtender<_Base> Parent;
   317     typedef MappableEdgeSetExtender<_Base> Parent;
   318 
   318 
   319     typedef typename Parent::UndirEdge UndirEdge;
   319     typedef typename Parent::UEdge UEdge;
   320 
   320 
   321     template <typename _Value>
   321     template <typename _Value>
   322     class UndirEdgeMap 
   322     class UEdgeMap 
   323       : public IterableMapExtender<DefaultMap<Graph, UndirEdge, _Value> > {
   323       : public IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > {
   324     public:
   324     public:
   325       typedef MappableUndirEdgeSetExtender Graph;
   325       typedef MappableUEdgeSetExtender Graph;
   326       typedef IterableMapExtender<
   326       typedef IterableMapExtender<
   327 	DefaultMap<Graph, UndirEdge, _Value> > Parent;
   327 	DefaultMap<Graph, UEdge, _Value> > Parent;
   328 
   328 
   329       UndirEdgeMap(const Graph& _g) 
   329       UEdgeMap(const Graph& _g) 
   330 	: Parent(_g) {}
   330 	: Parent(_g) {}
   331       UndirEdgeMap(const Graph& _g, const _Value& _v) 
   331       UEdgeMap(const Graph& _g, const _Value& _v) 
   332 	: Parent(_g, _v) {}
   332 	: Parent(_g, _v) {}
   333 
   333 
   334       UndirEdgeMap& operator=(const UndirEdgeMap& cmap) {
   334       UEdgeMap& operator=(const UEdgeMap& cmap) {
   335 	return operator=<UndirEdgeMap>(cmap);
   335 	return operator=<UEdgeMap>(cmap);
   336       }
   336       }
   337 
   337 
   338       template <typename CMap>
   338       template <typename CMap>
   339       UndirEdgeMap& operator=(const CMap& cmap) {
   339       UEdgeMap& operator=(const CMap& cmap) {
   340 	checkConcept<concept::ReadMap<UndirEdge, _Value>, CMap>();
   340 	checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
   341 	const typename Parent::Graph* graph = Parent::getGraph();
   341 	const typename Parent::Graph* graph = Parent::getGraph();
   342 	UndirEdge it;
   342 	UEdge it;
   343 	for (graph->first(it); it != INVALID; graph->next(it)) {
   343 	for (graph->first(it); it != INVALID; graph->next(it)) {
   344 	  Parent::set(it, cmap[it]);
   344 	  Parent::set(it, cmap[it]);
   345 	}
   345 	}
   346 	return *this;
   346 	return *this;
   347       }
   347       }
   350 
   350 
   351   };
   351   };
   352 
   352 
   353 
   353 
   354   template <typename _Base>
   354   template <typename _Base>
   355   class MappableUndirBipartiteGraphExtender : public _Base {
   355   class MappableUBipartiteGraphExtender : public _Base {
   356   public:
   356   public:
   357 
   357 
   358     typedef _Base Parent;
   358     typedef _Base Parent;
   359     typedef MappableUndirBipartiteGraphExtender Graph;
   359     typedef MappableUBipartiteGraphExtender Graph;
   360 
   360 
   361     typedef typename Parent::Node Node;
   361     typedef typename Parent::Node Node;
   362     typedef typename Parent::UpperNode UpperNode;
   362     typedef typename Parent::UpperNode UpperNode;
   363     typedef typename Parent::LowerNode LowerNode;
   363     typedef typename Parent::LowerNode LowerNode;
   364     typedef typename Parent::Edge Edge;
   364     typedef typename Parent::Edge Edge;
   365     typedef typename Parent::UndirEdge UndirEdge;
   365     typedef typename Parent::UEdge UEdge;
   366     
   366     
   367     template <typename _Value>
   367     template <typename _Value>
   368     class UpperNodeMap 
   368     class UpperNodeMap 
   369       : public IterableMapExtender<DefaultMap<Graph, UpperNode, _Value> > {
   369       : public IterableMapExtender<DefaultMap<Graph, UpperNode, _Value> > {
   370     public:
   370     public:
   371       typedef MappableUndirBipartiteGraphExtender Graph;
   371       typedef MappableUBipartiteGraphExtender Graph;
   372       typedef IterableMapExtender<DefaultMap<Graph, UpperNode, _Value> > 
   372       typedef IterableMapExtender<DefaultMap<Graph, UpperNode, _Value> > 
   373       Parent;
   373       Parent;
   374     
   374     
   375       UpperNodeMap(const Graph& _g) 
   375       UpperNodeMap(const Graph& _g) 
   376 	: Parent(_g) {}
   376 	: Parent(_g) {}
   403 
   403 
   404     template <typename _Value>
   404     template <typename _Value>
   405     class LowerNodeMap 
   405     class LowerNodeMap 
   406       : public IterableMapExtender<DefaultMap<Graph, LowerNode, _Value> > {
   406       : public IterableMapExtender<DefaultMap<Graph, LowerNode, _Value> > {
   407     public:
   407     public:
   408       typedef MappableUndirBipartiteGraphExtender Graph;
   408       typedef MappableUBipartiteGraphExtender Graph;
   409       typedef IterableMapExtender<DefaultMap<Graph, LowerNode, _Value> > 
   409       typedef IterableMapExtender<DefaultMap<Graph, LowerNode, _Value> > 
   410       Parent;
   410       Parent;
   411     
   411     
   412       LowerNodeMap(const Graph& _g) 
   412       LowerNodeMap(const Graph& _g) 
   413 	: Parent(_g) {}
   413 	: Parent(_g) {}
   441   protected:
   441   protected:
   442 
   442 
   443     template <typename _Value>
   443     template <typename _Value>
   444     class NodeMapBase : public Parent::NodeNotifier::ObserverBase {
   444     class NodeMapBase : public Parent::NodeNotifier::ObserverBase {
   445     public:
   445     public:
   446       typedef MappableUndirBipartiteGraphExtender Graph;
   446       typedef MappableUBipartiteGraphExtender Graph;
   447 
   447 
   448       typedef Node Key;
   448       typedef Node Key;
   449       typedef _Value Value;
   449       typedef _Value Value;
   450 
   450 
   451       /// The reference type of the map;
   451       /// The reference type of the map;
   521 
   521 
   522     template <typename _Value>
   522     template <typename _Value>
   523     class NodeMap 
   523     class NodeMap 
   524       : public IterableMapExtender<NodeMapBase<_Value> > {
   524       : public IterableMapExtender<NodeMapBase<_Value> > {
   525     public:
   525     public:
   526       typedef MappableUndirBipartiteGraphExtender Graph;
   526       typedef MappableUBipartiteGraphExtender Graph;
   527       typedef IterableMapExtender< NodeMapBase<_Value> > Parent;
   527       typedef IterableMapExtender< NodeMapBase<_Value> > Parent;
   528     
   528     
   529       NodeMap(const Graph& _g) 
   529       NodeMap(const Graph& _g) 
   530 	: Parent(_g) {}
   530 	: Parent(_g) {}
   531       NodeMap(const Graph& _g, const _Value& _v) 
   531       NodeMap(const Graph& _g, const _Value& _v) 
   559 
   559 
   560     template <typename _Value>
   560     template <typename _Value>
   561     class EdgeMap 
   561     class EdgeMap 
   562       : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
   562       : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
   563     public:
   563     public:
   564       typedef MappableUndirBipartiteGraphExtender Graph;
   564       typedef MappableUBipartiteGraphExtender Graph;
   565       typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
   565       typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
   566     
   566     
   567       EdgeMap(const Graph& _g) 
   567       EdgeMap(const Graph& _g) 
   568 	: Parent(_g) {}
   568 	: Parent(_g) {}
   569       EdgeMap(const Graph& _g, const _Value& _v) 
   569       EdgeMap(const Graph& _g, const _Value& _v) 
   584 	return *this;
   584 	return *this;
   585       }
   585       }
   586     };
   586     };
   587 
   587 
   588     template <typename _Value>
   588     template <typename _Value>
   589     class UndirEdgeMap 
   589     class UEdgeMap 
   590       : public IterableMapExtender<DefaultMap<Graph, UndirEdge, _Value> > {
   590       : public IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > {
   591     public:
   591     public:
   592       typedef MappableUndirBipartiteGraphExtender Graph;
   592       typedef MappableUBipartiteGraphExtender Graph;
   593       typedef IterableMapExtender<DefaultMap<Graph, UndirEdge, _Value> > 
   593       typedef IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > 
   594       Parent;
   594       Parent;
   595     
   595     
   596       UndirEdgeMap(const Graph& _g) 
   596       UEdgeMap(const Graph& _g) 
   597 	: Parent(_g) {}
   597 	: Parent(_g) {}
   598       UndirEdgeMap(const Graph& _g, const _Value& _v) 
   598       UEdgeMap(const Graph& _g, const _Value& _v) 
   599 	: Parent(_g, _v) {}
   599 	: Parent(_g, _v) {}
   600     
   600     
   601       UndirEdgeMap& operator=(const UndirEdgeMap& cmap) {
   601       UEdgeMap& operator=(const UEdgeMap& cmap) {
   602 	return operator=<UndirEdgeMap>(cmap);
   602 	return operator=<UEdgeMap>(cmap);
   603       }
   603       }
   604     
   604     
   605       template <typename CMap>
   605       template <typename CMap>
   606       UndirEdgeMap& operator=(const CMap& cmap) {
   606       UEdgeMap& operator=(const CMap& cmap) {
   607 	checkConcept<concept::ReadMap<UndirEdge, _Value>, CMap>();
   607 	checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
   608 	const typename Parent::Graph* graph = Parent::getGraph();
   608 	const typename Parent::Graph* graph = Parent::getGraph();
   609 	UndirEdge it;
   609 	UEdge it;
   610 	for (graph->first(it); it != INVALID; graph->next(it)) {
   610 	for (graph->first(it); it != INVALID; graph->next(it)) {
   611 	  Parent::set(it, cmap[it]);
   611 	  Parent::set(it, cmap[it]);
   612 	}
   612 	}
   613 	return *this;
   613 	return *this;
   614       }
   614       }