1.1 --- a/lemon/bits/map_extender.h Mon Mar 14 08:56:54 2011 +0100
1.2 +++ b/lemon/bits/map_extender.h Fri Apr 15 09:26:09 2011 +0200
1.3 @@ -49,6 +49,8 @@
1.4 typedef typename Parent::Reference Reference;
1.5 typedef typename Parent::ConstReference ConstReference;
1.6
1.7 + typedef typename Parent::ReferenceMapTag ReferenceMapTag;
1.8 +
1.9 class MapIt;
1.10 class ConstMapIt;
1.11
1.12 @@ -82,36 +84,36 @@
1.13
1.14 typedef typename Map::Value Value;
1.15
1.16 - MapIt() {}
1.17 + MapIt() : map(NULL) {}
1.18
1.19 - MapIt(Invalid i) : Parent(i) { }
1.20 + MapIt(Invalid i) : Parent(i), map(NULL) {}
1.21
1.22 - explicit MapIt(Map& _map) : map(_map) {
1.23 - map.notifier()->first(*this);
1.24 + explicit MapIt(Map& _map) : map(&_map) {
1.25 + map->notifier()->first(*this);
1.26 }
1.27
1.28 MapIt(const Map& _map, const Item& item)
1.29 - : Parent(item), map(_map) {}
1.30 + : Parent(item), map(&_map) {}
1.31
1.32 MapIt& operator++() {
1.33 - map.notifier()->next(*this);
1.34 + map->notifier()->next(*this);
1.35 return *this;
1.36 }
1.37
1.38 typename MapTraits<Map>::ConstReturnValue operator*() const {
1.39 - return map[*this];
1.40 + return (*map)[*this];
1.41 }
1.42
1.43 typename MapTraits<Map>::ReturnValue operator*() {
1.44 - return map[*this];
1.45 + return (*map)[*this];
1.46 }
1.47
1.48 void set(const Value& value) {
1.49 - map.set(*this, value);
1.50 + map->set(*this, value);
1.51 }
1.52
1.53 protected:
1.54 - Map& map;
1.55 + Map* map;
1.56
1.57 };
1.58
1.59 @@ -122,19 +124,19 @@
1.60
1.61 typedef typename Map::Value Value;
1.62
1.63 - ConstMapIt() {}
1.64 + ConstMapIt() : map(NULL) {}
1.65
1.66 - ConstMapIt(Invalid i) : Parent(i) { }
1.67 + ConstMapIt(Invalid i) : Parent(i), map(NULL) {}
1.68
1.69 - explicit ConstMapIt(Map& _map) : map(_map) {
1.70 - map.notifier()->first(*this);
1.71 + explicit ConstMapIt(Map& _map) : map(&_map) {
1.72 + map->notifier()->first(*this);
1.73 }
1.74
1.75 ConstMapIt(const Map& _map, const Item& item)
1.76 : Parent(item), map(_map) {}
1.77
1.78 ConstMapIt& operator++() {
1.79 - map.notifier()->next(*this);
1.80 + map->notifier()->next(*this);
1.81 return *this;
1.82 }
1.83
1.84 @@ -143,32 +145,32 @@
1.85 }
1.86
1.87 protected:
1.88 - const Map& map;
1.89 + const Map* map;
1.90 };
1.91
1.92 class ItemIt : public Item {
1.93 typedef Item Parent;
1.94
1.95 public:
1.96 + ItemIt() : map(NULL) {}
1.97
1.98 - ItemIt() {}
1.99
1.100 - ItemIt(Invalid i) : Parent(i) { }
1.101 + ItemIt(Invalid i) : Parent(i), map(NULL) {}
1.102
1.103 - explicit ItemIt(Map& _map) : map(_map) {
1.104 - map.notifier()->first(*this);
1.105 + explicit ItemIt(Map& _map) : map(&_map) {
1.106 + map->notifier()->first(*this);
1.107 }
1.108
1.109 ItemIt(const Map& _map, const Item& item)
1.110 - : Parent(item), map(_map) {}
1.111 + : Parent(item), map(&_map) {}
1.112
1.113 ItemIt& operator++() {
1.114 - map.notifier()->next(*this);
1.115 + map->notifier()->next(*this);
1.116 return *this;
1.117 }
1.118
1.119 protected:
1.120 - const Map& map;
1.121 + const Map* map;
1.122
1.123 };
1.124 };
1.125 @@ -191,6 +193,8 @@
1.126 typedef typename Parent::Reference Reference;
1.127 typedef typename Parent::ConstReference ConstReference;
1.128
1.129 + typedef typename Parent::ReferenceMapTag ReferenceMapTag;
1.130 +
1.131 class MapIt;
1.132 class ConstMapIt;
1.133
1.134 @@ -227,36 +231,36 @@
1.135 public:
1.136 typedef typename Map::Value Value;
1.137
1.138 - MapIt() {}
1.139 + MapIt() : map(NULL) {}
1.140
1.141 - MapIt(Invalid i) : Parent(i) { }
1.142 + MapIt(Invalid i) : Parent(i), map(NULL) { }
1.143
1.144 - explicit MapIt(Map& _map) : map(_map) {
1.145 - map.graph.first(*this);
1.146 + explicit MapIt(Map& _map) : map(&_map) {
1.147 + map->graph.first(*this);
1.148 }
1.149
1.150 MapIt(const Map& _map, const Item& item)
1.151 - : Parent(item), map(_map) {}
1.152 + : Parent(item), map(&_map) {}
1.153
1.154 MapIt& operator++() {
1.155 - map.graph.next(*this);
1.156 + map->graph.next(*this);
1.157 return *this;
1.158 }
1.159
1.160 typename MapTraits<Map>::ConstReturnValue operator*() const {
1.161 - return map[*this];
1.162 + return (*map)[*this];
1.163 }
1.164
1.165 typename MapTraits<Map>::ReturnValue operator*() {
1.166 - return map[*this];
1.167 + return (*map)[*this];
1.168 }
1.169
1.170 void set(const Value& value) {
1.171 - map.set(*this, value);
1.172 + map->set(*this, value);
1.173 }
1.174
1.175 protected:
1.176 - Map& map;
1.177 + Map* map;
1.178
1.179 };
1.180
1.181 @@ -267,53 +271,53 @@
1.182
1.183 typedef typename Map::Value Value;
1.184
1.185 - ConstMapIt() {}
1.186 + ConstMapIt() : map(NULL) {}
1.187
1.188 - ConstMapIt(Invalid i) : Parent(i) { }
1.189 + ConstMapIt(Invalid i) : Parent(i), map(NULL) { }
1.190
1.191 - explicit ConstMapIt(Map& _map) : map(_map) {
1.192 - map.graph.first(*this);
1.193 + explicit ConstMapIt(Map& _map) : map(&_map) {
1.194 + map->graph.first(*this);
1.195 }
1.196
1.197 ConstMapIt(const Map& _map, const Item& item)
1.198 - : Parent(item), map(_map) {}
1.199 + : Parent(item), map(&_map) {}
1.200
1.201 ConstMapIt& operator++() {
1.202 - map.graph.next(*this);
1.203 + map->graph.next(*this);
1.204 return *this;
1.205 }
1.206
1.207 typename MapTraits<Map>::ConstReturnValue operator*() const {
1.208 - return map[*this];
1.209 + return (*map)[*this];
1.210 }
1.211
1.212 protected:
1.213 - const Map& map;
1.214 + const Map* map;
1.215 };
1.216
1.217 class ItemIt : public Item {
1.218 typedef Item Parent;
1.219
1.220 public:
1.221 + ItemIt() : map(NULL) {}
1.222
1.223 - ItemIt() {}
1.224
1.225 - ItemIt(Invalid i) : Parent(i) { }
1.226 + ItemIt(Invalid i) : Parent(i), map(NULL) { }
1.227
1.228 - explicit ItemIt(Map& _map) : map(_map) {
1.229 - map.graph.first(*this);
1.230 + explicit ItemIt(Map& _map) : map(&_map) {
1.231 + map->graph.first(*this);
1.232 }
1.233
1.234 ItemIt(const Map& _map, const Item& item)
1.235 - : Parent(item), map(_map) {}
1.236 + : Parent(item), map(&_map) {}
1.237
1.238 ItemIt& operator++() {
1.239 - map.graph.next(*this);
1.240 + map->graph.next(*this);
1.241 return *this;
1.242 }
1.243
1.244 protected:
1.245 - const Map& map;
1.246 + const Map* map;
1.247
1.248 };
1.249