Changeset 2031:080d51024ac5 in lemon-0.x for lemon/bits/graph_extender.h
- Timestamp:
- 04/03/06 11:45:23 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2670
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bits/graph_extender.h
r1999 r2031 104 104 105 105 explicit NodeIt(const Graph& _graph) : graph(&_graph) { 106 _graph.first( *static_cast<Node*>(this));106 _graph.first(static_cast<Node&>(*this)); 107 107 } 108 108 … … 127 127 128 128 explicit EdgeIt(const Graph& _graph) : graph(&_graph) { 129 _graph.first( *static_cast<Edge*>(this));129 _graph.first(static_cast<Edge&>(*this)); 130 130 } 131 131 … … 233 233 } 234 234 235 236 /// \brief Template assign operator.237 ///238 /// The given parameter should be conform to the ReadMap239 /// concecpt and could be indiced by the current item set of240 /// the NodeMap. In this case the value for each item241 /// is assigned by the value of the given ReadMap.242 235 template <typename CMap> 243 236 NodeMap& operator=(const CMap& cmap) { 244 checkConcept<concept::ReadMap<Node, _Value>, CMap>(); 245 const typename Parent::Notifier* notifier = Parent::getNotifier(); 246 Node it; 247 for (notifier->first(it); it != INVALID; notifier->next(it)) { 248 Parent::set(it, cmap[it]); 249 } 237 Parent::operator=(cmap); 250 238 return *this; 251 239 } … … 271 259 template <typename CMap> 272 260 EdgeMap& operator=(const CMap& cmap) { 273 checkConcept<concept::ReadMap<Edge, _Value>, CMap>(); 274 const typename Parent::Notifier* notifier = Parent::getNotifier(); 275 Edge it; 276 for (notifier->first(it); it != INVALID; notifier->next(it)) { 277 Parent::set(it, cmap[it]); 278 } 261 Parent::operator=(cmap); 279 262 return *this; 280 263 } … … 432 415 433 416 explicit NodeIt(const Graph& _graph) : graph(&_graph) { 434 _graph.first( *static_cast<Node*>(this));417 _graph.first(static_cast<Node&>(*this)); 435 418 } 436 419 … … 455 438 456 439 explicit EdgeIt(const Graph& _graph) : graph(&_graph) { 457 _graph.first( *static_cast<Edge*>(this));440 _graph.first(static_cast<Edge&>(*this)); 458 441 } 459 442 … … 526 509 527 510 explicit UEdgeIt(const Graph& _graph) : graph(&_graph) { 528 _graph.first( *static_cast<UEdge*>(this));511 _graph.first(static_cast<UEdge&>(*this)); 529 512 } 530 513 … … 623 606 } 624 607 625 626 /// \brief Template assign operator.627 ///628 /// The given parameter should be conform to the ReadMap629 /// concecpt and could be indiced by the current item set of630 /// the NodeMap. In this case the value for each item631 /// is assigned by the value of the given ReadMap.632 608 template <typename CMap> 633 609 NodeMap& operator=(const CMap& cmap) { 634 checkConcept<concept::ReadMap<Node, _Value>, CMap>(); 635 const typename Parent::Notifier* notifier = Parent::getNotifier(); 636 Node it; 637 for (notifier->first(it); it != INVALID; notifier->next(it)) { 638 Parent::set(it, cmap[it]); 639 } 610 Parent::operator=(cmap); 640 611 return *this; 641 612 } … … 661 632 template <typename CMap> 662 633 EdgeMap& operator=(const CMap& cmap) { 663 checkConcept<concept::ReadMap<Edge, _Value>, CMap>(); 664 const typename Parent::Notifier* notifier = Parent::getNotifier(); 665 Edge it; 666 for (notifier->first(it); it != INVALID; notifier->next(it)) { 667 Parent::set(it, cmap[it]); 668 } 634 Parent::operator=(cmap); 669 635 return *this; 670 636 } … … 681 647 UEdgeMap(const Graph& graph) 682 648 : Parent(graph) {} 649 683 650 UEdgeMap(const Graph& graph, const _Value& value) 684 651 : Parent(graph, value) {} … … 690 657 template <typename CMap> 691 658 UEdgeMap& operator=(const CMap& cmap) { 692 checkConcept<concept::ReadMap<UEdge, _Value>, CMap>(); 693 const typename Parent::Notifier* notifier = Parent::getNotifier(); 694 Edge it; 695 for (notifier->first(it); it != INVALID; notifier->next(it)) { 696 Parent::set(it, cmap[it]); 697 } 659 Parent::operator=(cmap); 698 660 return *this; 699 661 } 662 700 663 }; 701 664 … … 1105 1068 } 1106 1069 1107 1108 /// \brief Template assign operator.1109 ///1110 /// The given parameter should be conform to the ReadMap1111 /// concept and could be indiced by the current item set of1112 /// the ANodeMap. In this case the value for each item1113 /// is assigned by the value of the given ReadMap.1114 1070 template <typename CMap> 1115 1071 ANodeMap& operator=(const CMap& cmap) { 1116 checkConcept<concept::ReadMap<ANode, _Value>, CMap>(); 1117 const typename Parent::Graph* graph = Parent::getGraph(); 1118 ANode it; 1119 for (graph->first(it); it != INVALID; graph->next(it)) { 1120 Parent::set(it, cmap[it]); 1121 } 1072 Parent::operator=(cmap); 1122 1073 return *this; 1123 1074 } … … 1141 1092 } 1142 1093 1143 1144 /// \brief Template assign operator.1145 ///1146 /// The given parameter should be conform to the ReadMap1147 /// concept and could be indiced by the current item set of1148 /// the BNodeMap. In this case the value for each item1149 /// is assigned by the value of the given ReadMap.1150 1094 template <typename CMap> 1151 1095 BNodeMap& operator=(const CMap& cmap) { 1152 checkConcept<concept::ReadMap<BNode, _Value>, CMap>(); 1153 const typename Parent::Graph* graph = Parent::getGraph(); 1154 BNode it; 1155 for (graph->first(it); it != INVALID; graph->next(it)) { 1156 Parent::set(it, cmap[it]); 1157 } 1096 Parent::operator=(cmap); 1158 1097 return *this; 1159 1098 } … … 1161 1100 }; 1162 1101 1163 p rotected:1102 public: 1164 1103 1165 1104 template <typename _Value> 1166 class NodeMap Base{1105 class NodeMap { 1167 1106 public: 1168 1107 typedef BpUGraphExtender Graph; … … 1178 1117 typedef True ReferenceMapTag; 1179 1118 1180 NodeMapBase(const Graph& graph) 1181 : aNodeMap(graph), bNodeMap(graph) {} 1182 NodeMapBase(const Graph& graph, const _Value& value) 1183 : aNodeMap(graph, value), bNodeMap(graph, value) {} 1119 NodeMap(const Graph& _graph) 1120 : graph(_graph), aNodeMap(_graph), bNodeMap(_graph) {} 1121 NodeMap(const Graph& _graph, const _Value& _value) 1122 : graph(_graph), aNodeMap(_graph, _value), bNodeMap(_graph, _value) {} 1123 1124 NodeMap& operator=(const NodeMap& cmap) { 1125 return operator=<NodeMap>(cmap); 1126 } 1127 1128 template <typename CMap> 1129 NodeMap& operator=(const CMap& cmap) { 1130 checkConcept<concept::ReadMap<Node, _Value>, CMap>(); 1131 const typename Parent::Notifier* notifier = Parent::getNotifier(); 1132 Edge it; 1133 for (graph.first(it); it != INVALID; graph.next(it)) { 1134 Parent::set(it, cmap[it]); 1135 } 1136 return *this; 1137 } 1184 1138 1185 1139 ConstReference operator[](const Key& node) const { … … 1207 1161 } 1208 1162 1209 const Graph* getGraph() const { 1210 return aNodeMap.getGraph(); 1211 } 1212 1163 class MapIt : public NodeIt { 1164 public: 1165 1166 typedef NodeIt Parent; 1167 1168 explicit MapIt(NodeMap& _map) 1169 : Parent(_map.graph), map(_map) {} 1170 1171 typename MapTraits<NodeMap>::ConstReturnValue operator*() const { 1172 return map[*this]; 1173 } 1174 1175 typename MapTraits<NodeMap>::ReturnValue operator*() { 1176 return map[*this]; 1177 } 1178 1179 void set(const Value& value) { 1180 map.set(*this, value); 1181 } 1182 1183 private: 1184 NodeMap& map; 1185 }; 1186 1187 class ConstMapIt : public NodeIt { 1188 public: 1189 1190 typedef NodeIt Parent; 1191 1192 explicit ConstMapIt(const NodeMap& _map) 1193 : Parent(_map.graph), map(_map) {} 1194 1195 typename MapTraits<NodeMap>::ConstReturnValue operator*() const { 1196 return map[*this]; 1197 } 1198 1199 private: 1200 const NodeMap& map; 1201 }; 1202 1203 class ItemIt : public NodeIt { 1204 public: 1205 1206 typedef NodeIt Parent; 1207 1208 explicit ItemIt(const NodeMap& _map) 1209 : Parent(_map.graph) {} 1210 1211 }; 1212 1213 1213 private: 1214 const Graph& graph; 1214 1215 ANodeMap<_Value> aNodeMap; 1215 1216 BNodeMap<_Value> bNodeMap; 1216 1217 }; 1217 1218 1218 public:1219 1220 template <typename _Value>1221 class NodeMap1222 : public MapExtender<NodeMapBase<_Value> > {1223 public:1224 typedef BpUGraphExtender Graph;1225 typedef MapExtender< NodeMapBase<_Value> > Parent;1226 1227 NodeMap(const Graph& graph)1228 : Parent(graph) {}1229 NodeMap(const Graph& graph, const _Value& value)1230 : Parent(graph, value) {}1231 1232 NodeMap& operator=(const NodeMap& cmap) {1233 return operator=<NodeMap>(cmap);1234 }1235 1236 1237 /// \brief Template assign operator.1238 ///1239 /// The given parameter should be conform to the ReadMap1240 /// concept and could be indiced by the current item set of1241 /// the NodeMap. In this case the value for each item1242 /// is assigned by the value of the given ReadMap.1243 template <typename CMap>1244 NodeMap& operator=(const CMap& cmap) {1245 checkConcept<concept::ReadMap<Node, _Value>, CMap>();1246 const typename Parent::Notifier* notifier = Parent::getNotifier();1247 Edge it;1248 for (notifier->first(it); it != INVALID; notifier->next(it)) {1249 Parent::set(it, cmap[it]);1250 }1251 return *this;1252 }1253 1254 };1255 1256 1257 1219 1258 1220 template <typename _Value> … … 1274 1236 template <typename CMap> 1275 1237 EdgeMap& operator=(const CMap& cmap) { 1276 checkConcept<concept::ReadMap<Edge, _Value>, CMap>(); 1277 const typename Parent::Notifier* notifier = Parent::getNotifier(); 1278 Edge it; 1279 for (notifier->first(it); it != INVALID; notifier->next(it)) { 1280 Parent::set(it, cmap[it]); 1281 } 1238 Parent::operator=(cmap); 1282 1239 return *this; 1283 1240 } … … 1302 1259 template <typename CMap> 1303 1260 UEdgeMap& operator=(const CMap& cmap) { 1304 checkConcept<concept::ReadMap<UEdge, _Value>, CMap>(); 1305 const typename Parent::Notifier* notifier = Parent::getNotifier(); 1306 Edge it; 1307 for (notifier->first(it); it != INVALID; notifier->next(it)) { 1308 Parent::set(it, cmap[it]); 1309 } 1261 Parent::operator=(cmap); 1310 1262 return *this; 1311 1263 }
Note: See TracChangeset
for help on using the changeset viewer.