1 /* -*- mode: C++; indent-tabs-mode: nil; -*- |
1 /* -*- mode: C++; indent-tabs-mode: nil; -*- |
2 * |
2 * |
3 * This file is a part of LEMON, a generic C++ optimization library. |
3 * This file is a part of LEMON, a generic C++ optimization library. |
4 * |
4 * |
5 * Copyright (C) 2003-2008 |
5 * Copyright (C) 2003-2009 |
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 * (Egervary Research Group on Combinatorial Optimization, EGRES). |
7 * (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 * |
8 * |
9 * Permission to use, modify and distribute this software is granted |
9 * Permission to use, modify and distribute this software is granted |
10 * provided that this copyright notice appears in all copies. For |
10 * provided that this copyright notice appears in all copies. For |
34 // \ingroup graphbits |
34 // \ingroup graphbits |
35 // |
35 // |
36 // \brief Extender for maps |
36 // \brief Extender for maps |
37 template <typename _Map> |
37 template <typename _Map> |
38 class MapExtender : public _Map { |
38 class MapExtender : public _Map { |
39 public: |
|
40 |
|
41 typedef _Map Parent; |
39 typedef _Map Parent; |
|
40 typedef typename Parent::GraphType GraphType; |
|
41 |
|
42 public: |
|
43 |
42 typedef MapExtender Map; |
44 typedef MapExtender Map; |
43 |
|
44 |
|
45 typedef typename Parent::Graph Graph; |
|
46 typedef typename Parent::Key Item; |
45 typedef typename Parent::Key Item; |
47 |
46 |
48 typedef typename Parent::Key Key; |
47 typedef typename Parent::Key Key; |
49 typedef typename Parent::Value Value; |
48 typedef typename Parent::Value Value; |
|
49 typedef typename Parent::Reference Reference; |
|
50 typedef typename Parent::ConstReference ConstReference; |
|
51 |
|
52 typedef typename Parent::ReferenceMapTag ReferenceMapTag; |
50 |
53 |
51 class MapIt; |
54 class MapIt; |
52 class ConstMapIt; |
55 class ConstMapIt; |
53 |
56 |
54 friend class MapIt; |
57 friend class MapIt; |
55 friend class ConstMapIt; |
58 friend class ConstMapIt; |
56 |
59 |
57 public: |
60 public: |
58 |
61 |
59 MapExtender(const Graph& graph) |
62 MapExtender(const GraphType& graph) |
60 : Parent(graph) {} |
63 : Parent(graph) {} |
61 |
64 |
62 MapExtender(const Graph& graph, const Value& value) |
65 MapExtender(const GraphType& graph, const Value& value) |
63 : Parent(graph, value) {} |
66 : Parent(graph, value) {} |
64 |
67 |
65 private: |
68 private: |
66 MapExtender& operator=(const MapExtender& cmap) { |
69 MapExtender& operator=(const MapExtender& cmap) { |
67 return operator=<MapExtender>(cmap); |
70 return operator=<MapExtender>(cmap); |
143 protected: |
147 protected: |
144 const Map* map; |
148 const Map* map; |
145 }; |
149 }; |
146 |
150 |
147 class ItemIt : public Item { |
151 class ItemIt : public Item { |
148 public: |
152 typedef Item Parent; |
149 |
153 |
150 typedef Item Parent; |
154 public: |
151 |
|
152 ItemIt() : map(NULL) {} |
155 ItemIt() : map(NULL) {} |
|
156 |
153 |
157 |
154 ItemIt(Invalid i) : Parent(i), map(NULL) {} |
158 ItemIt(Invalid i) : Parent(i), map(NULL) {} |
155 |
159 |
156 explicit ItemIt(Map& _map) : map(&_map) { |
160 explicit ItemIt(Map& _map) : map(&_map) { |
157 map->notifier()->first(*this); |
161 map->notifier()->first(*this); |
174 // \ingroup graphbits |
178 // \ingroup graphbits |
175 // |
179 // |
176 // \brief Extender for maps which use a subset of the items. |
180 // \brief Extender for maps which use a subset of the items. |
177 template <typename _Graph, typename _Map> |
181 template <typename _Graph, typename _Map> |
178 class SubMapExtender : public _Map { |
182 class SubMapExtender : public _Map { |
179 public: |
|
180 |
|
181 typedef _Map Parent; |
183 typedef _Map Parent; |
|
184 typedef _Graph GraphType; |
|
185 |
|
186 public: |
|
187 |
182 typedef SubMapExtender Map; |
188 typedef SubMapExtender Map; |
183 |
|
184 typedef _Graph Graph; |
|
185 |
|
186 typedef typename Parent::Key Item; |
189 typedef typename Parent::Key Item; |
187 |
190 |
188 typedef typename Parent::Key Key; |
191 typedef typename Parent::Key Key; |
189 typedef typename Parent::Value Value; |
192 typedef typename Parent::Value Value; |
|
193 typedef typename Parent::Reference Reference; |
|
194 typedef typename Parent::ConstReference ConstReference; |
|
195 |
|
196 typedef typename Parent::ReferenceMapTag ReferenceMapTag; |
190 |
197 |
191 class MapIt; |
198 class MapIt; |
192 class ConstMapIt; |
199 class ConstMapIt; |
193 |
200 |
194 friend class MapIt; |
201 friend class MapIt; |
195 friend class ConstMapIt; |
202 friend class ConstMapIt; |
196 |
203 |
197 public: |
204 public: |
198 |
205 |
199 SubMapExtender(const Graph& _graph) |
206 SubMapExtender(const GraphType& _graph) |
200 : Parent(_graph), graph(_graph) {} |
207 : Parent(_graph), graph(_graph) {} |
201 |
208 |
202 SubMapExtender(const Graph& _graph, const Value& _value) |
209 SubMapExtender(const GraphType& _graph, const Value& _value) |
203 : Parent(_graph, _value), graph(_graph) {} |
210 : Parent(_graph, _value), graph(_graph) {} |
204 |
211 |
205 private: |
212 private: |
206 SubMapExtender& operator=(const SubMapExtender& cmap) { |
213 SubMapExtender& operator=(const SubMapExtender& cmap) { |
207 return operator=<MapExtender>(cmap); |
214 return operator=<MapExtender>(cmap); |
287 protected: |
294 protected: |
288 const Map* map; |
295 const Map* map; |
289 }; |
296 }; |
290 |
297 |
291 class ItemIt : public Item { |
298 class ItemIt : public Item { |
292 public: |
299 typedef Item Parent; |
293 |
300 |
294 typedef Item Parent; |
301 public: |
295 |
|
296 ItemIt() : map(NULL) {} |
302 ItemIt() : map(NULL) {} |
|
303 |
297 |
304 |
298 ItemIt(Invalid i) : Parent(i), map(NULL) { } |
305 ItemIt(Invalid i) : Parent(i), map(NULL) { } |
299 |
306 |
300 explicit ItemIt(Map& _map) : map(&_map) { |
307 explicit ItemIt(Map& _map) : map(&_map) { |
301 map->graph.first(*this); |
308 map->graph.first(*this); |