COIN-OR::LEMON - Graph Library

Changeset 867:994c7df296c9 in lemon for lemon/bits


Ignore:
Timestamp:
12/10/09 17:05:35 (14 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Children:
868:76689f2fc02d, 869:1b89e29c9fc7, 900:5100072d83ca
Parents:
865:e9c203fb003d (diff), 765:703ebf476a1d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge

Location:
lemon/bits
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/map_extender.h

    r765 r867  
    8585      typedef typename Map::Value Value;
    8686
    87       MapIt() {}
    88 
    89       MapIt(Invalid i) : Parent(i) { }
    90 
    91       explicit MapIt(Map& _map) : map(_map) {
    92         map.notifier()->first(*this);
     87      MapIt() : map(NULL) {}
     88
     89      MapIt(Invalid i) : Parent(i), map(NULL) {}
     90
     91      explicit MapIt(Map& _map) : map(&_map) {
     92        map->notifier()->first(*this);
    9393      }
    9494
    9595      MapIt(const Map& _map, const Item& item)
     96        : Parent(item), map(&_map) {}
     97
     98      MapIt& operator++() {
     99        map->notifier()->next(*this);
     100        return *this;
     101      }
     102
     103      typename MapTraits<Map>::ConstReturnValue operator*() const {
     104        return (*map)[*this];
     105      }
     106
     107      typename MapTraits<Map>::ReturnValue operator*() {
     108        return (*map)[*this];
     109      }
     110
     111      void set(const Value& value) {
     112        map->set(*this, value);
     113      }
     114
     115    protected:
     116      Map* map;
     117
     118    };
     119
     120    class ConstMapIt : public Item {
     121      typedef Item Parent;
     122
     123    public:
     124
     125      typedef typename Map::Value Value;
     126
     127      ConstMapIt() : map(NULL) {}
     128
     129      ConstMapIt(Invalid i) : Parent(i), map(NULL) {}
     130
     131      explicit ConstMapIt(Map& _map) : map(&_map) {
     132        map->notifier()->first(*this);
     133      }
     134
     135      ConstMapIt(const Map& _map, const Item& item)
    96136        : Parent(item), map(_map) {}
    97137
    98       MapIt& operator++() {
    99         map.notifier()->next(*this);
     138      ConstMapIt& operator++() {
     139        map->notifier()->next(*this);
    100140        return *this;
    101141      }
     
    105145      }
    106146
    107       typename MapTraits<Map>::ReturnValue operator*() {
    108         return map[*this];
    109       }
    110 
    111       void set(const Value& value) {
    112         map.set(*this, value);
    113       }
    114 
    115     protected:
    116       Map& map;
    117 
    118     };
    119 
    120     class ConstMapIt : public Item {
    121       typedef Item Parent;
    122 
    123     public:
    124 
    125       typedef typename Map::Value Value;
    126 
    127       ConstMapIt() {}
    128 
    129       ConstMapIt(Invalid i) : Parent(i) { }
    130 
    131       explicit ConstMapIt(Map& _map) : map(_map) {
    132         map.notifier()->first(*this);
    133       }
    134 
    135       ConstMapIt(const Map& _map, const Item& item)
    136         : Parent(item), map(_map) {}
    137 
    138       ConstMapIt& operator++() {
    139         map.notifier()->next(*this);
    140         return *this;
    141       }
    142 
    143       typename MapTraits<Map>::ConstReturnValue operator*() const {
    144         return map[*this];
    145       }
    146 
    147     protected:
    148       const Map& map;
     147    protected:
     148      const Map* map;
    149149    };
    150150
     
    153153
    154154    public:
    155 
    156       ItemIt() {}
    157 
    158       ItemIt(Invalid i) : Parent(i) { }
    159 
    160       explicit ItemIt(Map& _map) : map(_map) {
    161         map.notifier()->first(*this);
     155      ItemIt() : map(NULL) {}
     156
     157
     158      ItemIt(Invalid i) : Parent(i), map(NULL) {}
     159
     160      explicit ItemIt(Map& _map) : map(&_map) {
     161        map->notifier()->first(*this);
    162162      }
    163163
    164164      ItemIt(const Map& _map, const Item& item)
    165         : Parent(item), map(_map) {}
     165        : Parent(item), map(&_map) {}
    166166
    167167      ItemIt& operator++() {
    168         map.notifier()->next(*this);
    169         return *this;
    170       }
    171 
    172     protected:
    173       const Map& map;
     168        map->notifier()->next(*this);
     169        return *this;
     170      }
     171
     172    protected:
     173      const Map* map;
    174174
    175175    };
     
    232232      typedef typename Map::Value Value;
    233233
    234       MapIt() {}
    235 
    236       MapIt(Invalid i) : Parent(i) { }
    237 
    238       explicit MapIt(Map& _map) : map(_map) {
    239         map.graph.first(*this);
     234      MapIt() : map(NULL) {}
     235
     236      MapIt(Invalid i) : Parent(i), map(NULL) { }
     237
     238      explicit MapIt(Map& _map) : map(&_map) {
     239        map->graph.first(*this);
    240240      }
    241241
    242242      MapIt(const Map& _map, const Item& item)
    243         : Parent(item), map(_map) {}
     243        : Parent(item), map(&_map) {}
    244244
    245245      MapIt& operator++() {
    246         map.graph.next(*this);
     246        map->graph.next(*this);
    247247        return *this;
    248248      }
    249249
    250250      typename MapTraits<Map>::ConstReturnValue operator*() const {
    251         return map[*this];
     251        return (*map)[*this];
    252252      }
    253253
    254254      typename MapTraits<Map>::ReturnValue operator*() {
    255         return map[*this];
     255        return (*map)[*this];
    256256      }
    257257
    258258      void set(const Value& value) {
    259         map.set(*this, value);
    260       }
    261 
    262     protected:
    263       Map& map;
     259        map->set(*this, value);
     260      }
     261
     262    protected:
     263      Map* map;
    264264
    265265    };
     
    272272      typedef typename Map::Value Value;
    273273
    274       ConstMapIt() {}
    275 
    276       ConstMapIt(Invalid i) : Parent(i) { }
    277 
    278       explicit ConstMapIt(Map& _map) : map(_map) {
    279         map.graph.first(*this);
     274      ConstMapIt() : map(NULL) {}
     275
     276      ConstMapIt(Invalid i) : Parent(i), map(NULL) { }
     277
     278      explicit ConstMapIt(Map& _map) : map(&_map) {
     279        map->graph.first(*this);
    280280      }
    281281
    282282      ConstMapIt(const Map& _map, const Item& item)
    283         : Parent(item), map(_map) {}
     283        : Parent(item), map(&_map) {}
    284284
    285285      ConstMapIt& operator++() {
    286         map.graph.next(*this);
     286        map->graph.next(*this);
    287287        return *this;
    288288      }
    289289
    290290      typename MapTraits<Map>::ConstReturnValue operator*() const {
    291         return map[*this];
    292       }
    293 
    294     protected:
    295       const Map& map;
     291        return (*map)[*this];
     292      }
     293
     294    protected:
     295      const Map* map;
    296296    };
    297297
     
    300300
    301301    public:
    302 
    303       ItemIt() {}
    304 
    305       ItemIt(Invalid i) : Parent(i) { }
    306 
    307       explicit ItemIt(Map& _map) : map(_map) {
    308         map.graph.first(*this);
     302      ItemIt() : map(NULL) {}
     303
     304
     305      ItemIt(Invalid i) : Parent(i), map(NULL) { }
     306
     307      explicit ItemIt(Map& _map) : map(&_map) {
     308        map->graph.first(*this);
    309309      }
    310310
    311311      ItemIt(const Map& _map, const Item& item)
    312         : Parent(item), map(_map) {}
     312        : Parent(item), map(&_map) {}
    313313
    314314      ItemIt& operator++() {
    315         map.graph.next(*this);
    316         return *this;
    317       }
    318 
    319     protected:
    320       const Map& map;
     315        map->graph.next(*this);
     316        return *this;
     317      }
     318
     319    protected:
     320      const Map* map;
    321321
    322322    };
  • lemon/bits/map_extender.h

    r865 r867  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2008
     5 * Copyright (C) 2003-2009
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    3737  template <typename _Map>
    3838  class MapExtender : public _Map {
    39   public:
    40 
    4139    typedef _Map Parent;
     40    typedef typename Parent::GraphType GraphType;
     41
     42  public:
     43
    4244    typedef MapExtender Map;
    43 
    44 
    45     typedef typename Parent::Graph Graph;
    4645    typedef typename Parent::Key Item;
    4746
    4847    typedef typename Parent::Key Key;
    4948    typedef typename Parent::Value Value;
     49    typedef typename Parent::Reference Reference;
     50    typedef typename Parent::ConstReference ConstReference;
     51
     52    typedef typename Parent::ReferenceMapTag ReferenceMapTag;
    5053
    5154    class MapIt;
     
    5760  public:
    5861
    59     MapExtender(const Graph& graph)
     62    MapExtender(const GraphType& graph)
    6063      : Parent(graph) {}
    6164
    62     MapExtender(const Graph& graph, const Value& value)
     65    MapExtender(const GraphType& graph, const Value& value)
    6366      : Parent(graph, value) {}
    6467
     
    7679  public:
    7780    class MapIt : public Item {
    78     public:
    79 
    80       typedef Item Parent;
     81      typedef Item Parent;
     82
     83    public:
     84
    8185      typedef typename Map::Value Value;
    8286
     
    115119
    116120    class ConstMapIt : public Item {
    117     public:
    118 
    119       typedef Item Parent;
     121      typedef Item Parent;
     122
     123    public:
    120124
    121125      typedef typename Map::Value Value;
     
    146150
    147151    class ItemIt : public Item {
    148     public:
    149 
    150       typedef Item Parent;
    151 
     152      typedef Item Parent;
     153
     154    public:
    152155      ItemIt() : map(NULL) {}
     156
    153157
    154158      ItemIt(Invalid i) : Parent(i), map(NULL) {}
     
    177181  template <typename _Graph, typename _Map>
    178182  class SubMapExtender : public _Map {
    179   public:
    180 
    181183    typedef _Map Parent;
     184    typedef _Graph GraphType;
     185
     186  public:
     187
    182188    typedef SubMapExtender Map;
    183 
    184     typedef _Graph Graph;
    185 
    186189    typedef typename Parent::Key Item;
    187190
    188191    typedef typename Parent::Key Key;
    189192    typedef typename Parent::Value Value;
     193    typedef typename Parent::Reference Reference;
     194    typedef typename Parent::ConstReference ConstReference;
     195
     196    typedef typename Parent::ReferenceMapTag ReferenceMapTag;
    190197
    191198    class MapIt;
     
    197204  public:
    198205
    199     SubMapExtender(const Graph& _graph)
     206    SubMapExtender(const GraphType& _graph)
    200207      : Parent(_graph), graph(_graph) {}
    201208
    202     SubMapExtender(const Graph& _graph, const Value& _value)
     209    SubMapExtender(const GraphType& _graph, const Value& _value)
    203210      : Parent(_graph, _value), graph(_graph) {}
    204211
     
    220227  public:
    221228    class MapIt : public Item {
    222     public:
    223 
    224       typedef Item Parent;
     229      typedef Item Parent;
     230
     231    public:
    225232      typedef typename Map::Value Value;
    226233
     
    259266
    260267    class ConstMapIt : public Item {
    261     public:
    262 
    263       typedef Item Parent;
     268      typedef Item Parent;
     269
     270    public:
    264271
    265272      typedef typename Map::Value Value;
     
    290297
    291298    class ItemIt : public Item {
    292     public:
    293 
    294       typedef Item Parent;
    295 
     299      typedef Item Parent;
     300
     301    public:
    296302      ItemIt() : map(NULL) {}
     303
    297304
    298305      ItemIt(Invalid i) : Parent(i), map(NULL) { }
     
    317324  private:
    318325
    319     const Graph& graph;
     326    const GraphType& graph;
    320327
    321328  };
Note: See TracChangeset for help on using the changeset viewer.