COIN-OR::LEMON - Graph Library

Ticket #330: 330-bugfix-e9c203fb003d.patch

File 330-bugfix-e9c203fb003d.patch, 5.6 KB (added by Peter Kovacs, 14 years ago)
  • lemon/bits/map_extender.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1258112013 -3600
    # Node ID e9c203fb003d6d603fedbfe94a10ec308645e8ea
    # Parent  c6acc34f98dc634b544e62802b9adc8b014bc7f7
    Bug fix in map_extender.h (#330)
    
    diff --git a/lemon/bits/map_extender.h b/lemon/bits/map_extender.h
    a b  
    8080      typedef Item Parent;
    8181      typedef typename Map::Value Value;
    8282
    83       MapIt() {}
     83      MapIt() : map(NULL) {}
    8484
    85       MapIt(Invalid i) : Parent(i) { }
     85      MapIt(Invalid i) : Parent(i), map(NULL) {}
    8686
    87       explicit MapIt(Map& _map) : map(_map) {
    88         map.notifier()->first(*this);
     87      explicit MapIt(Map& _map) : map(&_map) {
     88        map->notifier()->first(*this);
    8989      }
    9090
    9191      MapIt(const Map& _map, const Item& item)
    92         : Parent(item), map(_map) {}
     92        : Parent(item), map(&_map) {}
    9393
    9494      MapIt& operator++() {
    95         map.notifier()->next(*this);
     95        map->notifier()->next(*this);
    9696        return *this;
    9797      }
    9898
    9999      typename MapTraits<Map>::ConstReturnValue operator*() const {
    100         return map[*this];
     100        return (*map)[*this];
    101101      }
    102102
    103103      typename MapTraits<Map>::ReturnValue operator*() {
    104         return map[*this];
     104        return (*map)[*this];
    105105      }
    106106
    107107      void set(const Value& value) {
    108         map.set(*this, value);
     108        map->set(*this, value);
    109109      }
    110110
    111111    protected:
    112       Map& map;
     112      Map* map;
    113113
    114114    };
    115115
     
    120120
    121121      typedef typename Map::Value Value;
    122122
    123       ConstMapIt() {}
     123      ConstMapIt() : map(NULL) {}
    124124
    125       ConstMapIt(Invalid i) : Parent(i) { }
     125      ConstMapIt(Invalid i) : Parent(i), map(NULL) {}
    126126
    127       explicit ConstMapIt(Map& _map) : map(_map) {
    128         map.notifier()->first(*this);
     127      explicit ConstMapIt(Map& _map) : map(&_map) {
     128        map->notifier()->first(*this);
    129129      }
    130130
    131131      ConstMapIt(const Map& _map, const Item& item)
    132132        : Parent(item), map(_map) {}
    133133
    134134      ConstMapIt& operator++() {
    135         map.notifier()->next(*this);
     135        map->notifier()->next(*this);
    136136        return *this;
    137137      }
    138138
     
    141141      }
    142142
    143143    protected:
    144       const Map& map;
     144      const Map* map;
    145145    };
    146146
    147147    class ItemIt : public Item {
     
    149149
    150150      typedef Item Parent;
    151151
    152       ItemIt() {}
     152      ItemIt() : map(NULL) {}
    153153
    154       ItemIt(Invalid i) : Parent(i) { }
     154      ItemIt(Invalid i) : Parent(i), map(NULL) {}
    155155
    156       explicit ItemIt(Map& _map) : map(_map) {
    157         map.notifier()->first(*this);
     156      explicit ItemIt(Map& _map) : map(&_map) {
     157        map->notifier()->first(*this);
    158158      }
    159159
    160160      ItemIt(const Map& _map, const Item& item)
    161         : Parent(item), map(_map) {}
     161        : Parent(item), map(&_map) {}
    162162
    163163      ItemIt& operator++() {
    164         map.notifier()->next(*this);
     164        map->notifier()->next(*this);
    165165        return *this;
    166166      }
    167167
    168168    protected:
    169       const Map& map;
     169      const Map* map;
    170170
    171171    };
    172172  };
     
    224224      typedef Item Parent;
    225225      typedef typename Map::Value Value;
    226226
    227       MapIt() {}
     227      MapIt() : map(NULL) {}
    228228
    229       MapIt(Invalid i) : Parent(i) { }
     229      MapIt(Invalid i) : Parent(i), map(NULL) { }
    230230
    231       explicit MapIt(Map& _map) : map(_map) {
    232         map.graph.first(*this);
     231      explicit MapIt(Map& _map) : map(&_map) {
     232        map->graph.first(*this);
    233233      }
    234234
    235235      MapIt(const Map& _map, const Item& item)
    236         : Parent(item), map(_map) {}
     236        : Parent(item), map(&_map) {}
    237237
    238238      MapIt& operator++() {
    239         map.graph.next(*this);
     239        map->graph.next(*this);
    240240        return *this;
    241241      }
    242242
    243243      typename MapTraits<Map>::ConstReturnValue operator*() const {
    244         return map[*this];
     244        return (*map)[*this];
    245245      }
    246246
    247247      typename MapTraits<Map>::ReturnValue operator*() {
    248         return map[*this];
     248        return (*map)[*this];
    249249      }
    250250
    251251      void set(const Value& value) {
    252         map.set(*this, value);
     252        map->set(*this, value);
    253253      }
    254254
    255255    protected:
    256       Map& map;
     256      Map* map;
    257257
    258258    };
    259259
     
    264264
    265265      typedef typename Map::Value Value;
    266266
    267       ConstMapIt() {}
     267      ConstMapIt() : map(NULL) {}
    268268
    269       ConstMapIt(Invalid i) : Parent(i) { }
     269      ConstMapIt(Invalid i) : Parent(i), map(NULL) { }
    270270
    271       explicit ConstMapIt(Map& _map) : map(_map) {
    272         map.graph.first(*this);
     271      explicit ConstMapIt(Map& _map) : map(&_map) {
     272        map->graph.first(*this);
    273273      }
    274274
    275275      ConstMapIt(const Map& _map, const Item& item)
    276         : Parent(item), map(_map) {}
     276        : Parent(item), map(&_map) {}
    277277
    278278      ConstMapIt& operator++() {
    279         map.graph.next(*this);
     279        map->graph.next(*this);
    280280        return *this;
    281281      }
    282282
    283283      typename MapTraits<Map>::ConstReturnValue operator*() const {
    284         return map[*this];
     284        return (*map)[*this];
    285285      }
    286286
    287287    protected:
    288       const Map& map;
     288      const Map* map;
    289289    };
    290290
    291291    class ItemIt : public Item {
     
    293293
    294294      typedef Item Parent;
    295295
    296       ItemIt() {}
     296      ItemIt() : map(NULL) {}
    297297
    298       ItemIt(Invalid i) : Parent(i) { }
     298      ItemIt(Invalid i) : Parent(i), map(NULL) { }
    299299
    300       explicit ItemIt(Map& _map) : map(_map) {
    301         map.graph.first(*this);
     300      explicit ItemIt(Map& _map) : map(&_map) {
     301        map->graph.first(*this);
    302302      }
    303303
    304304      ItemIt(const Map& _map, const Item& item)
    305         : Parent(item), map(_map) {}
     305        : Parent(item), map(&_map) {}
    306306
    307307      ItemIt& operator++() {
    308         map.graph.next(*this);
     308        map->graph.next(*this);
    309309        return *this;
    310310      }
    311311
    312312    protected:
    313       const Map& map;
     313      const Map* map;
    314314
    315315    };
    316316