# HG changeset patch # User Peter Kovacs # Date 1258112013 -3600 # Node ID e9c203fb003d6d603fedbfe94a10ec308645e8ea # Parent c6acc34f98dc634b544e62802b9adc8b014bc7f7 Bug fix in map_extender.h (#330) diff -r c6acc34f98dc -r e9c203fb003d lemon/bits/map_extender.h --- a/lemon/bits/map_extender.h Fri Oct 16 10:21:37 2009 +0200 +++ b/lemon/bits/map_extender.h Fri Nov 13 12:33:33 2009 +0100 @@ -80,36 +80,36 @@ typedef Item Parent; typedef typename Map::Value Value; - MapIt() {} + MapIt() : map(NULL) {} - MapIt(Invalid i) : Parent(i) { } + MapIt(Invalid i) : Parent(i), map(NULL) {} - explicit MapIt(Map& _map) : map(_map) { - map.notifier()->first(*this); + explicit MapIt(Map& _map) : map(&_map) { + map->notifier()->first(*this); } MapIt(const Map& _map, const Item& item) - : Parent(item), map(_map) {} + : Parent(item), map(&_map) {} MapIt& operator++() { - map.notifier()->next(*this); + map->notifier()->next(*this); return *this; } typename MapTraits::ConstReturnValue operator*() const { - return map[*this]; + return (*map)[*this]; } typename MapTraits::ReturnValue operator*() { - return map[*this]; + return (*map)[*this]; } void set(const Value& value) { - map.set(*this, value); + map->set(*this, value); } protected: - Map& map; + Map* map; }; @@ -120,19 +120,19 @@ typedef typename Map::Value Value; - ConstMapIt() {} + ConstMapIt() : map(NULL) {} - ConstMapIt(Invalid i) : Parent(i) { } + ConstMapIt(Invalid i) : Parent(i), map(NULL) {} - explicit ConstMapIt(Map& _map) : map(_map) { - map.notifier()->first(*this); + explicit ConstMapIt(Map& _map) : map(&_map) { + map->notifier()->first(*this); } ConstMapIt(const Map& _map, const Item& item) : Parent(item), map(_map) {} ConstMapIt& operator++() { - map.notifier()->next(*this); + map->notifier()->next(*this); return *this; } @@ -141,7 +141,7 @@ } protected: - const Map& map; + const Map* map; }; class ItemIt : public Item { @@ -149,24 +149,24 @@ typedef Item Parent; - ItemIt() {} + ItemIt() : map(NULL) {} - ItemIt(Invalid i) : Parent(i) { } + ItemIt(Invalid i) : Parent(i), map(NULL) {} - explicit ItemIt(Map& _map) : map(_map) { - map.notifier()->first(*this); + explicit ItemIt(Map& _map) : map(&_map) { + map->notifier()->first(*this); } ItemIt(const Map& _map, const Item& item) - : Parent(item), map(_map) {} + : Parent(item), map(&_map) {} ItemIt& operator++() { - map.notifier()->next(*this); + map->notifier()->next(*this); return *this; } protected: - const Map& map; + const Map* map; }; }; @@ -224,36 +224,36 @@ typedef Item Parent; typedef typename Map::Value Value; - MapIt() {} + MapIt() : map(NULL) {} - MapIt(Invalid i) : Parent(i) { } + MapIt(Invalid i) : Parent(i), map(NULL) { } - explicit MapIt(Map& _map) : map(_map) { - map.graph.first(*this); + explicit MapIt(Map& _map) : map(&_map) { + map->graph.first(*this); } MapIt(const Map& _map, const Item& item) - : Parent(item), map(_map) {} + : Parent(item), map(&_map) {} MapIt& operator++() { - map.graph.next(*this); + map->graph.next(*this); return *this; } typename MapTraits::ConstReturnValue operator*() const { - return map[*this]; + return (*map)[*this]; } typename MapTraits::ReturnValue operator*() { - return map[*this]; + return (*map)[*this]; } void set(const Value& value) { - map.set(*this, value); + map->set(*this, value); } protected: - Map& map; + Map* map; }; @@ -264,28 +264,28 @@ typedef typename Map::Value Value; - ConstMapIt() {} + ConstMapIt() : map(NULL) {} - ConstMapIt(Invalid i) : Parent(i) { } + ConstMapIt(Invalid i) : Parent(i), map(NULL) { } - explicit ConstMapIt(Map& _map) : map(_map) { - map.graph.first(*this); + explicit ConstMapIt(Map& _map) : map(&_map) { + map->graph.first(*this); } ConstMapIt(const Map& _map, const Item& item) - : Parent(item), map(_map) {} + : Parent(item), map(&_map) {} ConstMapIt& operator++() { - map.graph.next(*this); + map->graph.next(*this); return *this; } typename MapTraits::ConstReturnValue operator*() const { - return map[*this]; + return (*map)[*this]; } protected: - const Map& map; + const Map* map; }; class ItemIt : public Item { @@ -293,24 +293,24 @@ typedef Item Parent; - ItemIt() {} + ItemIt() : map(NULL) {} - ItemIt(Invalid i) : Parent(i) { } + ItemIt(Invalid i) : Parent(i), map(NULL) { } - explicit ItemIt(Map& _map) : map(_map) { - map.graph.first(*this); + explicit ItemIt(Map& _map) : map(&_map) { + map->graph.first(*this); } ItemIt(const Map& _map, const Item& item) - : Parent(item), map(_map) {} + : Parent(item), map(&_map) {} ItemIt& operator++() { - map.graph.next(*this); + map->graph.next(*this); return *this; } protected: - const Map& map; + const Map* map; };