0
8
0
| ... | ... |
@@ -100,12 +100,13 @@ |
| 100 | 100 |
for (nf->first(it); it != INVALID; nf->next(it)) {
|
| 101 | 101 |
int id = nf->id(it);; |
| 102 | 102 |
allocator.construct(&(values[id]), value); |
| 103 | 103 |
} |
| 104 | 104 |
} |
| 105 | 105 |
|
| 106 |
private: |
|
| 106 | 107 |
/// \brief Constructor to copy a map of the same map type. |
| 107 | 108 |
/// |
| 108 | 109 |
/// Constructor to copy a map of the same map type. |
| 109 | 110 |
ArrayMap(const ArrayMap& copy) : Parent() {
|
| 110 | 111 |
if (copy.attached()) {
|
| 111 | 112 |
attach(*copy.notifier()); |
| ... | ... |
@@ -147,12 +148,13 @@ |
| 147 | 148 |
for (nf->first(it); it != INVALID; nf->next(it)) {
|
| 148 | 149 |
set(it, cmap[it]); |
| 149 | 150 |
} |
| 150 | 151 |
return *this; |
| 151 | 152 |
} |
| 152 | 153 |
|
| 154 |
public: |
|
| 153 | 155 |
/// \brief The destructor of the map. |
| 154 | 156 |
/// |
| 155 | 157 |
/// The destructor of the map. |
| 156 | 158 |
virtual ~ArrayMap() {
|
| 157 | 159 |
if (attached()) {
|
| 158 | 160 |
clear(); |
| ... | ... |
@@ -224,12 +224,13 @@ |
| 224 | 224 |
|
| 225 | 225 |
explicit NodeMap(const Digraph& digraph) |
| 226 | 226 |
: Parent(digraph) {}
|
| 227 | 227 |
NodeMap(const Digraph& digraph, const _Value& value) |
| 228 | 228 |
: Parent(digraph, value) {}
|
| 229 | 229 |
|
| 230 |
private: |
|
| 230 | 231 |
NodeMap& operator=(const NodeMap& cmap) {
|
| 231 | 232 |
return operator=<NodeMap>(cmap); |
| 232 | 233 |
} |
| 233 | 234 |
|
| 234 | 235 |
template <typename CMap> |
| 235 | 236 |
NodeMap& operator=(const CMap& cmap) {
|
| ... | ... |
@@ -248,12 +249,13 @@ |
| 248 | 249 |
|
| 249 | 250 |
explicit ArcMap(const Digraph& digraph) |
| 250 | 251 |
: Parent(digraph) {}
|
| 251 | 252 |
ArcMap(const Digraph& digraph, const _Value& value) |
| 252 | 253 |
: Parent(digraph, value) {}
|
| 253 | 254 |
|
| 255 |
private: |
|
| 254 | 256 |
ArcMap& operator=(const ArcMap& cmap) {
|
| 255 | 257 |
return operator=<ArcMap>(cmap); |
| 256 | 258 |
} |
| 257 | 259 |
|
| 258 | 260 |
template <typename CMap> |
| 259 | 261 |
ArcMap& operator=(const CMap& cmap) {
|
| ... | ... |
@@ -605,12 +607,13 @@ |
| 605 | 607 |
|
| 606 | 608 |
NodeMap(const Graph& graph) |
| 607 | 609 |
: Parent(graph) {}
|
| 608 | 610 |
NodeMap(const Graph& graph, const _Value& value) |
| 609 | 611 |
: Parent(graph, value) {}
|
| 610 | 612 |
|
| 613 |
private: |
|
| 611 | 614 |
NodeMap& operator=(const NodeMap& cmap) {
|
| 612 | 615 |
return operator=<NodeMap>(cmap); |
| 613 | 616 |
} |
| 614 | 617 |
|
| 615 | 618 |
template <typename CMap> |
| 616 | 619 |
NodeMap& operator=(const CMap& cmap) {
|
| ... | ... |
@@ -629,12 +632,13 @@ |
| 629 | 632 |
|
| 630 | 633 |
ArcMap(const Graph& graph) |
| 631 | 634 |
: Parent(graph) {}
|
| 632 | 635 |
ArcMap(const Graph& graph, const _Value& value) |
| 633 | 636 |
: Parent(graph, value) {}
|
| 634 | 637 |
|
| 638 |
private: |
|
| 635 | 639 |
ArcMap& operator=(const ArcMap& cmap) {
|
| 636 | 640 |
return operator=<ArcMap>(cmap); |
| 637 | 641 |
} |
| 638 | 642 |
|
| 639 | 643 |
template <typename CMap> |
| 640 | 644 |
ArcMap& operator=(const CMap& cmap) {
|
| ... | ... |
@@ -654,12 +658,13 @@ |
| 654 | 658 |
EdgeMap(const Graph& graph) |
| 655 | 659 |
: Parent(graph) {}
|
| 656 | 660 |
|
| 657 | 661 |
EdgeMap(const Graph& graph, const _Value& value) |
| 658 | 662 |
: Parent(graph, value) {}
|
| 659 | 663 |
|
| 664 |
private: |
|
| 660 | 665 |
EdgeMap& operator=(const EdgeMap& cmap) {
|
| 661 | 666 |
return operator=<EdgeMap>(cmap); |
| 662 | 667 |
} |
| 663 | 668 |
|
| 664 | 669 |
template <typename CMap> |
| 665 | 670 |
EdgeMap& operator=(const CMap& cmap) {
|
| ... | ... |
@@ -59,22 +59,24 @@ |
| 59 | 59 |
MapExtender(const Graph& graph) |
| 60 | 60 |
: Parent(graph) {}
|
| 61 | 61 |
|
| 62 | 62 |
MapExtender(const Graph& graph, const Value& value) |
| 63 | 63 |
: Parent(graph, value) {}
|
| 64 | 64 |
|
| 65 |
private: |
|
| 65 | 66 |
MapExtender& operator=(const MapExtender& cmap) {
|
| 66 | 67 |
return operator=<MapExtender>(cmap); |
| 67 | 68 |
} |
| 68 | 69 |
|
| 69 | 70 |
template <typename CMap> |
| 70 | 71 |
MapExtender& operator=(const CMap& cmap) {
|
| 71 | 72 |
Parent::operator=(cmap); |
| 72 | 73 |
return *this; |
| 73 | 74 |
} |
| 74 | 75 |
|
| 76 |
public: |
|
| 75 | 77 |
class MapIt : public Item {
|
| 76 | 78 |
public: |
| 77 | 79 |
|
| 78 | 80 |
typedef Item Parent; |
| 79 | 81 |
typedef typename Map::Value Value; |
| 80 | 82 |
|
| ... | ... |
@@ -197,12 +199,13 @@ |
| 197 | 199 |
SubMapExtender(const Graph& _graph) |
| 198 | 200 |
: Parent(_graph), graph(_graph) {}
|
| 199 | 201 |
|
| 200 | 202 |
SubMapExtender(const Graph& _graph, const Value& _value) |
| 201 | 203 |
: Parent(_graph, _value), graph(_graph) {}
|
| 202 | 204 |
|
| 205 |
private: |
|
| 203 | 206 |
SubMapExtender& operator=(const SubMapExtender& cmap) {
|
| 204 | 207 |
return operator=<MapExtender>(cmap); |
| 205 | 208 |
} |
| 206 | 209 |
|
| 207 | 210 |
template <typename CMap> |
| 208 | 211 |
SubMapExtender& operator=(const CMap& cmap) {
|
| ... | ... |
@@ -211,12 +214,13 @@ |
| 211 | 214 |
for (graph.first(it); it != INVALID; graph.next(it)) {
|
| 212 | 215 |
Parent::set(it, cmap[it]); |
| 213 | 216 |
} |
| 214 | 217 |
return *this; |
| 215 | 218 |
} |
| 216 | 219 |
|
| 220 |
public: |
|
| 217 | 221 |
class MapIt : public Item {
|
| 218 | 222 |
public: |
| 219 | 223 |
|
| 220 | 224 |
typedef Item Parent; |
| 221 | 225 |
typedef typename Map::Value Value; |
| 222 | 226 |
| ... | ... |
@@ -97,12 +97,13 @@ |
| 97 | 97 |
/// It adds all the items of the graph to the map. |
| 98 | 98 |
VectorMap(const Graph& graph, const Value& value) {
|
| 99 | 99 |
Parent::attach(graph.notifier(Item())); |
| 100 | 100 |
container.resize(Parent::notifier()->maxId() + 1, value); |
| 101 | 101 |
} |
| 102 | 102 |
|
| 103 |
private: |
|
| 103 | 104 |
/// \brief Copy constructor |
| 104 | 105 |
/// |
| 105 | 106 |
/// Copy constructor. |
| 106 | 107 |
VectorMap(const VectorMap& _copy) : Parent() {
|
| 107 | 108 |
if (_copy.attached()) {
|
| 108 | 109 |
Parent::attach(*_copy.notifier()); |
| ... | ... |
@@ -431,12 +431,13 @@ |
| 431 | 431 |
|
| 432 | 432 |
///\e |
| 433 | 433 |
NodeMap(const Digraph&) { }
|
| 434 | 434 |
///\e |
| 435 | 435 |
NodeMap(const Digraph&, T) { }
|
| 436 | 436 |
|
| 437 |
private: |
|
| 437 | 438 |
///Copy constructor |
| 438 | 439 |
NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
|
| 439 | 440 |
///Assignment operator |
| 440 | 441 |
template <typename CMap> |
| 441 | 442 |
NodeMap& operator=(const CMap&) {
|
| 442 | 443 |
checkConcept<ReadMap<Node, T>, CMap>(); |
| ... | ... |
@@ -453,12 +454,13 @@ |
| 453 | 454 |
public: |
| 454 | 455 |
|
| 455 | 456 |
///\e |
| 456 | 457 |
ArcMap(const Digraph&) { }
|
| 457 | 458 |
///\e |
| 458 | 459 |
ArcMap(const Digraph&, T) { }
|
| 460 |
private: |
|
| 459 | 461 |
///Copy constructor |
| 460 | 462 |
ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
|
| 461 | 463 |
///Assignment operator |
| 462 | 464 |
template <typename CMap> |
| 463 | 465 |
ArcMap& operator=(const CMap&) {
|
| 464 | 466 |
checkConcept<ReadMap<Arc, T>, CMap>(); |
| ... | ... |
@@ -509,12 +509,13 @@ |
| 509 | 509 |
|
| 510 | 510 |
///\e |
| 511 | 511 |
NodeMap(const Graph&) { }
|
| 512 | 512 |
///\e |
| 513 | 513 |
NodeMap(const Graph&, T) { }
|
| 514 | 514 |
|
| 515 |
private: |
|
| 515 | 516 |
///Copy constructor |
| 516 | 517 |
NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
|
| 517 | 518 |
///Assignment operator |
| 518 | 519 |
template <typename CMap> |
| 519 | 520 |
NodeMap& operator=(const CMap&) {
|
| 520 | 521 |
checkConcept<ReadMap<Node, T>, CMap>(); |
| ... | ... |
@@ -532,12 +533,13 @@ |
| 532 | 533 |
public: |
| 533 | 534 |
|
| 534 | 535 |
///\e |
| 535 | 536 |
ArcMap(const Graph&) { }
|
| 536 | 537 |
///\e |
| 537 | 538 |
ArcMap(const Graph&, T) { }
|
| 539 |
private: |
|
| 538 | 540 |
///Copy constructor |
| 539 | 541 |
ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
|
| 540 | 542 |
///Assignment operator |
| 541 | 543 |
template <typename CMap> |
| 542 | 544 |
ArcMap& operator=(const CMap&) {
|
| 543 | 545 |
checkConcept<ReadMap<Arc, T>, CMap>(); |
| ... | ... |
@@ -555,12 +557,13 @@ |
| 555 | 557 |
public: |
| 556 | 558 |
|
| 557 | 559 |
///\e |
| 558 | 560 |
EdgeMap(const Graph&) { }
|
| 559 | 561 |
///\e |
| 560 | 562 |
EdgeMap(const Graph&, T) { }
|
| 563 |
private: |
|
| 561 | 564 |
///Copy constructor |
| 562 | 565 |
EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {}
|
| 563 | 566 |
///Assignment operator |
| 564 | 567 |
template <typename CMap> |
| 565 | 568 |
EdgeMap& operator=(const CMap&) {
|
| 566 | 569 |
checkConcept<ReadMap<Edge, T>, CMap>(); |
| ... | ... |
@@ -1002,12 +1002,14 @@ |
| 1002 | 1002 |
/// Construct a new map for the graph. |
| 1003 | 1003 |
explicit GraphMap(const Graph&) {}
|
| 1004 | 1004 |
/// \brief Construct a new map with default value. |
| 1005 | 1005 |
/// |
| 1006 | 1006 |
/// Construct a new map for the graph and initalise the values. |
| 1007 | 1007 |
GraphMap(const Graph&, const Value&) {}
|
| 1008 |
|
|
| 1009 |
private: |
|
| 1008 | 1010 |
/// \brief Copy constructor. |
| 1009 | 1011 |
/// |
| 1010 | 1012 |
/// Copy Constructor. |
| 1011 | 1013 |
GraphMap(const GraphMap&) : Parent() {}
|
| 1012 | 1014 |
|
| 1013 | 1015 |
/// \brief Assign operator. |
| ... | ... |
@@ -1018,28 +1020,30 @@ |
| 1018 | 1020 |
template <typename CMap> |
| 1019 | 1021 |
GraphMap& operator=(const CMap&) {
|
| 1020 | 1022 |
checkConcept<ReadMap<Key, Value>, CMap>(); |
| 1021 | 1023 |
return *this; |
| 1022 | 1024 |
} |
| 1023 | 1025 |
|
| 1026 |
public: |
|
| 1024 | 1027 |
template<typename _Map> |
| 1025 | 1028 |
struct Constraints {
|
| 1026 | 1029 |
void constraints() {
|
| 1027 | 1030 |
checkConcept<ReadWriteMap<Key, Value>, _Map >(); |
| 1028 | 1031 |
// Construction with a graph parameter |
| 1029 | 1032 |
_Map a(g); |
| 1030 | 1033 |
// Constructor with a graph and a default value parameter |
| 1031 | 1034 |
_Map a2(g,t); |
| 1032 | 1035 |
// Copy constructor. |
| 1033 |
_Map b(c); |
|
| 1036 |
// _Map b(c); |
|
| 1034 | 1037 |
|
| 1035 |
ReadMap<Key, Value> cmap; |
|
| 1036 |
b = cmap; |
|
| 1038 |
// ReadMap<Key, Value> cmap; |
|
| 1039 |
// b = cmap; |
|
| 1037 | 1040 |
|
| 1041 |
ignore_unused_variable_warning(a); |
|
| 1038 | 1042 |
ignore_unused_variable_warning(a2); |
| 1039 |
ignore_unused_variable_warning(b); |
|
| 1043 |
// ignore_unused_variable_warning(b); |
|
| 1040 | 1044 |
} |
| 1041 | 1045 |
|
| 1042 | 1046 |
const _Map &c; |
| 1043 | 1047 |
const Graph &g; |
| 1044 | 1048 |
const typename GraphMap::Value &t; |
| 1045 | 1049 |
}; |
| ... | ... |
@@ -1079,12 +1083,13 @@ |
| 1079 | 1083 |
/// \brief Construct a new map with default value. |
| 1080 | 1084 |
/// |
| 1081 | 1085 |
/// Construct a new map for the digraph and initalise the values. |
| 1082 | 1086 |
NodeMap(const MappableDigraphComponent& digraph, const _Value& value) |
| 1083 | 1087 |
: Parent(digraph, value) {}
|
| 1084 | 1088 |
|
| 1089 |
private: |
|
| 1085 | 1090 |
/// \brief Copy constructor. |
| 1086 | 1091 |
/// |
| 1087 | 1092 |
/// Copy Constructor. |
| 1088 | 1093 |
NodeMap(const NodeMap& nm) : Parent(nm) {}
|
| 1089 | 1094 |
|
| 1090 | 1095 |
/// \brief Assign operator. |
| ... | ... |
@@ -1116,12 +1121,13 @@ |
| 1116 | 1121 |
/// \brief Construct a new map with default value. |
| 1117 | 1122 |
/// |
| 1118 | 1123 |
/// Construct a new map for the digraph and initalise the values. |
| 1119 | 1124 |
ArcMap(const MappableDigraphComponent& digraph, const _Value& value) |
| 1120 | 1125 |
: Parent(digraph, value) {}
|
| 1121 | 1126 |
|
| 1127 |
private: |
|
| 1122 | 1128 |
/// \brief Copy constructor. |
| 1123 | 1129 |
/// |
| 1124 | 1130 |
/// Copy Constructor. |
| 1125 | 1131 |
ArcMap(const ArcMap& nm) : Parent(nm) {}
|
| 1126 | 1132 |
|
| 1127 | 1133 |
/// \brief Assign operator. |
| ... | ... |
@@ -1212,12 +1218,13 @@ |
| 1212 | 1218 |
/// \brief Construct a new map with default value. |
| 1213 | 1219 |
/// |
| 1214 | 1220 |
/// Construct a new map for the graph and initalise the values. |
| 1215 | 1221 |
EdgeMap(const MappableGraphComponent& graph, const _Value& value) |
| 1216 | 1222 |
: Parent(graph, value) {}
|
| 1217 | 1223 |
|
| 1224 |
private: |
|
| 1218 | 1225 |
/// \brief Copy constructor. |
| 1219 | 1226 |
/// |
| 1220 | 1227 |
/// Copy Constructor. |
| 1221 | 1228 |
EdgeMap(const EdgeMap& nm) : Parent(nm) {}
|
| 1222 | 1229 |
|
| 1223 | 1230 |
/// \brief Assign operator. |
| ... | ... |
@@ -209,16 +209,16 @@ |
| 209 | 209 |
s = s * (s - 1) / 2; |
| 210 | 210 |
for (NodeIt it(G); it != INVALID; ++it) {
|
| 211 | 211 |
s -= map[it]; |
| 212 | 212 |
} |
| 213 | 213 |
check(s == 0, "Wrong sum."); |
| 214 | 214 |
|
| 215 |
map = constMap<Node>(12); |
|
| 216 |
for (NodeIt it(G); it != INVALID; ++it) {
|
|
| 217 |
check(map[it] == 12, "Wrong operator[]."); |
|
| 218 |
} |
|
| 215 |
// map = constMap<Node>(12); |
|
| 216 |
// for (NodeIt it(G); it != INVALID; ++it) {
|
|
| 217 |
// check(map[it] == 12, "Wrong operator[]."); |
|
| 218 |
// } |
|
| 219 | 219 |
} |
| 220 | 220 |
|
| 221 | 221 |
template <typename Graph> |
| 222 | 222 |
void checkGraphArcMap(const Graph& G) {
|
| 223 | 223 |
typedef typename Graph::Arc Arc; |
| 224 | 224 |
typedef typename Graph::ArcIt ArcIt; |
| ... | ... |
@@ -239,16 +239,16 @@ |
| 239 | 239 |
s = s * (s - 1) / 2; |
| 240 | 240 |
for (ArcIt it(G); it != INVALID; ++it) {
|
| 241 | 241 |
s -= map[it]; |
| 242 | 242 |
} |
| 243 | 243 |
check(s == 0, "Wrong sum."); |
| 244 | 244 |
|
| 245 |
map = constMap<Arc>(12); |
|
| 246 |
for (ArcIt it(G); it != INVALID; ++it) {
|
|
| 247 |
check(map[it] == 12, "Wrong operator[]."); |
|
| 248 |
} |
|
| 245 |
// map = constMap<Arc>(12); |
|
| 246 |
// for (ArcIt it(G); it != INVALID; ++it) {
|
|
| 247 |
// check(map[it] == 12, "Wrong operator[]."); |
|
| 248 |
// } |
|
| 249 | 249 |
} |
| 250 | 250 |
|
| 251 | 251 |
template <typename Graph> |
| 252 | 252 |
void checkGraphEdgeMap(const Graph& G) {
|
| 253 | 253 |
typedef typename Graph::Edge Edge; |
| 254 | 254 |
typedef typename Graph::EdgeIt EdgeIt; |
| ... | ... |
@@ -269,16 +269,16 @@ |
| 269 | 269 |
s = s * (s - 1) / 2; |
| 270 | 270 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
| 271 | 271 |
s -= map[it]; |
| 272 | 272 |
} |
| 273 | 273 |
check(s == 0, "Wrong sum."); |
| 274 | 274 |
|
| 275 |
map = constMap<Edge>(12); |
|
| 276 |
for (EdgeIt it(G); it != INVALID; ++it) {
|
|
| 277 |
check(map[it] == 12, "Wrong operator[]."); |
|
| 278 |
} |
|
| 275 |
// map = constMap<Edge>(12); |
|
| 276 |
// for (EdgeIt it(G); it != INVALID; ++it) {
|
|
| 277 |
// check(map[it] == 12, "Wrong operator[]."); |
|
| 278 |
// } |
|
| 279 | 279 |
} |
| 280 | 280 |
|
| 281 | 281 |
|
| 282 | 282 |
} //namespace lemon |
| 283 | 283 |
|
| 284 | 284 |
#endif |
0 comments (0 inline)