0
5
0
... | ... |
@@ -17,18 +17,16 @@ |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_GRAPH_ADAPTOR_EXTENDER_H |
20 | 20 |
#define LEMON_BITS_GRAPH_ADAPTOR_EXTENDER_H |
21 | 21 |
|
22 | 22 |
#include <lemon/core.h> |
23 | 23 |
#include <lemon/error.h> |
24 | 24 |
|
25 |
#include <lemon/bits/default_map.h> |
|
26 |
|
|
27 | 25 |
namespace lemon { |
28 | 26 |
|
29 | 27 |
template <typename _Digraph> |
30 | 28 |
class DigraphAdaptorExtender : public _Digraph { |
31 | 29 |
public: |
32 | 30 |
|
33 | 31 |
typedef _Digraph Parent; |
34 | 32 |
typedef _Digraph Digraph; |
... | ... |
@@ -42,16 +42,18 @@ |
42 | 42 |
typedef MapExtender Map; |
43 | 43 |
|
44 | 44 |
|
45 | 45 |
typedef typename Parent::Graph Graph; |
46 | 46 |
typedef typename Parent::Key Item; |
47 | 47 |
|
48 | 48 |
typedef typename Parent::Key Key; |
49 | 49 |
typedef typename Parent::Value Value; |
50 |
typedef typename Parent::Reference Reference; |
|
51 |
typedef typename Parent::ConstReference ConstReference; |
|
50 | 52 |
|
51 | 53 |
class MapIt; |
52 | 54 |
class ConstMapIt; |
53 | 55 |
|
54 | 56 |
friend class MapIt; |
55 | 57 |
friend class ConstMapIt; |
56 | 58 |
|
57 | 59 |
public: |
... | ... |
@@ -182,16 +184,18 @@ |
182 | 184 |
typedef SubMapExtender Map; |
183 | 185 |
|
184 | 186 |
typedef _Graph Graph; |
185 | 187 |
|
186 | 188 |
typedef typename Parent::Key Item; |
187 | 189 |
|
188 | 190 |
typedef typename Parent::Key Key; |
189 | 191 |
typedef typename Parent::Value Value; |
192 |
typedef typename Parent::Reference Reference; |
|
193 |
typedef typename Parent::ConstReference ConstReference; |
|
190 | 194 |
|
191 | 195 |
class MapIt; |
192 | 196 |
class ConstMapIt; |
193 | 197 |
|
194 | 198 |
friend class MapIt; |
195 | 199 |
friend class ConstMapIt; |
196 | 200 |
|
197 | 201 |
public: |
... | ... |
@@ -416,66 +416,67 @@ |
416 | 416 |
/// It is always the target of the pointed arc. |
417 | 417 |
Node runningNode(const OutArcIt&) const { return INVALID; } |
418 | 418 |
|
419 | 419 |
/// \brief The opposite node on the given arc. |
420 | 420 |
/// |
421 | 421 |
/// Gives back the opposite node on the given arc. |
422 | 422 |
Node oppositeNode(const Node&, const Arc&) const { return INVALID; } |
423 | 423 |
|
424 |
/// \brief |
|
424 |
/// \brief Reference map of the nodes to type \c T. |
|
425 | 425 |
/// |
426 |
/// ReadWrite map of the nodes to type \c T. |
|
427 |
/// \sa Reference |
|
426 |
/// Reference map of the nodes to type \c T. |
|
428 | 427 |
template<class T> |
429 |
class NodeMap : public |
|
428 |
class NodeMap : public ReferenceMap<Node, T, T&, const T&> { |
|
430 | 429 |
public: |
431 | 430 |
|
432 | 431 |
///\e |
433 | 432 |
NodeMap(const Digraph&) { } |
434 | 433 |
///\e |
435 | 434 |
NodeMap(const Digraph&, T) { } |
436 | 435 |
|
437 | 436 |
private: |
438 | 437 |
///Copy constructor |
439 |
NodeMap(const NodeMap& nm) : |
|
438 |
NodeMap(const NodeMap& nm) : |
|
439 |
ReferenceMap<Node, T, T&, const T&>(nm) { } |
|
440 | 440 |
///Assignment operator |
441 | 441 |
template <typename CMap> |
442 | 442 |
NodeMap& operator=(const CMap&) { |
443 | 443 |
checkConcept<ReadMap<Node, T>, CMap>(); |
444 | 444 |
return *this; |
445 | 445 |
} |
446 | 446 |
}; |
447 | 447 |
|
448 |
/// \brief |
|
448 |
/// \brief Reference map of the arcs to type \c T. |
|
449 | 449 |
/// |
450 | 450 |
/// Reference map of the arcs to type \c T. |
451 |
/// \sa Reference |
|
452 | 451 |
template<class T> |
453 |
class ArcMap : public |
|
452 |
class ArcMap : public ReferenceMap<Arc, T, T&, const T&> { |
|
454 | 453 |
public: |
455 | 454 |
|
456 | 455 |
///\e |
457 | 456 |
ArcMap(const Digraph&) { } |
458 | 457 |
///\e |
459 | 458 |
ArcMap(const Digraph&, T) { } |
460 | 459 |
private: |
461 | 460 |
///Copy constructor |
462 |
ArcMap(const ArcMap& em) : |
|
461 |
ArcMap(const ArcMap& em) : |
|
462 |
ReferenceMap<Arc, T, T&, const T&>(em) { } |
|
463 | 463 |
///Assignment operator |
464 | 464 |
template <typename CMap> |
465 | 465 |
ArcMap& operator=(const CMap&) { |
466 | 466 |
checkConcept<ReadMap<Arc, T>, CMap>(); |
467 | 467 |
return *this; |
468 | 468 |
} |
469 | 469 |
}; |
470 | 470 |
|
471 | 471 |
template <typename _Digraph> |
472 | 472 |
struct Constraints { |
473 | 473 |
void constraints() { |
474 |
checkConcept<BaseDigraphComponent, _Digraph>(); |
|
474 | 475 |
checkConcept<IterableDigraphComponent<>, _Digraph>(); |
475 | 476 |
checkConcept<IDableDigraphComponent<>, _Digraph>(); |
476 | 477 |
checkConcept<MappableDigraphComponent<>, _Digraph>(); |
477 | 478 |
} |
478 | 479 |
}; |
479 | 480 |
|
480 | 481 |
}; |
481 | 482 |
... | ... |
@@ -492,81 +492,81 @@ |
492 | 492 |
InArcIt(const Graph&, const Arc&) { } |
493 | 493 |
/// Next incoming arc |
494 | 494 |
|
495 | 495 |
/// Assign the iterator to the next inarc of the corresponding node. |
496 | 496 |
/// |
497 | 497 |
InArcIt& operator++() { return *this; } |
498 | 498 |
}; |
499 | 499 |
|
500 |
/// \brief |
|
500 |
/// \brief Reference map of the nodes to type \c T. |
|
501 | 501 |
/// |
502 |
/// ReadWrite map of the nodes to type \c T. |
|
503 |
/// \sa Reference |
|
502 |
/// Reference map of the nodes to type \c T. |
|
504 | 503 |
template<class T> |
505 |
class NodeMap : public |
|
504 |
class NodeMap : public ReferenceMap<Node, T, T&, const T&> |
|
506 | 505 |
{ |
507 | 506 |
public: |
508 | 507 |
|
509 | 508 |
///\e |
510 | 509 |
NodeMap(const Graph&) { } |
511 | 510 |
///\e |
512 | 511 |
NodeMap(const Graph&, T) { } |
513 | 512 |
|
514 | 513 |
private: |
515 | 514 |
///Copy constructor |
516 |
NodeMap(const NodeMap& nm) : |
|
515 |
NodeMap(const NodeMap& nm) : |
|
516 |
ReferenceMap<Node, T, T&, const T&>(nm) { } |
|
517 | 517 |
///Assignment operator |
518 | 518 |
template <typename CMap> |
519 | 519 |
NodeMap& operator=(const CMap&) { |
520 | 520 |
checkConcept<ReadMap<Node, T>, CMap>(); |
521 | 521 |
return *this; |
522 | 522 |
} |
523 | 523 |
}; |
524 | 524 |
|
525 |
/// \brief |
|
525 |
/// \brief Reference map of the arcs to type \c T. |
|
526 | 526 |
/// |
527 |
/// Reference map of the directed arcs to type \c T. |
|
528 |
/// \sa Reference |
|
527 |
/// Reference map of the arcs to type \c T. |
|
529 | 528 |
template<class T> |
530 |
class ArcMap : public |
|
529 |
class ArcMap : public ReferenceMap<Arc, T, T&, const T&> |
|
531 | 530 |
{ |
532 | 531 |
public: |
533 | 532 |
|
534 | 533 |
///\e |
535 | 534 |
ArcMap(const Graph&) { } |
536 | 535 |
///\e |
537 | 536 |
ArcMap(const Graph&, T) { } |
538 | 537 |
private: |
539 | 538 |
///Copy constructor |
540 |
ArcMap(const ArcMap& em) : |
|
539 |
ArcMap(const ArcMap& em) : |
|
540 |
ReferenceMap<Arc, T, T&, const T&>(em) { } |
|
541 | 541 |
///Assignment operator |
542 | 542 |
template <typename CMap> |
543 | 543 |
ArcMap& operator=(const CMap&) { |
544 | 544 |
checkConcept<ReadMap<Arc, T>, CMap>(); |
545 | 545 |
return *this; |
546 | 546 |
} |
547 | 547 |
}; |
548 | 548 |
|
549 |
/// |
|
549 |
/// Reference map of the edges to type \c T. |
|
550 | 550 |
|
551 |
/// Reference map of the arcs to type \c T. |
|
552 |
/// \sa Reference |
|
551 |
/// Reference map of the edges to type \c T. |
|
553 | 552 |
template<class T> |
554 |
class EdgeMap : public |
|
553 |
class EdgeMap : public ReferenceMap<Edge, T, T&, const T&> |
|
555 | 554 |
{ |
556 | 555 |
public: |
557 | 556 |
|
558 | 557 |
///\e |
559 | 558 |
EdgeMap(const Graph&) { } |
560 | 559 |
///\e |
561 | 560 |
EdgeMap(const Graph&, T) { } |
562 | 561 |
private: |
563 | 562 |
///Copy constructor |
564 |
EdgeMap(const EdgeMap& em) : |
|
563 |
EdgeMap(const EdgeMap& em) : |
|
564 |
ReferenceMap<Edge, T, T&, const T&>(em) {} |
|
565 | 565 |
///Assignment operator |
566 | 566 |
template <typename CMap> |
567 | 567 |
EdgeMap& operator=(const CMap&) { |
568 | 568 |
checkConcept<ReadMap<Edge, T>, CMap>(); |
569 | 569 |
return *this; |
570 | 570 |
} |
571 | 571 |
}; |
572 | 572 |
|
... | ... |
@@ -743,16 +743,17 @@ |
743 | 743 |
/// Returns the running node of the iterator |
744 | 744 |
Node runningNode(IncEdgeIt) const { |
745 | 745 |
return INVALID; |
746 | 746 |
} |
747 | 747 |
|
748 | 748 |
template <typename _Graph> |
749 | 749 |
struct Constraints { |
750 | 750 |
void constraints() { |
751 |
checkConcept<BaseGraphComponent, _Graph>(); |
|
751 | 752 |
checkConcept<IterableGraphComponent<>, _Graph>(); |
752 | 753 |
checkConcept<IDableGraphComponent<>, _Graph>(); |
753 | 754 |
checkConcept<MappableGraphComponent<>, _Graph>(); |
754 | 755 |
} |
755 | 756 |
}; |
756 | 757 |
|
757 | 758 |
}; |
758 | 759 |
... | ... |
@@ -983,28 +983,36 @@ |
983 | 983 |
}; |
984 | 984 |
}; |
985 | 985 |
|
986 | 986 |
/// \brief Concept class for standard graph maps. |
987 | 987 |
/// |
988 | 988 |
/// This class describes the concept of standard graph maps, i.e. |
989 | 989 |
/// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and |
990 | 990 |
/// graph types, which can be used for associating data to graph items. |
991 |
/// The standard graph maps must conform to the ReferenceMap concept. |
|
991 | 992 |
template <typename GR, typename K, typename V> |
992 |
class GraphMap : public |
|
993 |
class GraphMap : public ReferenceMap<K, V, V&, const V&> { |
|
993 | 994 |
public: |
994 | 995 |
|
995 | 996 |
typedef ReadWriteMap<K, V> Parent; |
996 | 997 |
|
997 | 998 |
/// The graph type of the map. |
998 | 999 |
typedef GR Graph; |
999 | 1000 |
/// The key type of the map. |
1000 | 1001 |
typedef K Key; |
1001 | 1002 |
/// The value type of the map. |
1002 | 1003 |
typedef V Value; |
1004 |
/// The reference type of the map. |
|
1005 |
typedef Value& Reference; |
|
1006 |
/// The const reference type of the map. |
|
1007 |
typedef const Value& ConstReference; |
|
1008 |
|
|
1009 |
// The reference map tag. |
|
1010 |
typedef True ReferenceMapTag; |
|
1003 | 1011 |
|
1004 | 1012 |
/// \brief Construct a new map. |
1005 | 1013 |
/// |
1006 | 1014 |
/// Construct a new map for the graph. |
1007 | 1015 |
explicit GraphMap(const Graph&) {} |
1008 | 1016 |
/// \brief Construct a new map with default value. |
1009 | 1017 |
/// |
1010 | 1018 |
/// Construct a new map for the graph and initalize the values. |
... | ... |
@@ -1026,17 +1034,18 @@ |
1026 | 1034 |
checkConcept<ReadMap<Key, Value>, CMap>(); |
1027 | 1035 |
return *this; |
1028 | 1036 |
} |
1029 | 1037 |
|
1030 | 1038 |
public: |
1031 | 1039 |
template<typename _Map> |
1032 | 1040 |
struct Constraints { |
1033 | 1041 |
void constraints() { |
1034 |
checkConcept |
|
1042 |
checkConcept |
|
1043 |
<ReferenceMap<Key, Value, Value&, const Value&>, _Map>(); |
|
1035 | 1044 |
_Map m1(g); |
1036 | 1045 |
_Map m2(g,t); |
1037 | 1046 |
|
1038 | 1047 |
// Copy constructor |
1039 | 1048 |
// _Map m3(m); |
1040 | 1049 |
|
1041 | 1050 |
// Assignment operator |
1042 | 1051 |
// ReadMap<Key, Value> cmap; |
... | ... |
@@ -1068,16 +1077,17 @@ |
1068 | 1077 |
typedef typename Base::Node Node; |
1069 | 1078 |
typedef typename Base::Arc Arc; |
1070 | 1079 |
|
1071 | 1080 |
typedef MappableDigraphComponent Digraph; |
1072 | 1081 |
|
1073 | 1082 |
/// \brief Standard graph map for the nodes. |
1074 | 1083 |
/// |
1075 | 1084 |
/// Standard graph map for the nodes. |
1085 |
/// It conforms to the ReferenceMap concept. |
|
1076 | 1086 |
template <typename V> |
1077 | 1087 |
class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> { |
1078 | 1088 |
public: |
1079 | 1089 |
typedef GraphMap<MappableDigraphComponent, Node, V> Parent; |
1080 | 1090 |
|
1081 | 1091 |
/// \brief Construct a new map. |
1082 | 1092 |
/// |
1083 | 1093 |
/// Construct a new map for the digraph. |
... | ... |
@@ -1105,16 +1115,17 @@ |
1105 | 1115 |
return *this; |
1106 | 1116 |
} |
1107 | 1117 |
|
1108 | 1118 |
}; |
1109 | 1119 |
|
1110 | 1120 |
/// \brief Standard graph map for the arcs. |
1111 | 1121 |
/// |
1112 | 1122 |
/// Standard graph map for the arcs. |
1123 |
/// It conforms to the ReferenceMap concept. |
|
1113 | 1124 |
template <typename V> |
1114 | 1125 |
class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> { |
1115 | 1126 |
public: |
1116 | 1127 |
typedef GraphMap<MappableDigraphComponent, Arc, V> Parent; |
1117 | 1128 |
|
1118 | 1129 |
/// \brief Construct a new map. |
1119 | 1130 |
/// |
1120 | 1131 |
/// Construct a new map for the digraph. |
... | ... |
@@ -1202,16 +1213,17 @@ |
1202 | 1213 |
typedef BAS Base; |
1203 | 1214 |
typedef typename Base::Edge Edge; |
1204 | 1215 |
|
1205 | 1216 |
typedef MappableGraphComponent Graph; |
1206 | 1217 |
|
1207 | 1218 |
/// \brief Standard graph map for the edges. |
1208 | 1219 |
/// |
1209 | 1220 |
/// Standard graph map for the edges. |
1221 |
/// It conforms to the ReferenceMap concept. |
|
1210 | 1222 |
template <typename V> |
1211 | 1223 |
class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> { |
1212 | 1224 |
public: |
1213 | 1225 |
typedef GraphMap<MappableGraphComponent, Edge, V> Parent; |
1214 | 1226 |
|
1215 | 1227 |
/// \brief Construct a new map. |
1216 | 1228 |
/// |
1217 | 1229 |
/// Construct a new map for the graph. |
0 comments (0 inline)