Changeset 209:765619b7cbb2 in lemon for lemon/bits/map_extender.h
- Timestamp:
- 07/13/08 20:51:02 (16 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bits/map_extender.h
r107 r209 1 /* -*- C++-*-2 * 3 * This file is a part of LEMON, a generic C++ optimization library 1 /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 * 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 5 * Copyright (C) 2003-2008 … … 33 33 34 34 /// \ingroup graphbits 35 /// 35 /// 36 36 /// \brief Extender for maps 37 37 template <typename _Map> … … 57 57 public: 58 58 59 MapExtender(const Graph& graph) 59 MapExtender(const Graph& graph) 60 60 : Parent(graph) {} 61 61 62 MapExtender(const Graph& graph, const Value& value) 62 MapExtender(const Graph& graph, const Value& value) 63 63 : Parent(graph, value) {} 64 64 … … 71 71 Parent::operator=(cmap); 72 72 return *this; 73 } 73 } 74 74 75 75 class MapIt : public Item { 76 76 public: 77 77 78 78 typedef Item Parent; 79 79 typedef typename Map::Value Value; 80 80 81 81 MapIt() {} 82 82 … … 87 87 } 88 88 89 MapIt(const Map& _map, const Item& item) 90 91 92 MapIt& operator++() { 93 94 return *this; 95 } 96 89 MapIt(const Map& _map, const Item& item) 90 : Parent(item), map(_map) {} 91 92 MapIt& operator++() { 93 map.notifier()->next(*this); 94 return *this; 95 } 96 97 97 typename MapTraits<Map>::ConstReturnValue operator*() const { 98 98 return map[*this]; 99 99 } 100 100 101 101 typename MapTraits<Map>::ReturnValue operator*() { 102 103 } 104 102 return map[*this]; 103 } 104 105 105 void set(const Value& value) { 106 107 } 108 106 map.set(*this, value); 107 } 108 109 109 protected: 110 110 Map& map; 111 111 112 112 }; 113 113 … … 118 118 119 119 typedef typename Map::Value Value; 120 120 121 121 ConstMapIt() {} 122 122 … … 127 127 } 128 128 129 ConstMapIt(const Map& _map, const Item& item) 130 131 132 ConstMapIt& operator++() { 133 134 return *this; 129 ConstMapIt(const Map& _map, const Item& item) 130 : Parent(item), map(_map) {} 131 132 ConstMapIt& operator++() { 133 map.notifier()->next(*this); 134 return *this; 135 135 } 136 136 137 137 typename MapTraits<Map>::ConstReturnValue operator*() const { 138 138 return map[*this]; 139 139 } 140 140 … … 145 145 class ItemIt : public Item { 146 146 public: 147 148 typedef Item Parent; 149 147 148 typedef Item Parent; 149 150 150 ItemIt() {} 151 151 … … 156 156 } 157 157 158 ItemIt(const Map& _map, const Item& item) 159 160 161 ItemIt& operator++() { 162 163 return *this; 158 ItemIt(const Map& _map, const Item& item) 159 : Parent(item), map(_map) {} 160 161 ItemIt& operator++() { 162 map.notifier()->next(*this); 163 return *this; 164 164 } 165 165 166 166 protected: 167 167 const Map& map; 168 168 169 169 }; 170 170 }; 171 171 172 172 /// \ingroup graphbits 173 /// 173 /// 174 174 /// \brief Extender for maps which use a subset of the items. 175 175 template <typename _Graph, typename _Map> … … 195 195 public: 196 196 197 SubMapExtender(const Graph& _graph) 197 SubMapExtender(const Graph& _graph) 198 198 : Parent(_graph), graph(_graph) {} 199 199 200 SubMapExtender(const Graph& _graph, const Value& _value) 200 SubMapExtender(const Graph& _graph, const Value& _value) 201 201 : Parent(_graph, _value), graph(_graph) {} 202 202 … … 213 213 } 214 214 return *this; 215 } 215 } 216 216 217 217 class MapIt : public Item { 218 218 public: 219 219 220 220 typedef Item Parent; 221 221 typedef typename Map::Value Value; 222 222 223 223 MapIt() {} 224 224 … … 229 229 } 230 230 231 MapIt(const Map& _map, const Item& item) 232 233 234 MapIt& operator++() { 235 236 return *this; 237 } 238 231 MapIt(const Map& _map, const Item& item) 232 : Parent(item), map(_map) {} 233 234 MapIt& operator++() { 235 map.graph.next(*this); 236 return *this; 237 } 238 239 239 typename MapTraits<Map>::ConstReturnValue operator*() const { 240 240 return map[*this]; 241 241 } 242 242 243 243 typename MapTraits<Map>::ReturnValue operator*() { 244 245 } 246 244 return map[*this]; 245 } 246 247 247 void set(const Value& value) { 248 249 } 250 248 map.set(*this, value); 249 } 250 251 251 protected: 252 252 Map& map; 253 253 254 254 }; 255 255 … … 260 260 261 261 typedef typename Map::Value Value; 262 262 263 263 ConstMapIt() {} 264 264 … … 269 269 } 270 270 271 ConstMapIt(const Map& _map, const Item& item) 272 273 274 ConstMapIt& operator++() { 275 276 return *this; 271 ConstMapIt(const Map& _map, const Item& item) 272 : Parent(item), map(_map) {} 273 274 ConstMapIt& operator++() { 275 map.graph.next(*this); 276 return *this; 277 277 } 278 278 279 279 typename MapTraits<Map>::ConstReturnValue operator*() const { 280 280 return map[*this]; 281 281 } 282 282 … … 287 287 class ItemIt : public Item { 288 288 public: 289 290 typedef Item Parent; 291 289 290 typedef Item Parent; 291 292 292 ItemIt() {} 293 293 … … 298 298 } 299 299 300 ItemIt(const Map& _map, const Item& item) 301 302 303 ItemIt& operator++() { 304 305 return *this; 300 ItemIt(const Map& _map, const Item& item) 301 : Parent(item), map(_map) {} 302 303 ItemIt& operator++() { 304 map.graph.next(*this); 305 return *this; 306 306 } 307 307 308 308 protected: 309 309 const Map& map; 310 311 }; 312 310 311 }; 312 313 313 private: 314 314 315 315 const Graph& graph; 316 316 317 317 }; 318 318
Note: See TracChangeset
for help on using the changeset viewer.