lemon/bits/map_extender.h
changeset 891 5205145fabf6
parent 580 2313edd0db0b
child 718 703ebf476a1d
equal deleted inserted replaced
6:c644c04c32ec 7:968720842aa6
    34   // \ingroup graphbits
    34   // \ingroup graphbits
    35   //
    35   //
    36   // \brief Extender for maps
    36   // \brief Extender for maps
    37   template <typename _Map>
    37   template <typename _Map>
    38   class MapExtender : public _Map {
    38   class MapExtender : public _Map {
    39   public:
       
    40 
       
    41     typedef _Map Parent;
    39     typedef _Map Parent;
       
    40     typedef typename Parent::GraphType GraphType;
       
    41 
       
    42   public:
       
    43 
    42     typedef MapExtender Map;
    44     typedef MapExtender Map;
    43 
       
    44 
       
    45     typedef typename Parent::Graph Graph;
       
    46     typedef typename Parent::Key Item;
    45     typedef typename Parent::Key Item;
    47 
    46 
    48     typedef typename Parent::Key Key;
    47     typedef typename Parent::Key Key;
    49     typedef typename Parent::Value Value;
    48     typedef typename Parent::Value Value;
    50     typedef typename Parent::Reference Reference;
    49     typedef typename Parent::Reference Reference;
    56     friend class MapIt;
    55     friend class MapIt;
    57     friend class ConstMapIt;
    56     friend class ConstMapIt;
    58 
    57 
    59   public:
    58   public:
    60 
    59 
    61     MapExtender(const Graph& graph)
    60     MapExtender(const GraphType& graph)
    62       : Parent(graph) {}
    61       : Parent(graph) {}
    63 
    62 
    64     MapExtender(const Graph& graph, const Value& value)
    63     MapExtender(const GraphType& graph, const Value& value)
    65       : Parent(graph, value) {}
    64       : Parent(graph, value) {}
    66 
    65 
    67   private:
    66   private:
    68     MapExtender& operator=(const MapExtender& cmap) {
    67     MapExtender& operator=(const MapExtender& cmap) {
    69       return operator=<MapExtender>(cmap);
    68       return operator=<MapExtender>(cmap);
    75       return *this;
    74       return *this;
    76     }
    75     }
    77 
    76 
    78   public:
    77   public:
    79     class MapIt : public Item {
    78     class MapIt : public Item {
    80     public:
    79       typedef Item Parent;
    81 
    80 
    82       typedef Item Parent;
    81     public:
       
    82 
    83       typedef typename Map::Value Value;
    83       typedef typename Map::Value Value;
    84 
    84 
    85       MapIt() {}
    85       MapIt() {}
    86 
    86 
    87       MapIt(Invalid i) : Parent(i) { }
    87       MapIt(Invalid i) : Parent(i) { }
   114       Map& map;
   114       Map& map;
   115 
   115 
   116     };
   116     };
   117 
   117 
   118     class ConstMapIt : public Item {
   118     class ConstMapIt : public Item {
   119     public:
   119       typedef Item Parent;
   120 
   120 
   121       typedef Item Parent;
   121     public:
   122 
   122 
   123       typedef typename Map::Value Value;
   123       typedef typename Map::Value Value;
   124 
   124 
   125       ConstMapIt() {}
   125       ConstMapIt() {}
   126 
   126 
   145     protected:
   145     protected:
   146       const Map& map;
   146       const Map& map;
   147     };
   147     };
   148 
   148 
   149     class ItemIt : public Item {
   149     class ItemIt : public Item {
   150     public:
   150       typedef Item Parent;
   151 
   151 
   152       typedef Item Parent;
   152     public:
   153 
   153 
   154       ItemIt() {}
   154       ItemIt() {}
   155 
   155 
   156       ItemIt(Invalid i) : Parent(i) { }
   156       ItemIt(Invalid i) : Parent(i) { }
   157 
   157 
   176   // \ingroup graphbits
   176   // \ingroup graphbits
   177   //
   177   //
   178   // \brief Extender for maps which use a subset of the items.
   178   // \brief Extender for maps which use a subset of the items.
   179   template <typename _Graph, typename _Map>
   179   template <typename _Graph, typename _Map>
   180   class SubMapExtender : public _Map {
   180   class SubMapExtender : public _Map {
   181   public:
       
   182 
       
   183     typedef _Map Parent;
   181     typedef _Map Parent;
       
   182     typedef _Graph GraphType;
       
   183 
       
   184   public:
       
   185 
   184     typedef SubMapExtender Map;
   186     typedef SubMapExtender Map;
   185 
       
   186     typedef _Graph Graph;
       
   187 
       
   188     typedef typename Parent::Key Item;
   187     typedef typename Parent::Key Item;
   189 
   188 
   190     typedef typename Parent::Key Key;
   189     typedef typename Parent::Key Key;
   191     typedef typename Parent::Value Value;
   190     typedef typename Parent::Value Value;
   192     typedef typename Parent::Reference Reference;
   191     typedef typename Parent::Reference Reference;
   198     friend class MapIt;
   197     friend class MapIt;
   199     friend class ConstMapIt;
   198     friend class ConstMapIt;
   200 
   199 
   201   public:
   200   public:
   202 
   201 
   203     SubMapExtender(const Graph& _graph)
   202     SubMapExtender(const GraphType& _graph)
   204       : Parent(_graph), graph(_graph) {}
   203       : Parent(_graph), graph(_graph) {}
   205 
   204 
   206     SubMapExtender(const Graph& _graph, const Value& _value)
   205     SubMapExtender(const GraphType& _graph, const Value& _value)
   207       : Parent(_graph, _value), graph(_graph) {}
   206       : Parent(_graph, _value), graph(_graph) {}
   208 
   207 
   209   private:
   208   private:
   210     SubMapExtender& operator=(const SubMapExtender& cmap) {
   209     SubMapExtender& operator=(const SubMapExtender& cmap) {
   211       return operator=<MapExtender>(cmap);
   210       return operator=<MapExtender>(cmap);
   221       return *this;
   220       return *this;
   222     }
   221     }
   223 
   222 
   224   public:
   223   public:
   225     class MapIt : public Item {
   224     class MapIt : public Item {
   226     public:
   225       typedef Item Parent;
   227 
   226 
   228       typedef Item Parent;
   227     public:
   229       typedef typename Map::Value Value;
   228       typedef typename Map::Value Value;
   230 
   229 
   231       MapIt() {}
   230       MapIt() {}
   232 
   231 
   233       MapIt(Invalid i) : Parent(i) { }
   232       MapIt(Invalid i) : Parent(i) { }
   260       Map& map;
   259       Map& map;
   261 
   260 
   262     };
   261     };
   263 
   262 
   264     class ConstMapIt : public Item {
   263     class ConstMapIt : public Item {
   265     public:
   264       typedef Item Parent;
   266 
   265 
   267       typedef Item Parent;
   266     public:
   268 
   267 
   269       typedef typename Map::Value Value;
   268       typedef typename Map::Value Value;
   270 
   269 
   271       ConstMapIt() {}
   270       ConstMapIt() {}
   272 
   271 
   291     protected:
   290     protected:
   292       const Map& map;
   291       const Map& map;
   293     };
   292     };
   294 
   293 
   295     class ItemIt : public Item {
   294     class ItemIt : public Item {
   296     public:
   295       typedef Item Parent;
   297 
   296 
   298       typedef Item Parent;
   297     public:
   299 
   298 
   300       ItemIt() {}
   299       ItemIt() {}
   301 
   300 
   302       ItemIt(Invalid i) : Parent(i) { }
   301       ItemIt(Invalid i) : Parent(i) { }
   303 
   302 
   318 
   317 
   319     };
   318     };
   320 
   319 
   321   private:
   320   private:
   322 
   321 
   323     const Graph& graph;
   322     const GraphType& graph;
   324 
   323 
   325   };
   324   };
   326 
   325 
   327 }
   326 }
   328 
   327