COIN-OR::LEMON - Graph Library

Changeset 406:e9c203fb003d in lemon-1.0 for lemon


Ignore:
Timestamp:
11/13/09 12:33:33 (14 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Children:
407:2e9655402778, 409:f58e01094738
Phase:
public
Message:

Bug fix in map_extender.h (#330)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/map_extender.h

    r318 r406  
    8181      typedef typename Map::Value Value;
    8282
    83       MapIt() {}
    84 
    85       MapIt(Invalid i) : Parent(i) { }
    86 
    87       explicit MapIt(Map& _map) : map(_map) {
    88         map.notifier()->first(*this);
     83      MapIt() : map(NULL) {}
     84
     85      MapIt(Invalid i) : Parent(i), map(NULL) {}
     86
     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) {}
     93
     94      MapIt& operator++() {
     95        map->notifier()->next(*this);
     96        return *this;
     97      }
     98
     99      typename MapTraits<Map>::ConstReturnValue operator*() const {
     100        return (*map)[*this];
     101      }
     102
     103      typename MapTraits<Map>::ReturnValue operator*() {
     104        return (*map)[*this];
     105      }
     106
     107      void set(const Value& value) {
     108        map->set(*this, value);
     109      }
     110
     111    protected:
     112      Map* map;
     113
     114    };
     115
     116    class ConstMapIt : public Item {
     117    public:
     118
     119      typedef Item Parent;
     120
     121      typedef typename Map::Value Value;
     122
     123      ConstMapIt() : map(NULL) {}
     124
     125      ConstMapIt(Invalid i) : Parent(i), map(NULL) {}
     126
     127      explicit ConstMapIt(Map& _map) : map(&_map) {
     128        map->notifier()->first(*this);
     129      }
     130
     131      ConstMapIt(const Map& _map, const Item& item)
    92132        : Parent(item), map(_map) {}
    93133
    94       MapIt& operator++() {
    95         map.notifier()->next(*this);
     134      ConstMapIt& operator++() {
     135        map->notifier()->next(*this);
    96136        return *this;
    97137      }
     
    101141      }
    102142
    103       typename MapTraits<Map>::ReturnValue operator*() {
    104         return map[*this];
    105       }
    106 
    107       void set(const Value& value) {
    108         map.set(*this, value);
    109       }
    110 
    111     protected:
    112       Map& map;
    113 
    114     };
    115 
    116     class ConstMapIt : public Item {
    117     public:
    118 
    119       typedef Item Parent;
    120 
    121       typedef typename Map::Value Value;
    122 
    123       ConstMapIt() {}
    124 
    125       ConstMapIt(Invalid i) : Parent(i) { }
    126 
    127       explicit ConstMapIt(Map& _map) : map(_map) {
    128         map.notifier()->first(*this);
    129       }
    130 
    131       ConstMapIt(const Map& _map, const Item& item)
    132         : Parent(item), map(_map) {}
    133 
    134       ConstMapIt& operator++() {
    135         map.notifier()->next(*this);
    136         return *this;
    137       }
    138 
    139       typename MapTraits<Map>::ConstReturnValue operator*() const {
    140         return map[*this];
    141       }
    142 
    143     protected:
    144       const Map& map;
     143    protected:
     144      const Map* map;
    145145    };
    146146
     
    150150      typedef Item Parent;
    151151
    152       ItemIt() {}
    153 
    154       ItemIt(Invalid i) : Parent(i) { }
    155 
    156       explicit ItemIt(Map& _map) : map(_map) {
    157         map.notifier()->first(*this);
     152      ItemIt() : map(NULL) {}
     153
     154      ItemIt(Invalid i) : Parent(i), map(NULL) {}
     155
     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);
    165         return *this;
    166       }
    167 
    168     protected:
    169       const Map& map;
     164        map->notifier()->next(*this);
     165        return *this;
     166      }
     167
     168    protected:
     169      const Map* map;
    170170
    171171    };
     
    225225      typedef typename Map::Value Value;
    226226
    227       MapIt() {}
    228 
    229       MapIt(Invalid i) : Parent(i) { }
    230 
    231       explicit MapIt(Map& _map) : map(_map) {
    232         map.graph.first(*this);
     227      MapIt() : map(NULL) {}
     228
     229      MapIt(Invalid i) : Parent(i), map(NULL) { }
     230
     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);
    253       }
    254 
    255     protected:
    256       Map& map;
     252        map->set(*this, value);
     253      }
     254
     255    protected:
     256      Map* map;
    257257
    258258    };
     
    265265      typedef typename Map::Value Value;
    266266
    267       ConstMapIt() {}
    268 
    269       ConstMapIt(Invalid i) : Parent(i) { }
    270 
    271       explicit ConstMapIt(Map& _map) : map(_map) {
    272         map.graph.first(*this);
     267      ConstMapIt() : map(NULL) {}
     268
     269      ConstMapIt(Invalid i) : Parent(i), map(NULL) { }
     270
     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];
    285       }
    286 
    287     protected:
    288       const Map& map;
     284        return (*map)[*this];
     285      }
     286
     287    protected:
     288      const Map* map;
    289289    };
    290290
     
    294294      typedef Item Parent;
    295295
    296       ItemIt() {}
    297 
    298       ItemIt(Invalid i) : Parent(i) { }
    299 
    300       explicit ItemIt(Map& _map) : map(_map) {
    301         map.graph.first(*this);
     296      ItemIt() : map(NULL) {}
     297
     298      ItemIt(Invalid i) : Parent(i), map(NULL) { }
     299
     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);
    309         return *this;
    310       }
    311 
    312     protected:
    313       const Map& map;
     308        map->graph.next(*this);
     309        return *this;
     310      }
     311
     312    protected:
     313      const Map* map;
    314314
    315315    };
Note: See TracChangeset for help on using the changeset viewer.