Ticket #224: 765a16dc7c3a.patch
File 765a16dc7c3a.patch, 32.2 KB (added by , 13 years ago) |
---|
-
lemon/adaptors.h
# HG changeset patch # User Balazs Dezso <deba@inf.elte.hu> # Date 1259432084 -3600 # Node ID 765a16dc7c3a8f65344f78b87dad69dd9eeb102d # Parent 9cc6e98c487d3a14fe1db17001f3c4a47350dc80 Static maps for graphs (#224) diff -r 9cc6e98c487d -r 765a16dc7c3a lemon/adaptors.h
a b 114 114 public: 115 115 explicit NodeMap(const Adaptor& adaptor) 116 116 : Parent(*adaptor._digraph) {} 117 NodeMap(const Adaptor& adaptor, const V& value )118 : Parent(*adaptor._digraph, value ) { }117 NodeMap(const Adaptor& adaptor, const V& value, bool dynamic = true) 118 : Parent(*adaptor._digraph, value, dynamic) { } 119 119 120 120 private: 121 121 NodeMap& operator=(const NodeMap& cmap) { … … 137 137 public: 138 138 explicit ArcMap(const DigraphAdaptorBase<DGR>& adaptor) 139 139 : Parent(*adaptor._digraph) {} 140 ArcMap(const DigraphAdaptorBase<DGR>& adaptor, const V& value) 141 : Parent(*adaptor._digraph, value) {} 140 ArcMap(const DigraphAdaptorBase<DGR>& adaptor, const V& value, 141 bool dynamic = true) 142 : Parent(*adaptor._digraph, value, dynamic) {} 142 143 143 144 private: 144 145 ArcMap& operator=(const ArcMap& cmap) { … … 256 257 public: 257 258 explicit NodeMap(const GraphAdaptorBase<GR>& adapter) 258 259 : Parent(*adapter._graph) {} 259 NodeMap(const GraphAdaptorBase<GR>& adapter, const V& value) 260 : Parent(*adapter._graph, value) {} 260 NodeMap(const GraphAdaptorBase<GR>& adapter, const V& value, 261 bool dynamic = true) 262 : Parent(*adapter._graph, value, dynamic) {} 261 263 262 264 private: 263 265 NodeMap& operator=(const NodeMap& cmap) { … … 279 281 public: 280 282 explicit ArcMap(const GraphAdaptorBase<GR>& adapter) 281 283 : Parent(*adapter._graph) {} 282 ArcMap(const GraphAdaptorBase<GR>& adapter, const V& value) 283 : Parent(*adapter._graph, value) {} 284 ArcMap(const GraphAdaptorBase<GR>& adapter, const V& value, 285 bool dynamic = true) 286 : Parent(*adapter._graph, value, dynamic) {} 284 287 285 288 private: 286 289 ArcMap& operator=(const ArcMap& cmap) { … … 301 304 public: 302 305 explicit EdgeMap(const GraphAdaptorBase<GR>& adapter) 303 306 : Parent(*adapter._graph) {} 304 EdgeMap(const GraphAdaptorBase<GR>& adapter, const V& value) 305 : Parent(*adapter._graph, value) {} 307 EdgeMap(const GraphAdaptorBase<GR>& adapter, const V& value, 308 bool dynamic = true) 309 : Parent(*adapter._graph, value, dynamic) {} 306 310 307 311 private: 308 312 EdgeMap& operator=(const EdgeMap& cmap) { … … 519 523 520 524 NodeMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor) 521 525 : Parent(adaptor) {} 522 NodeMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor, const V& value) 523 : Parent(adaptor, value) {} 526 NodeMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor, const V& value, 527 bool dynamic = true) 528 : Parent(adaptor, value, dynamic) {} 524 529 525 530 private: 526 531 NodeMap& operator=(const NodeMap& cmap) { … … 546 551 547 552 ArcMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor) 548 553 : Parent(adaptor) {} 549 ArcMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor, const V& value) 550 : Parent(adaptor, value) {} 554 ArcMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor, const V& value, 555 bool dynamic = true) 556 : Parent(adaptor, value, dynamic) {} 551 557 552 558 private: 553 559 ArcMap& operator=(const ArcMap& cmap) { … … 662 668 663 669 NodeMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor) 664 670 : Parent(adaptor) {} 665 NodeMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor, const V& value) 666 : Parent(adaptor, value) {} 671 NodeMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor, const V& value, 672 bool dynamic = true) 673 : Parent(adaptor, value, dynamic) {} 667 674 668 675 private: 669 676 NodeMap& operator=(const NodeMap& cmap) { … … 689 696 690 697 ArcMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor) 691 698 : Parent(adaptor) {} 692 ArcMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor, const V& value) 693 : Parent(adaptor, value) {} 699 ArcMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor, const V& value, 700 bool dynamic = true) 701 : Parent(adaptor, value, dynamic) {} 694 702 695 703 private: 696 704 ArcMap& operator=(const ArcMap& cmap) { … … 1032 1040 1033 1041 NodeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor) 1034 1042 : Parent(adaptor) {} 1035 NodeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor, const V& value) 1036 : Parent(adaptor, value) {} 1043 NodeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor, const V& value, 1044 bool dynamic = true) 1045 : Parent(adaptor, value, dynamic) {} 1037 1046 1038 1047 private: 1039 1048 NodeMap& operator=(const NodeMap& cmap) { … … 1059 1068 1060 1069 ArcMap(const SubGraphBase<GR, NF, EF, ch>& adaptor) 1061 1070 : Parent(adaptor) {} 1062 ArcMap(const SubGraphBase<GR, NF, EF, ch>& adaptor, const V& value) 1063 : Parent(adaptor, value) {} 1071 ArcMap(const SubGraphBase<GR, NF, EF, ch>& adaptor, const V& value, 1072 bool dynamic = true) 1073 : Parent(adaptor, value, dynamic) {} 1064 1074 1065 1075 private: 1066 1076 ArcMap& operator=(const ArcMap& cmap) { … … 1087 1097 EdgeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor) 1088 1098 : Parent(adaptor) {} 1089 1099 1090 EdgeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor, const V& value) 1091 : Parent(adaptor, value) {} 1100 EdgeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor, const V& value, 1101 bool dynamic = true) 1102 : Parent(adaptor, value, dynamic) {} 1092 1103 1093 1104 private: 1094 1105 EdgeMap& operator=(const EdgeMap& cmap) { … … 1230 1241 1231 1242 NodeMap(const SubGraphBase<GR, NF, EF, false>& adaptor) 1232 1243 : Parent(adaptor) {} 1233 NodeMap(const SubGraphBase<GR, NF, EF, false>& adaptor, const V& value) 1234 : Parent(adaptor, value) {} 1244 NodeMap(const SubGraphBase<GR, NF, EF, false>& adaptor, const V& value, 1245 bool dynamic = true) 1246 : Parent(adaptor, value, dynamic) {} 1235 1247 1236 1248 private: 1237 1249 NodeMap& operator=(const NodeMap& cmap) { … … 1257 1269 1258 1270 ArcMap(const SubGraphBase<GR, NF, EF, false>& adaptor) 1259 1271 : Parent(adaptor) {} 1260 ArcMap(const SubGraphBase<GR, NF, EF, false>& adaptor, const V& value) 1261 : Parent(adaptor, value) {} 1272 ArcMap(const SubGraphBase<GR, NF, EF, false>& adaptor, const V& value, 1273 bool dynamic = true) 1274 : Parent(adaptor, value, dynamic) {} 1262 1275 1263 1276 private: 1264 1277 ArcMap& operator=(const ArcMap& cmap) { … … 1285 1298 EdgeMap(const SubGraphBase<GR, NF, EF, false>& adaptor) 1286 1299 : Parent(adaptor) {} 1287 1300 1288 EdgeMap(const SubGraphBase<GR, NF, EF, false>& adaptor, const V& value) 1289 : Parent(adaptor, value) {} 1301 EdgeMap(const SubGraphBase<GR, NF, EF, false>& adaptor, const V& value, 1302 bool dynamic = true) 1303 : Parent(adaptor, value, dynamic) {} 1290 1304 1291 1305 private: 1292 1306 EdgeMap& operator=(const EdgeMap& cmap) { … … 2097 2111 ArcMapBase(const UndirectorBase<DGR>& adaptor) : 2098 2112 _forward(*adaptor._digraph), _backward(*adaptor._digraph) {} 2099 2113 2100 ArcMapBase(const UndirectorBase<DGR>& adaptor, const V& value) 2101 : _forward(*adaptor._digraph, value), 2102 _backward(*adaptor._digraph, value) {} 2114 ArcMapBase(const UndirectorBase<DGR>& adaptor, const V& value, 2115 bool dynamic = true) 2116 : _forward(*adaptor._digraph, value, dynamic), 2117 _backward(*adaptor._digraph, value, dynamic) {} 2118 2119 void update() { 2120 _forward.update(); 2121 _backward.update(); 2122 } 2103 2123 2104 2124 void set(const Arc& a, const V& value) { 2105 2125 if (direction(a)) { … … 2143 2163 explicit NodeMap(const UndirectorBase<DGR>& adaptor) 2144 2164 : Parent(*adaptor._digraph) {} 2145 2165 2146 NodeMap(const UndirectorBase<DGR>& adaptor, const V& value) 2147 : Parent(*adaptor._digraph, value) { } 2166 NodeMap(const UndirectorBase<DGR>& adaptor, const V& value, 2167 bool dynamic = true) 2168 : Parent(*adaptor._digraph, value, dynamic) { } 2148 2169 2149 2170 private: 2150 2171 NodeMap& operator=(const NodeMap& cmap) { … … 2170 2191 explicit ArcMap(const UndirectorBase<DGR>& adaptor) 2171 2192 : Parent(adaptor) {} 2172 2193 2173 ArcMap(const UndirectorBase<DGR>& adaptor, const V& value) 2174 : Parent(adaptor, value) {} 2194 ArcMap(const UndirectorBase<DGR>& adaptor, const V& value, 2195 bool dynamic = true) 2196 : Parent(adaptor, value, dynamic) {} 2175 2197 2176 2198 private: 2177 2199 ArcMap& operator=(const ArcMap& cmap) { … … 2195 2217 explicit EdgeMap(const UndirectorBase<DGR>& adaptor) 2196 2218 : Parent(*adaptor._digraph) {} 2197 2219 2198 EdgeMap(const UndirectorBase<DGR>& adaptor, const V& value) 2199 : Parent(*adaptor._digraph, value) {} 2220 EdgeMap(const UndirectorBase<DGR>& adaptor, const V& value, 2221 bool dynamic = true) 2222 : Parent(*adaptor._digraph, value, dynamic) {} 2200 2223 2201 2224 private: 2202 2225 EdgeMap& operator=(const EdgeMap& cmap) { … … 2483 2506 explicit NodeMap(const OrienterBase<GR, DM>& adapter) 2484 2507 : Parent(*adapter._graph) {} 2485 2508 2486 NodeMap(const OrienterBase<GR, DM>& adapter, const V& value) 2487 : Parent(*adapter._graph, value) {} 2509 NodeMap(const OrienterBase<GR, DM>& adapter, const V& value, 2510 bool dynamic = true) 2511 : Parent(*adapter._graph, value, dynamic) {} 2488 2512 2489 2513 private: 2490 2514 NodeMap& operator=(const NodeMap& cmap) { … … 2508 2532 explicit ArcMap(const OrienterBase<GR, DM>& adapter) 2509 2533 : Parent(*adapter._graph) { } 2510 2534 2511 ArcMap(const OrienterBase<GR, DM>& adapter, const V& value) 2512 : Parent(*adapter._graph, value) { } 2535 ArcMap(const OrienterBase<GR, DM>& adapter, const V& value, 2536 bool dynamic = true) 2537 : Parent(*adapter._graph, value, dynamic) { } 2513 2538 2514 2539 private: 2515 2540 ArcMap& operator=(const ArcMap& cmap) { … … 3187 3212 3188 3213 NodeMapBase(const SplitNodesBase<DGR>& adaptor) 3189 3214 : _in_map(*adaptor._digraph), _out_map(*adaptor._digraph) {} 3190 NodeMapBase(const SplitNodesBase<DGR>& adaptor, const V& value) 3191 : _in_map(*adaptor._digraph, value), 3192 _out_map(*adaptor._digraph, value) {} 3215 NodeMapBase(const SplitNodesBase<DGR>& adaptor, const V& value, 3216 bool dynamic = true) 3217 : _in_map(*adaptor._digraph, value, dynamic), 3218 _out_map(*adaptor._digraph, value, dynamic) {} 3219 3220 void update() { 3221 _in_map.update(); 3222 _out_map.update(); 3223 } 3193 3224 3194 3225 void set(const Node& key, const V& val) { 3195 3226 if (SplitNodesBase<DGR>::inNode(key)) { _in_map.set(key, val); } … … 3226 3257 3227 3258 ArcMapBase(const SplitNodesBase<DGR>& adaptor) 3228 3259 : _arc_map(*adaptor._digraph), _node_map(*adaptor._digraph) {} 3229 ArcMapBase(const SplitNodesBase<DGR>& adaptor, const V& value) 3230 : _arc_map(*adaptor._digraph, value), 3231 _node_map(*adaptor._digraph, value) {} 3260 ArcMapBase(const SplitNodesBase<DGR>& adaptor, const V& value, 3261 bool dynamic = true) 3262 : _arc_map(*adaptor._digraph, value, dynamic), 3263 _node_map(*adaptor._digraph, value, dynamic) {} 3264 3265 void update() { 3266 _arc_map.update(); 3267 _node_map.update(); 3268 } 3232 3269 3233 3270 void set(const Arc& key, const V& val) { 3234 3271 if (SplitNodesBase<DGR>::origArc(key)) { … … 3272 3309 NodeMap(const SplitNodesBase<DGR>& adaptor) 3273 3310 : Parent(adaptor) {} 3274 3311 3275 NodeMap(const SplitNodesBase<DGR>& adaptor, const V& value) 3276 : Parent(adaptor, value) {} 3312 NodeMap(const SplitNodesBase<DGR>& adaptor, const V& value, 3313 bool dynamic = true) 3314 : Parent(adaptor, value, dynamic) {} 3277 3315 3278 3316 private: 3279 3317 NodeMap& operator=(const NodeMap& cmap) { … … 3298 3336 ArcMap(const SplitNodesBase<DGR>& adaptor) 3299 3337 : Parent(adaptor) {} 3300 3338 3301 ArcMap(const SplitNodesBase<DGR>& adaptor, const V& value) 3302 : Parent(adaptor, value) {} 3339 ArcMap(const SplitNodesBase<DGR>& adaptor, const V& value, 3340 bool dynamic = true) 3341 : Parent(adaptor, value, dynamic) {} 3303 3342 3304 3343 private: 3305 3344 ArcMap& operator=(const ArcMap& cmap) { -
lemon/bits/alteration_notifier.h
diff -r 9cc6e98c487d -r 765a16dc7c3a lemon/bits/alteration_notifier.h
a b 141 141 // \brief Constructor which attach the observer into notifier. 142 142 // 143 143 // Constructor which attach the observer into notifier. 144 ObserverBase(AlterationNotifier& nf ) {145 attach(nf );144 ObserverBase(AlterationNotifier& nf, bool dynamic = true) { 145 attach(nf, dynamic); 146 146 } 147 147 148 148 // \brief Constructor which attach the obserever to the same notifier. 149 149 // 150 150 // Constructor which attach the obserever to the same notifier as 151 151 // the other observer is attached to. 152 ObserverBase(const ObserverBase& copy ) {152 ObserverBase(const ObserverBase& copy, bool dynamic = true) { 153 153 if (copy.attached()) { 154 attach(*copy.notifier() );154 attach(*copy.notifier(), dynamic); 155 155 } 156 156 } 157 157 … … 165 165 // \brief Attaches the observer into an AlterationNotifier. 166 166 // 167 167 // This member attaches the observer into an AlterationNotifier. 168 void attach(AlterationNotifier& nf ) {169 nf.attach(*this );168 void attach(AlterationNotifier& nf, bool dynamic = true) { 169 nf.attach(*this, dynamic); 170 170 } 171 171 172 172 // \brief Detaches the observer into an AlterationNotifier. … … 186 186 // Gives back true when the observer is attached into a notifier. 187 187 bool attached() const { return _notifier != 0; } 188 188 189 // Gives back true when the observer is dynamic. 190 bool dynamic() const { 191 return _notifier->_observers.end() != _index; 192 } 193 189 194 private: 190 195 191 196 ObserverBase& operator=(const ObserverBase& copy); … … 331 336 332 337 protected: 333 338 334 void attach(ObserverBase& observer) { 335 observer._index = _observers.insert(_observers.begin(), &observer); 339 void attach(ObserverBase& observer, bool dynamic = true) { 340 if (dynamic) { 341 observer._index = _observers.insert(_observers.begin(), &observer); 342 } else { 343 observer._index = _observers.end(); 344 } 336 345 observer._notifier = this; 337 346 } 338 347 339 348 void detach(ObserverBase& observer) { 340 _observers.erase(observer._index); 349 if (observer._index != _observers.end()) { 350 _observers.erase(observer._index); 351 } 341 352 observer._index = _observers.end(); 342 353 observer._notifier = 0; 343 354 } -
lemon/bits/array_map.h
diff -r 9cc6e98c487d -r 765a16dc7c3a lemon/bits/array_map.h
a b 87 87 Notifier* nf = Parent::notifier(); 88 88 Item it; 89 89 for (nf->first(it); it != INVALID; nf->next(it)) { 90 int id = nf->id(it); ;90 int id = nf->id(it); 91 91 allocator.construct(&(values[id]), Value()); 92 92 } 93 93 } … … 95 95 // \brief Constructor to use default value to initialize the map. 96 96 // 97 97 // It constructs a map and initialize all of the the map. 98 ArrayMap(const GraphType& graph, const Value& value) { 99 Parent::attach(graph.notifier(Item())); 98 ArrayMap(const GraphType& graph, const Value& value, 99 bool dynamic = true) { 100 Parent::attach(graph.notifier(Item()), dynamic); 100 101 allocate_memory(); 101 Notifier* nf = Parent::notifier(); 102 Item it; 103 for (nf->first(it); it != INVALID; nf->next(it)) { 104 int id = nf->id(it);; 105 allocator.construct(&(values[id]), value); 102 if (dynamic) { 103 Notifier* nf = Parent::notifier(); 104 Item it; 105 for (nf->first(it); it != INVALID; nf->next(it)) { 106 int id = nf->id(it); 107 allocator.construct(&(values[id]), value); 108 } 109 } else { 110 for (int id = 0; id < capacity; ++id) { 111 allocator.construct(&(values[id]), value); 112 } 113 } 114 } 115 116 // \brief Updates the static map 117 // 118 // If the map is static map, this function reallocates the 119 // capacity of the map to the current state of the item set. 120 void update() { 121 if (!Parent::dynamic()) { 122 int max_id = Parent::notifier()->maxId(); 123 if (max_id >= capacity) { 124 int new_capacity = (capacity == 0 ? 1 : capacity); 125 while (new_capacity <= max_id) { 126 new_capacity <<= 1; 127 } 128 Value* new_values = allocator.allocate(new_capacity); 129 for (int id = 0; id < capacity; ++id) { 130 allocator.construct(&(new_values[id]), values[id]); 131 } 132 for (int id = capacity; id < new_capacity; ++id) { 133 allocator.construct(&(new_values[id]), Value()); 134 } 135 if (capacity != 0) allocator.deallocate(values, capacity); 136 values = new_values; 137 capacity = new_capacity; 138 } 106 139 } 107 140 } 108 141 … … 110 143 // \brief Constructor to copy a map of the same map type. 111 144 // 112 145 // Constructor to copy a map of the same map type. 113 ArrayMap(const ArrayMap& copy ) : Parent() {146 ArrayMap(const ArrayMap& copy, bool dynamic = true) : Parent() { 114 147 if (copy.attached()) { 115 attach(*copy.notifier() );148 attach(*copy.notifier(), dynamic); 116 149 } 117 150 capacity = copy.capacity; 118 151 if (capacity == 0) return; 119 152 values = allocator.allocate(capacity); 120 Notifier* nf = Parent::notifier(); 121 Item it; 122 for (nf->first(it); it != INVALID; nf->next(it)) { 123 int id = nf->id(it);; 124 allocator.construct(&(values[id]), copy.values[id]); 153 if (dynamic) { 154 Notifier* nf = Parent::notifier(); 155 Item it; 156 for (nf->first(it); it != INVALID; nf->next(it)) { 157 int id = nf->id(it); 158 allocator.construct(&(values[id]), copy.values[id]); 159 } 160 } else { 161 std::vector<bool> constructed(capacity, false); 162 Notifier* nf = Parent::notifier(); 163 Item it; 164 for (nf->first(it); it != INVALID; nf->next(it)) { 165 int id = nf->id(it); 166 allocator.construct(&(values[id]), copy.values[id]); 167 constructed[id] = true; 168 } 169 for (int id = 0; id < capacity; ++id) { 170 if (!constructed[id]) { 171 allocator.construct(&(values[id]), Value()); 172 } 173 } 125 174 } 126 175 } 127 176 … … 160 209 // The destructor of the map. 161 210 virtual ~ArrayMap() { 162 211 if (attached()) { 163 clear(); 212 if (Parent::dynamic()) { 213 Notifier* nf = Parent::notifier(); 214 if (capacity != 0) { 215 Item it; 216 for (nf->first(it); it != INVALID; nf->next(it)) { 217 int id = nf->id(it); 218 allocator.destroy(&(values[id])); 219 } 220 allocator.deallocate(values, capacity); 221 capacity = 0; 222 } 223 } else { 224 if (capacity != 0) { 225 for (int id = 0; id < capacity; ++id) { 226 allocator.destroy(&(values[id])); 227 } 228 allocator.deallocate(values, capacity); 229 capacity = 0; 230 } 231 } 164 232 detach(); 165 233 } 166 234 } -
lemon/bits/default_map.h
diff -r 9cc6e98c487d -r 765a16dc7c3a lemon/bits/default_map.h
a b 162 162 typedef typename Parent::Value Value; 163 163 164 164 explicit DefaultMap(const GraphType& graph) : Parent(graph) {} 165 DefaultMap(const GraphType& graph, const Value& value )166 : Parent(graph, value ) {}165 DefaultMap(const GraphType& graph, const Value& value, bool dynamic = true) 166 : Parent(graph, value, dynamic) {} 167 167 168 168 DefaultMap& operator=(const DefaultMap& cmap) { 169 169 return operator=<DefaultMap>(cmap); -
lemon/bits/edge_set_extender.h
diff -r 9cc6e98c487d -r 765a16dc7c3a lemon/bits/edge_set_extender.h
a b 224 224 public: 225 225 explicit ArcMap(const Digraph& _g) 226 226 : Parent(_g) {} 227 ArcMap(const Digraph& _g, const _Value& _v )228 : Parent(_g, _v ) {}227 ArcMap(const Digraph& _g, const _Value& _v, bool dynamic = true) 228 : Parent(_g, _v, dynamic) {} 229 229 230 230 ArcMap& operator=(const ArcMap& cmap) { 231 231 return operator=<ArcMap>(cmap); … … 539 539 public: 540 540 explicit ArcMap(const Graph& _g) 541 541 : Parent(_g) {} 542 ArcMap(const Graph& _g, const _Value& _v )543 : Parent(_g, _v ) {}542 ArcMap(const Graph& _g, const _Value& _v, bool dynamic = true) 543 : Parent(_g, _v, dynamic) {} 544 544 545 545 ArcMap& operator=(const ArcMap& cmap) { 546 546 return operator=<ArcMap>(cmap); … … 564 564 explicit EdgeMap(const Graph& _g) 565 565 : Parent(_g) {} 566 566 567 EdgeMap(const Graph& _g, const _Value& _v )568 : Parent(_g, _v ) {}567 EdgeMap(const Graph& _g, const _Value& _v, bool dynamic = true) 568 : Parent(_g, _v, dynamic) {} 569 569 570 570 EdgeMap& operator=(const EdgeMap& cmap) { 571 571 return operator=<EdgeMap>(cmap); -
lemon/bits/graph_extender.h
diff -r 9cc6e98c487d -r 765a16dc7c3a lemon/bits/graph_extender.h
a b 224 224 public: 225 225 explicit NodeMap(const Digraph& digraph) 226 226 : Parent(digraph) {} 227 NodeMap(const Digraph& digraph, const _Value& value )228 : Parent(digraph, value ) {}227 NodeMap(const Digraph& digraph, const _Value& value, bool dynamic = true) 228 : Parent(digraph, value, dynamic) {} 229 229 230 230 private: 231 231 NodeMap& operator=(const NodeMap& cmap) { … … 248 248 public: 249 249 explicit ArcMap(const Digraph& digraph) 250 250 : Parent(digraph) {} 251 ArcMap(const Digraph& digraph, const _Value& value )252 : Parent(digraph, value ) {}251 ArcMap(const Digraph& digraph, const _Value& value, bool dynamic = true) 252 : Parent(digraph, value, dynamic) {} 253 253 254 254 private: 255 255 ArcMap& operator=(const ArcMap& cmap) { … … 606 606 public: 607 607 explicit NodeMap(const Graph& graph) 608 608 : Parent(graph) {} 609 NodeMap(const Graph& graph, const _Value& value )610 : Parent(graph, value ) {}609 NodeMap(const Graph& graph, const _Value& value, bool dynamic = true) 610 : Parent(graph, value, dynamic) {} 611 611 612 612 private: 613 613 NodeMap& operator=(const NodeMap& cmap) { … … 630 630 public: 631 631 explicit ArcMap(const Graph& graph) 632 632 : Parent(graph) {} 633 ArcMap(const Graph& graph, const _Value& value )634 : Parent(graph, value ) {}633 ArcMap(const Graph& graph, const _Value& value, bool dynamic = true) 634 : Parent(graph, value, dynamic = true) {} 635 635 636 636 private: 637 637 ArcMap& operator=(const ArcMap& cmap) { … … 655 655 explicit EdgeMap(const Graph& graph) 656 656 : Parent(graph) {} 657 657 658 EdgeMap(const Graph& graph, const _Value& value )659 : Parent(graph, value ) {}658 EdgeMap(const Graph& graph, const _Value& value, bool dynamic = true) 659 : Parent(graph, value, dynamic) {} 660 660 661 661 private: 662 662 EdgeMap& operator=(const EdgeMap& cmap) { -
lemon/bits/map_extender.h
diff -r 9cc6e98c487d -r 765a16dc7c3a lemon/bits/map_extender.h
a b 62 62 MapExtender(const GraphType& graph) 63 63 : Parent(graph) {} 64 64 65 MapExtender(const GraphType& graph, const Value& value )66 : Parent(graph, value ) {}65 MapExtender(const GraphType& graph, const Value& value, bool dynamic = true) 66 : Parent(graph, value, dynamic) {} 67 67 68 68 private: 69 69 MapExtender& operator=(const MapExtender& cmap) { … … 206 206 SubMapExtender(const GraphType& _graph) 207 207 : Parent(_graph), graph(_graph) {} 208 208 209 SubMapExtender(const GraphType& _graph, const Value& _value) 210 : Parent(_graph, _value), graph(_graph) {} 209 SubMapExtender(const GraphType& _graph, const Value& _value, 210 bool dynamic = true) 211 : Parent(_graph, _value, dynamic), graph(_graph) {} 211 212 212 213 private: 213 214 SubMapExtender& operator=(const SubMapExtender& cmap) { -
lemon/bits/vector_map.h
diff -r 9cc6e98c487d -r 765a16dc7c3a lemon/bits/vector_map.h
a b 98 98 // 99 99 // It constructs a map uses a given value to initialize the map. 100 100 // It adds all the items of the graph to the map. 101 VectorMap(const GraphType& graph, const Value& value) { 102 Parent::attach(graph.notifier(Item())); 101 VectorMap(const GraphType& graph, const Value& value, 102 bool dynamic = true) { 103 Parent::attach(graph.notifier(Item()), dynamic); 103 104 container.resize(Parent::notifier()->maxId() + 1, value); 104 105 } 105 106 107 // \brief Updates the static map 108 // 109 // If the map is static map, this function reallocates the 110 // capacity of the map to the current state of the item set. 111 void update() { 112 if (!Parent::dynamic()) { 113 container.resize(Parent::notifier()->maxId() + 1, Value()); 114 } 115 } 116 106 117 private: 107 118 // \brief Copy constructor 108 119 // 109 120 // Copy constructor. 110 VectorMap(const VectorMap& _copy ) : Parent() {121 VectorMap(const VectorMap& _copy, bool dynamic = true) : Parent() { 111 122 if (_copy.attached()) { 112 Parent::attach(*_copy.notifier() );123 Parent::attach(*_copy.notifier(), dynamic); 113 124 container = _copy.container; 114 125 } 115 126 } -
lemon/concepts/digraph.h
diff -r 9cc6e98c487d -r 765a16dc7c3a lemon/concepts/digraph.h
a b 430 430 /// Constructor 431 431 explicit NodeMap(const Digraph&) { } 432 432 /// Constructor with given initial value 433 NodeMap(const Digraph&, T) { } 433 NodeMap(const Digraph&, T, bool = true) { } 434 /// Static map update 435 void update() { } 434 436 435 437 private: 436 438 ///Copy constructor … … 455 457 /// Constructor 456 458 explicit ArcMap(const Digraph&) { } 457 459 /// Constructor with given initial value 458 ArcMap(const Digraph&, T) { } 460 ArcMap(const Digraph&, T, bool = true) { } 461 /// Static map update 462 void update() { } 459 463 460 464 private: 461 465 ///Copy constructor -
lemon/concepts/graph.h
diff -r 9cc6e98c487d -r 765a16dc7c3a lemon/concepts/graph.h
a b 517 517 /// Constructor 518 518 explicit NodeMap(const Graph&) { } 519 519 /// Constructor with given initial value 520 NodeMap(const Graph&, T) { } 520 NodeMap(const Graph&, T, bool = true) { } 521 /// Static map update 522 void update() { } 521 523 522 524 private: 523 525 ///Copy constructor … … 543 545 /// Constructor 544 546 explicit ArcMap(const Graph&) { } 545 547 /// Constructor with given initial value 546 ArcMap(const Graph&, T) { } 548 ArcMap(const Graph&, T, bool = true) { } 549 /// Static map update 550 void update() { } 547 551 548 552 private: 549 553 ///Copy constructor … … 569 573 /// Constructor 570 574 explicit EdgeMap(const Graph&) { } 571 575 /// Constructor with given initial value 572 EdgeMap(const Graph&, T) { } 576 EdgeMap(const Graph&, T, bool = true) { } 577 /// Static map update 578 void update() { } 573 579 574 580 private: 575 581 ///Copy constructor -
lemon/concepts/graph_components.h
diff -r 9cc6e98c487d -r 765a16dc7c3a lemon/concepts/graph_components.h
a b 1018 1018 /// \brief Construct a new map with default value. 1019 1019 /// 1020 1020 /// Construct a new map for the graph and initalize the values. 1021 GraphMap(const GR&, const Value&) {} 1021 GraphMap(const GR&, const Value&, bool = true) {} 1022 /// \brief Static map update 1023 /// 1024 /// Updates the static map 1025 void update() {} 1022 1026 1023 1027 private: 1024 1028 /// \brief Copy constructor. … … 1045 1049 <ReferenceMap<Key, Value, Value&, const Value&>, _Map>(); 1046 1050 _Map m1(g); 1047 1051 _Map m2(g,t); 1052 _Map m3(g,t,false); 1053 1054 m3.update(); 1048 1055 1049 1056 // Copy constructor 1050 1057 // _Map m3(m); … … 1055 1062 1056 1063 ignore_unused_variable_warning(m1); 1057 1064 ignore_unused_variable_warning(m2); 1065 ignore_unused_variable_warning(m3); 1058 1066 // ignore_unused_variable_warning(m3); 1059 1067 } 1060 1068 … … 1099 1107 /// \brief Construct a new map with default value. 1100 1108 /// 1101 1109 /// Construct a new map for the digraph and initalize the values. 1102 NodeMap(const MappableDigraphComponent& digraph, const V& value) 1103 : Parent(digraph, value) {} 1110 NodeMap(const MappableDigraphComponent& digraph, const V& value, 1111 bool dynamic = true) 1112 : Parent(digraph, value, dynamic) {} 1104 1113 1105 1114 private: 1106 1115 /// \brief Copy constructor. … … 1137 1146 /// \brief Construct a new map with default value. 1138 1147 /// 1139 1148 /// Construct a new map for the digraph and initalize the values. 1140 ArcMap(const MappableDigraphComponent& digraph, const V& value) 1141 : Parent(digraph, value) {} 1149 ArcMap(const MappableDigraphComponent& digraph, const V& value, 1150 bool dynamic = true) 1151 : Parent(digraph, value, dynamic) {} 1142 1152 1143 1153 private: 1144 1154 /// \brief Copy constructor. … … 1235 1245 /// \brief Construct a new map with default value. 1236 1246 /// 1237 1247 /// Construct a new map for the graph and initalize the values. 1238 EdgeMap(const MappableGraphComponent& graph, const V& value) 1239 : Parent(graph, value) {} 1248 EdgeMap(const MappableGraphComponent& graph, const V& value, 1249 bool dynamic = true) 1250 : Parent(graph, value, dynamic) {} 1240 1251 1241 1252 private: 1242 1253 /// \brief Copy constructor. -
lemon/edge_set.h
diff -r 9cc6e98c487d -r 765a16dc7c3a lemon/edge_set.h
a b 220 220 explicit NodeMap(const ListArcSetBase<GR>& arcset) 221 221 : Parent(*arcset._graph) {} 222 222 223 NodeMap(const ListArcSetBase<GR>& arcset, const V& value) 224 : Parent(*arcset._graph, value) {} 223 NodeMap(const ListArcSetBase<GR>& arcset, const V& value, 224 bool dynamic = true) 225 : Parent(*arcset._graph, value, dynamic) {} 225 226 226 227 NodeMap& operator=(const NodeMap& cmap) { 227 228 return operator=<NodeMap>(cmap); … … 651 652 explicit NodeMap(const ListEdgeSetBase<GR>& arcset) 652 653 : Parent(*arcset._graph) {} 653 654 654 NodeMap(const ListEdgeSetBase<GR>& arcset, const V& value) 655 : Parent(*arcset._graph, value) {} 655 NodeMap(const ListEdgeSetBase<GR>& arcset, const V& value, 656 bool dynamic = true) 657 : Parent(*arcset._graph, value, dynamic) {} 656 658 657 659 NodeMap& operator=(const NodeMap& cmap) { 658 660 return operator=<NodeMap>(cmap); … … 916 918 explicit NodeMap(const SmartArcSetBase<GR>& arcset) 917 919 : Parent(*arcset._graph) { } 918 920 919 NodeMap(const SmartArcSetBase<GR>& arcset, const V& value) 920 : Parent(*arcset._graph, value) { } 921 NodeMap(const SmartArcSetBase<GR>& arcset, const V& value, 922 bool dynamic = true) 923 : Parent(*arcset._graph, value, dynamic) { } 921 924 922 925 NodeMap& operator=(const NodeMap& cmap) { 923 926 return operator=<NodeMap>(cmap); … … 1268 1271 explicit NodeMap(const SmartEdgeSetBase<GR>& arcset) 1269 1272 : Parent(*arcset._graph) { } 1270 1273 1271 NodeMap(const SmartEdgeSetBase<GR>& arcset, const V& value) 1272 : Parent(*arcset._graph, value) { } 1274 NodeMap(const SmartEdgeSetBase<GR>& arcset, const V& value, 1275 bool dynamic = true) 1276 : Parent(*arcset._graph, value, dynamic) { } 1273 1277 1274 1278 NodeMap& operator=(const NodeMap& cmap) { 1275 1279 return operator=<NodeMap>(cmap);