Changeset 980:0f1044b7a3af in lemon-0.x
- Timestamp:
- 11/11/04 10:31:55 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1368
- Location:
- src
- Files:
-
- 2 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
src/lemon/Makefile.am
r977 r980 1 1 pkginclude_HEADERS = \ 2 map_defines.h \ 2 3 array_map.h \ 3 4 bfs.h \ … … 7 8 dijkstra.h \ 8 9 dimacs.h \ 9 extended_pair.h \10 10 fib_heap.h \ 11 11 full_graph.h \ … … 15 15 kruskal.h \ 16 16 list_graph.h \ 17 map_iterator.h \18 17 alteration_observer_registry.h \ 19 18 maps.h \ … … 28 27 xy.h \ 29 28 concept_check.h \ 30 map_defines.h \31 map_bits.h \32 29 utility.h \ 33 30 iterable_graph_extender.h \ 34 idmappable_graph_extender.h \35 31 extendable_graph_extender.h \ 36 32 clearable_graph_extender.h \ -
src/lemon/alteration_observer_registry.h
r978 r980 322 322 public: 323 323 324 EdgeObserverRegistry& get EdgeObserverRegistry() const {324 EdgeObserverRegistry& getObserverRegistry(Edge = INVALID) const { 325 325 return edge_observers; 326 326 } 327 327 328 NodeObserverRegistry& get NodeObserverRegistry() const {328 NodeObserverRegistry& getObserverRegistry(Node = INVALID) const { 329 329 return node_observers; 330 330 } … … 365 365 mutable UndirEdgeObserverRegistry undir_edge_observers; 366 366 367 UndirEdgeObserverRegistry& get UndirEdgeObserverRegistry() const {367 UndirEdgeObserverRegistry& getObserverRegistry(UndirEdge = INVALID) const { 368 368 return undir_edge_observers; 369 369 } -
src/lemon/array_map.h
r979 r980 45 45 typename _Item, 46 46 typename _ItemIt, 47 typename _IdMap,48 47 typename _Value> 49 48 class ArrayMap : public AlterationObserverRegistry<_Item>::ObserverBase { … … 61 60 /// The iterator to iterate on the keys. 62 61 typedef _ItemIt KeyIt; 63 64 typedef _IdMap IdMap;65 62 66 63 typedef _Value Value; … … 95 92 /** Graph and Registry initialized map constructor. 96 93 */ 97 ArrayMap(const Graph& _g , Registry& _r) : graph(&_g) {98 attach(_ r);94 ArrayMap(const Graph& _g) : graph(&_g) { 95 attach(_g.getObserverRegistry(_Item())); 99 96 allocate_memory(); 100 97 for (KeyIt it(*graph); it != INVALID; ++it) { 101 int id = IdMap(*graph)[it];98 int id = graph->id(it);; 102 99 allocator.construct(&(values[id]), Value()); 103 100 } … … 108 105 /// It constrates a map and initialize all of the the map. 109 106 110 ArrayMap(const Graph& _g, Registry& _r,const Value& _v) : graph(&_g) {111 attach(_ r);107 ArrayMap(const Graph& _g, const Value& _v) : graph(&_g) { 108 attach(_g.getObserverRegistry(_Item())); 112 109 allocate_memory(); 113 110 for (KeyIt it(*graph); it != INVALID; ++it) { 114 int id = IdMap(*graph)[it];111 int id = graph->id(it);; 115 112 allocator.construct(&(values[id]), _v); 116 113 } … … 127 124 values = allocator.allocate(capacity); 128 125 for (KeyIt it(*graph); it != INVALID; ++it) { 129 int id = IdMap(*graph)[it];126 int id = graph->id(it);; 130 127 allocator.construct(&(values[id]), copy.values[id]); 131 128 } … … 155 152 156 153 for (KeyIt it(*graph); it != INVALID; ++it) { 157 int id = IdMap(*graph)[it];154 int id = graph->id(it);; 158 155 allocator.construct(&(values[id]), copy.values[id]); 159 156 } … … 177 174 */ 178 175 ReferenceType operator[](const KeyType& key) { 179 int id = IdMap(*graph)[key];176 int id = graph->id(key); 180 177 return values[id]; 181 178 } … … 186 183 */ 187 184 ConstReferenceType operator[](const KeyType& key) const { 188 int id = IdMap(*graph)[key];185 int id = graph->id(key); 189 186 return values[id]; 190 187 } … … 200 197 */ 201 198 void add(const KeyType& key) { 202 int id = IdMap(*graph)[key];199 int id = graph->id(key); 203 200 if (id >= capacity) { 204 201 int new_capacity = (capacity == 0 ? 1 : capacity); … … 208 205 Value* new_values = allocator.allocate(new_capacity); 209 206 for (KeyIt it(*graph); it != INVALID; ++it) { 210 int jd = IdMap(*graph)[it];207 int jd = graph->id(it);; 211 208 if (id != jd) { 212 209 allocator.construct(&(new_values[jd]), values[jd]); … … 224 221 */ 225 222 void erase(const KeyType& key) { 226 int id = IdMap(*graph)[key];223 int id = graph->id(key); 227 224 allocator.destroy(&(values[id])); 228 225 } … … 231 228 allocate_memory(); 232 229 for (KeyIt it(*graph); it != INVALID; ++it) { 233 int id = IdMap(*graph)[it];230 int id = graph->id(it);; 234 231 allocator.construct(&(values[id]), Value()); 235 232 } … … 239 236 if (capacity != 0) { 240 237 for (KeyIt it(*graph); it != INVALID; ++it) { 241 int id = IdMap(*graph)[it];238 int id = graph->id(it);; 242 239 allocator.destroy(&(values[id])); 243 240 } … … 303 300 304 301 void allocate_memory() { 305 int max_id = IdMap(*graph).maxId();302 int max_id = graph->maxId(_Item()); 306 303 if (max_id == -1) { 307 304 capacity = 0; … … 344 341 typedef typename Parent::Node Node; 345 342 typedef typename Parent::NodeIt NodeIt; 346 typedef typename Parent::NodeIdMap NodeIdMap;347 343 typedef typename Parent::NodeObserverRegistry NodeObserverRegistry; 348 344 349 345 typedef typename Parent::Edge Edge; 350 346 typedef typename Parent::EdgeIt EdgeIt; 351 typedef typename Parent::EdgeIdMap EdgeIdMap;352 347 typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry; 353 348 … … 355 350 356 351 template <typename _Value> 357 class NodeMap : public ArrayMap<Graph, Node, NodeIt, NodeIdMap,_Value> {352 class NodeMap : public ArrayMap<Graph, Node, NodeIt, _Value> { 358 353 public: 359 354 typedef ArrayMappableGraphExtender<_Base> Graph; … … 361 356 typedef typename Graph::Node Node; 362 357 typedef typename Graph::NodeIt NodeIt; 363 typedef typename Graph::NodeIdMap NodeIdMap; 364 365 typedef ArrayMap<Graph, Node, NodeIt, NodeIdMap, _Value> Parent; 358 359 typedef ArrayMap<Graph, Node, NodeIt, _Value> Parent; 366 360 367 361 //typedef typename Parent::Graph Graph; … … 369 363 370 364 NodeMap(const Graph& g) 371 : Parent(g , g.getNodeObserverRegistry()) {}365 : Parent(g) {} 372 366 NodeMap(const Graph& g, const Value& v) 373 : Parent(g, g.getNodeObserverRegistry(),v) {}367 : Parent(g, v) {} 374 368 375 369 }; 376 370 377 371 template <typename _Value> 378 class EdgeMap : public ArrayMap<Graph, Edge, EdgeIt, EdgeIdMap,_Value> {372 class EdgeMap : public ArrayMap<Graph, Edge, EdgeIt, _Value> { 379 373 public: 380 374 typedef ArrayMappableGraphExtender<_Base> Graph; … … 382 376 typedef typename Graph::Edge Edge; 383 377 typedef typename Graph::EdgeIt EdgeIt; 384 typedef typename Graph::EdgeIdMap EdgeIdMap; 385 386 typedef ArrayMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> Parent; 378 379 typedef ArrayMap<Graph, Edge, EdgeIt, _Value> Parent; 387 380 388 381 //typedef typename Parent::Graph Graph; … … 390 383 391 384 EdgeMap(const Graph& g) 392 : Parent(g , g.getEdgeObserverRegistry()) {}385 : Parent(g) {} 393 386 EdgeMap(const Graph& g, const Value& v) 394 : Parent(g, g.getEdgeObserverRegistry(),v) {}387 : Parent(g, v) {} 395 388 396 389 }; -
src/lemon/clearable_graph_extender.h
r946 r980 15 15 typedef ClearableGraphExtender Graph; 16 16 typedef _Base Parent; 17 typedef typename Parent::Node Node; 18 typedef typename Parent::Edge Edge; 17 19 18 20 void clear() { 19 Parent::get NodeObserverRegistry().clear();20 Parent::get EdgeObserverRegistry().clear();21 Parent::getObserverRegistry(Node()).clear(); 22 Parent::getObserverRegistry(Edge()).clear(); 21 23 Parent::clear(); 22 24 } -
src/lemon/concept/graph_component.h
r964 r980 162 162 163 163 164 /// Assign operator for nodes. 165 166 /// The nodes are assignable. 167 /// 164 168 Node& operator=(const Node&) { return *this;} 165 169 … … 211 215 Edge(Invalid) {} 212 216 213 217 /// Assign operator for edges. 218 219 /// The edges are assignable. 220 /// 214 221 Edge& operator=(const Edge&) { return *this;} 215 222 … … 430 437 /// Gives back an integer greater or equal to the maximum Node id. 431 438 /// 432 int max EdgeId() const { return -1;}439 int maxId(Node = INVALID) const { return -1;} 433 440 434 441 /// Gives back an integer greater or equal to the maximum Edge id. … … 436 443 /// Gives back an integer greater or equal to the maximum Edge id. 437 444 /// 438 int max NodeId() const { return -1;}445 int maxId(Edge = INVALID) const { return -1;} 439 446 }; 440 447 … … 448 455 void constraints() { 449 456 function_requires< BaseGraphComponentConcept<Graph> >(); 450 int nid = graph.max EdgeId();457 int nid = graph.maxId(typename Graph::Node()); 451 458 ignore_unused_variable_warning(nid); 452 int eid = graph.max NodeId();459 int eid = graph.maxId(typename Graph::Edge()); 453 460 ignore_unused_variable_warning(eid); 454 461 } … … 663 670 664 671 665 class IdMappableGraphComponent : virtual public BaseGraphComponent {666 667 typedef IdMappableGraphComponent Graph;668 669 public:670 671 typedef BaseGraphComponent::Node Node;672 typedef BaseGraphComponent::Edge Edge;673 674 class NodeIdMap : public ReadMap<Node, int> {675 public:676 NodeIdMap(const Graph&) {}677 int maxId() const { return -1;}678 };679 680 class EdgeIdMap : public ReadMap<Edge, int> {681 public:682 EdgeIdMap(const Graph&) {}683 int maxId() const { return -1;}684 };685 686 };687 688 template <typename Graph>689 struct IdMappableGraphComponentConcept {690 void constraints() {691 function_requires< BaseGraphComponentConcept<Graph> >();692 {693 typedef typename Graph::EdgeIdMap EdgeIdMap;694 function_requires<ReadMapConcept<EdgeIdMap> >();695 EdgeIdMap edge_map(graph);696 int n = edge_map.maxId();697 ignore_unused_variable_warning(n);698 }699 {700 typedef typename Graph::NodeIdMap NodeIdMap;701 function_requires<ReadMapConcept<NodeIdMap> >();702 NodeIdMap node_map(graph);703 int n = node_map.maxId();704 ignore_unused_variable_warning(n);705 }706 }707 Graph& graph;708 };709 710 711 672 class MappableGraphComponent : virtual public BaseGraphComponent { 712 673 public: -
src/lemon/default_map.h
r979 r980 43 43 44 44 45 template <typename _Graph, typename _Item, typename _ItemIt, typename _ IdMap, typename _Value>45 template <typename _Graph, typename _Item, typename _ItemIt, typename _Value> 46 46 struct DefaultMapSelector { 47 typedef ArrayMap<_Graph, _Item, _ItemIt, _ IdMap, _Value> Map;47 typedef ArrayMap<_Graph, _Item, _ItemIt, _Value> Map; 48 48 }; 49 49 50 50 // bool 51 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>52 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,bool> {53 typedef VectorMap<_Graph, _Item, _IdMap,bool> Map;51 template <typename _Graph, typename _Item, typename _ItemIt> 52 struct DefaultMapSelector<_Graph, _Item, _ItemIt, bool> { 53 typedef VectorMap<_Graph, _Item, bool> Map; 54 54 }; 55 55 56 56 // char 57 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>58 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,char> {59 typedef VectorMap<_Graph, _Item, _IdMap,char> Map;60 }; 61 62 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>63 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,signed char> {64 typedef VectorMap<_Graph, _Item, _IdMap,signed char> Map;65 }; 66 67 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>68 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,unsigned char> {69 typedef VectorMap<_Graph, _Item, _IdMap,unsigned char> Map;57 template <typename _Graph, typename _Item, typename _ItemIt> 58 struct DefaultMapSelector<_Graph, _Item, _ItemIt, char> { 59 typedef VectorMap<_Graph, _Item, char> Map; 60 }; 61 62 template <typename _Graph, typename _Item, typename _ItemIt> 63 struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed char> { 64 typedef VectorMap<_Graph, _Item, signed char> Map; 65 }; 66 67 template <typename _Graph, typename _Item, typename _ItemIt> 68 struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned char> { 69 typedef VectorMap<_Graph, _Item, unsigned char> Map; 70 70 }; 71 71 72 72 73 73 // int 74 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>75 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,signed int> {76 typedef VectorMap<_Graph, _Item, _IdMap,signed int> Map;77 }; 78 79 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>80 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,unsigned int> {81 typedef VectorMap<_Graph, _Item, _IdMap,unsigned int> Map;74 template <typename _Graph, typename _Item, typename _ItemIt> 75 struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed int> { 76 typedef VectorMap<_Graph, _Item, signed int> Map; 77 }; 78 79 template <typename _Graph, typename _Item, typename _ItemIt> 80 struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned int> { 81 typedef VectorMap<_Graph, _Item, unsigned int> Map; 82 82 }; 83 83 84 84 85 85 // short 86 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>87 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,signed short> {88 typedef VectorMap<_Graph, _Item, _IdMap,signed short> Map;89 }; 90 91 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>92 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,unsigned short> {93 typedef VectorMap<_Graph, _Item, _IdMap,unsigned short> Map;86 template <typename _Graph, typename _Item, typename _ItemIt> 87 struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed short> { 88 typedef VectorMap<_Graph, _Item, signed short> Map; 89 }; 90 91 template <typename _Graph, typename _Item, typename _ItemIt> 92 struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned short> { 93 typedef VectorMap<_Graph, _Item, unsigned short> Map; 94 94 }; 95 95 96 96 97 97 // long 98 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>99 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,signed long> {100 typedef VectorMap<_Graph, _Item, _IdMap,signed long> Map;101 }; 102 103 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>104 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,unsigned long> {105 typedef VectorMap<_Graph, _Item, _IdMap,unsigned long> Map;98 template <typename _Graph, typename _Item, typename _ItemIt> 99 struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed long> { 100 typedef VectorMap<_Graph, _Item, signed long> Map; 101 }; 102 103 template <typename _Graph, typename _Item, typename _ItemIt> 104 struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned long> { 105 typedef VectorMap<_Graph, _Item, unsigned long> Map; 106 106 }; 107 107 … … 110 110 111 111 // float 112 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>113 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,float> {114 typedef VectorMap<_Graph, _Item, _IdMap,float> Map;112 template <typename _Graph, typename _Item, typename _ItemIt> 113 struct DefaultMapSelector<_Graph, _Item, _ItemIt, float> { 114 typedef VectorMap<_Graph, _Item, float> Map; 115 115 }; 116 116 117 117 118 118 // double 119 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>120 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,double> {121 typedef VectorMap<_Graph, _Item, _IdMap,double> Map;119 template <typename _Graph, typename _Item, typename _ItemIt> 120 struct DefaultMapSelector<_Graph, _Item, _ItemIt, double> { 121 typedef VectorMap<_Graph, _Item, double> Map; 122 122 }; 123 123 124 124 125 125 // long double 126 template <typename _Graph, typename _Item, typename _ItemIt , typename _IdMap>127 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap,long double> {128 typedef VectorMap<_Graph, _Item, _IdMap,long double> Map;126 template <typename _Graph, typename _Item, typename _ItemIt> 127 struct DefaultMapSelector<_Graph, _Item, _ItemIt, long double> { 128 typedef VectorMap<_Graph, _Item, long double> Map; 129 129 }; 130 130 131 131 132 132 // pointer 133 template <typename _Graph, typename _Item, typename _ItemIt, typename _ IdMap, typename _Ptr>134 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _ IdMap, _Ptr*> {135 typedef VectorMap<_Graph, _Item, _ IdMap, _Ptr*> Map;133 template <typename _Graph, typename _Item, typename _ItemIt, typename _Ptr> 134 struct DefaultMapSelector<_Graph, _Item, _ItemIt, _Ptr*> { 135 typedef VectorMap<_Graph, _Item, _Ptr*> Map; 136 136 }; 137 137 … … 141 141 typename _Item, 142 142 typename _ItemIt, 143 typename _IdMap,144 143 typename _Value> 145 class DefaultMap : public DefaultMapSelector<_Graph, _Item, _ItemIt, _ IdMap, _Value>::Map {144 class DefaultMap : public DefaultMapSelector<_Graph, _Item, _ItemIt, _Value>::Map { 146 145 public: 147 typedef typename DefaultMapSelector<_Graph, _Item, _ItemIt, _ IdMap, _Value>::Map Parent;148 typedef DefaultMap<_Graph, _Item, _ItemIt, _ IdMap, bool> Map;146 typedef typename DefaultMapSelector<_Graph, _Item, _ItemIt, _Value>::Map Parent; 147 typedef DefaultMap<_Graph, _Item, _ItemIt, _Value> Map; 149 148 150 149 typedef typename Parent::Graph Graph; 151 typedef typename Parent::Registry Registry;152 150 typedef typename Parent::ValueType ValueType; 153 151 154 DefaultMap(const Graph& _g , Registry& _r) : Parent(_g, _r) {}155 DefaultMap(const Graph& _g, Registry& _r, const ValueType& _v) : Parent(_g, _r, _v) {}152 DefaultMap(const Graph& _g) : Parent(_g) {} 153 DefaultMap(const Graph& _g, const ValueType& _v) : Parent(_g, _v) {} 156 154 }; 157 155 … … 167 165 typedef typename Parent::Node Node; 168 166 typedef typename Parent::NodeIt NodeIt; 169 typedef typename Parent::NodeIdMap NodeIdMap;170 typedef typename Parent::NodeObserverRegistry NodeObserverRegistry;171 167 172 168 typedef typename Parent::Edge Edge; 173 169 typedef typename Parent::EdgeIt EdgeIt; 174 typedef typename Parent::EdgeIdMap EdgeIdMap;175 typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry;176 170 177 171 178 179 172 template <typename _Value> 180 class NodeMap : public DefaultMap<Graph, Node, NodeIt, NodeIdMap,_Value> {173 class NodeMap : public DefaultMap<Graph, Node, NodeIt, _Value> { 181 174 public: 182 175 typedef DefaultMappableGraphExtender<_Base> Graph; … … 184 177 typedef typename Graph::Node Node; 185 178 typedef typename Graph::NodeIt NodeIt; 186 typedef typename Graph::NodeIdMap NodeIdMap; 187 188 typedef DefaultMap<Graph, Node, NodeIt, NodeIdMap, _Value> Parent; 179 180 typedef DefaultMap<Graph, Node, NodeIt, _Value> Parent; 189 181 190 182 //typedef typename Parent::Graph Graph; 191 183 typedef typename Parent::ValueType ValueType; 192 184 193 NodeMap(const Graph& g)194 : Parent( g, g.getNodeObserverRegistry()) {}195 NodeMap(const Graph& g, const ValueType&v)196 : Parent( g, g.getNodeObserverRegistry(),v) {}185 NodeMap(const Graph& _g) 186 : Parent(_g) {} 187 NodeMap(const Graph& _g, const ValueType& _v) 188 : Parent(_g, _v) {} 197 189 198 190 }; 199 191 200 192 template <typename _Value> 201 class EdgeMap : public DefaultMap<Graph, Edge, EdgeIt, EdgeIdMap,_Value> {193 class EdgeMap : public DefaultMap<Graph, Edge, EdgeIt, _Value> { 202 194 public: 203 195 typedef DefaultMappableGraphExtender<_Base> Graph; … … 205 197 typedef typename Graph::Edge Edge; 206 198 typedef typename Graph::EdgeIt EdgeIt; 207 typedef typename Graph::EdgeIdMap EdgeIdMap; 208 209 typedef DefaultMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> Parent; 199 200 typedef DefaultMap<Graph, Edge, EdgeIt, _Value> Parent; 210 201 211 202 //typedef typename Parent::Graph Graph; 212 203 typedef typename Parent::ValueType ValueType; 213 204 214 EdgeMap(const Graph& g)215 : Parent( g, g.getEdgeObserverRegistry()) {}216 EdgeMap(const Graph& g, const ValueType&v)217 : Parent( g, g.getEdgeObserverRegistry(),v) {}205 EdgeMap(const Graph& _g) 206 : Parent(_g) {} 207 EdgeMap(const Graph& _g, const ValueType& _v) 208 : Parent(_g, _v) {} 218 209 219 210 }; -
src/lemon/erasable_graph_extender.h
r946 r980 33 33 } 34 34 35 Parent::get NodeObserverRegistry().erase(node);35 Parent::getObserverRegistry(Node()).erase(node); 36 36 Parent::erase(node); 37 37 } 38 38 39 39 void erase(const Edge& edge) { 40 Parent::get EdgeObserverRegistry().erase(edge);40 Parent::getObserverRegistry(Edge()).erase(edge); 41 41 Parent::erase(edge); 42 42 } -
src/lemon/extendable_graph_extender.h
r946 r980 18 18 Node addNode() { 19 19 Node node = Parent::addNode(); 20 Parent::get NodeObserverRegistry().add(node);20 Parent::getObserverRegistry(Node()).add(node); 21 21 return node; 22 22 } … … 24 24 Edge addEdge(const Node& from, const Node& to) { 25 25 Edge edge = Parent::addEdge(from, to); 26 Parent::get EdgeObserverRegistry().add(edge);26 Parent::getObserverRegistry(Edge()).add(edge); 27 27 return edge; 28 28 } -
src/lemon/full_graph.h
r977 r980 19 19 20 20 21 #include <lemon/idmappable_graph_extender.h>22 21 #include <lemon/iterable_graph_extender.h> 23 22 #include <lemon/alteration_observer_registry.h> … … 71 70 /// Maximum node ID. 72 71 ///\sa id(Node) 73 int max NodeId() const { return NodeNum-1; }72 int maxId(Node = INVALID) const { return NodeNum-1; } 74 73 /// Maximum edge ID. 75 74 76 75 /// Maximum edge ID. 77 76 ///\sa id(Edge) 78 int max EdgeId() const { return EdgeNum-1; }77 int maxId(Edge = INVALID) const { return EdgeNum-1; } 79 78 80 79 Node tail(Edge e) const { return e.id % NodeNum; } … … 189 188 typedef AlterableGraphExtender<FullGraphBase> AlterableFullGraphBase; 190 189 typedef IterableGraphExtender<AlterableFullGraphBase> IterableFullGraphBase; 191 typedef IdMappableGraphExtender<IterableFullGraphBase> IdMappableFullGraphBase; 192 typedef DefaultMappableGraphExtender<IdMappableFullGraphBase> MappableFullGraphBase; 190 typedef DefaultMappableGraphExtender<IterableFullGraphBase> MappableFullGraphBase; 193 191 194 192 ///A full graph class. -
src/lemon/list_graph.h
r975 r980 26 26 #include <lemon/extendable_graph_extender.h> 27 27 28 #include <lemon/idmappable_graph_extender.h>29 30 28 #include <lemon/iterable_graph_extender.h> 31 29 … … 106 104 /// Maximum node ID. 107 105 ///\sa id(Node) 108 int max NodeId() const { return nodes.size()-1; }106 int maxId(Node = INVALID) const { return nodes.size()-1; } 109 107 110 108 /// Maximum edge ID. … … 112 110 /// Maximum edge ID. 113 111 ///\sa id(Edge) 114 int max EdgeId() const { return edges.size()-1; }112 int maxId(Edge = INVALID) const { return edges.size()-1; } 115 113 116 114 Node tail(Edge e) const { return edges[e.id].tail; } … … 304 302 typedef AlterableGraphExtender<ListGraphBase> AlterableListGraphBase; 305 303 typedef IterableGraphExtender<AlterableListGraphBase> IterableListGraphBase; 306 typedef IdMappableGraphExtender<IterableListGraphBase> IdMappableListGraphBase; 307 typedef DefaultMappableGraphExtender<IdMappableListGraphBase> MappableListGraphBase; 304 typedef DefaultMappableGraphExtender<IterableListGraphBase> MappableListGraphBase; 308 305 typedef ExtendableGraphExtender<MappableListGraphBase> ExtendableListGraphBase; 309 306 typedef ClearableGraphExtender<ExtendableListGraphBase> ClearableListGraphBase; -
src/lemon/smart_graph.h
r977 r980 28 28 #include <lemon/clearable_graph_extender.h> 29 29 #include <lemon/extendable_graph_extender.h> 30 #include <lemon/idmappable_graph_extender.h>31 30 #include <lemon/iterable_graph_extender.h> 32 31 #include <lemon/alteration_observer_registry.h> … … 92 91 /// Maximum node ID. 93 92 ///\sa id(Node) 94 int max NodeId() const { return nodes.size()-1; }93 int maxId(Node = INVALID) const { return nodes.size()-1; } 95 94 /// Maximum edge ID. 96 95 97 96 /// Maximum edge ID. 98 97 ///\sa id(Edge) 99 int max EdgeId() const { return edges.size()-1; }98 int maxId(Edge = INVALID) const { return edges.size()-1; } 100 99 101 100 Node tail(Edge e) const { return edges[e.n].tail; } … … 222 221 typedef AlterableGraphExtender<SmartGraphBase> AlterableSmartGraphBase; 223 222 typedef IterableGraphExtender<AlterableSmartGraphBase> IterableSmartGraphBase; 224 typedef IdMappableGraphExtender<IterableSmartGraphBase> IdMappableSmartGraphBase; 225 typedef DefaultMappableGraphExtender<IdMappableSmartGraphBase> MappableSmartGraphBase; 223 typedef DefaultMappableGraphExtender<IterableSmartGraphBase> MappableSmartGraphBase; 226 224 typedef ExtendableGraphExtender<MappableSmartGraphBase> ExtendableSmartGraphBase; 227 225 typedef ClearableGraphExtender<ExtendableSmartGraphBase> ClearableSmartGraphBase; … … 240 238 /// 241 239 ///\author Alpar Juttner 242 class SmartGraph : public ClearableSmartGraphBase {240 class SmartGraph : public ClearableSmartGraphBase { 243 241 public: 244 242 /// Finds an edge between two nodes. -
src/lemon/vector_map.h
r979 r980 47 47 template <typename _Graph, 48 48 typename _Item, 49 typename _IdMap,50 49 typename _Value> 51 50 class VectorMap : public AlterationObserverRegistry<_Item>::ObserverBase { … … 57 56 typedef _Item KeyType; 58 57 /// The id map type of the map. 59 typedef _IdMap IdMap;60 /// The registry type of the map.61 58 typedef AlterationObserverRegistry<_Item> Registry; 62 59 /// The value type of the map. … … 94 91 /// It adds all the items of the graph to the map. 95 92 96 VectorMap(const Graph& _g , Registry& _r) : graph(&_g) {97 attach(_ r);93 VectorMap(const Graph& _g) : graph(&_g) { 94 attach(_g.getObserverRegistry(_Item())); 98 95 build(); 99 96 } … … 104 101 /// It adds all the items of the graph to the map. 105 102 106 VectorMap(const Graph& g, Registry& r, const Value& v) : graph(&g) {107 attach( r);108 container.resize( IdMap(*graph).maxId() + 1,v);109 } 110 111 VectorMap(const VectorMap& copy) : graph(copy.getGraph()) {112 if ( copy.attached()) {113 attach(* copy.getRegistry());114 container = copy.container;103 VectorMap(const Graph& _g, const Value& _v) : graph(&_g) { 104 attach(_g.getObserverRegistry(_Item())); 105 container.resize(graph->maxId(_Item()) + 1, _v); 106 } 107 108 VectorMap(const VectorMap& _copy) : graph(_copy.getGraph()) { 109 if (_copy.attached()) { 110 attach(*_copy.getRegistry()); 111 container = _copy.container; 115 112 } 116 113 } … … 155 152 156 153 ReferenceType operator[](const KeyType& key) { 157 return container[ IdMap(*graph)[key]];154 return container[graph->id(key)]; 158 155 } 159 156 … … 164 161 165 162 ConstReferenceType operator[](const KeyType& key) const { 166 return container[ IdMap(*graph)[key]];163 return container[graph->id(key)]; 167 164 } 168 165 … … 183 180 184 181 void add(const KeyType& key) { 185 int id = IdMap(*graph)[key];182 int id = graph->id(key); 186 183 if (id >= (int)container.size()) { 187 184 container.resize(id + 1); … … 201 198 202 199 void build() { 203 container.resize( IdMap(*graph).maxId() + 1);200 container.resize(graph->maxId(_Item()) + 1); 204 201 } 205 202 … … 240 237 241 238 template <typename _Value> 242 class NodeMap : public VectorMap<Graph, Node, NodeIdMap,_Value> {239 class NodeMap : public VectorMap<Graph, Node, _Value> { 243 240 public: 244 241 typedef VectorMappableGraphExtender<_Base> Graph; 245 242 246 243 typedef typename Graph::Node Node; 247 typedef typename Graph::NodeIdMap NodeIdMap; 248 249 typedef VectorMap<Graph, Node, NodeIdMap, _Value> Parent; 244 245 typedef VectorMap<Graph, Node, _Value> Parent; 250 246 251 247 //typedef typename Parent::Graph Graph; … … 253 249 254 250 NodeMap(const Graph& g) 255 : Parent(g , g.getNodeObserverRegistry()) {}251 : Parent(g) {} 256 252 NodeMap(const Graph& g, const Value& v) 257 : Parent(g, g.getNodeObserverRegistry(),v) {}253 : Parent(g, v) {} 258 254 259 255 }; 260 256 261 257 template <typename _Value> 262 class EdgeMap : public VectorMap<Graph, Edge, EdgeIdMap,_Value> {258 class EdgeMap : public VectorMap<Graph, Edge, _Value> { 263 259 public: 264 260 typedef VectorMappableGraphExtender<_Base> Graph; 265 261 266 262 typedef typename Graph::Edge Edge; 267 typedef typename Graph::EdgeIdMap EdgeIdMap; 268 269 typedef VectorMap<Graph, Edge, EdgeIdMap, _Value> Parent; 263 264 typedef VectorMap<Graph, Edge, _Value> Parent; 270 265 271 266 //typedef typename Parent::Graph Graph; … … 273 268 274 269 EdgeMap(const Graph& g) 275 : Parent(g , g.getEdgeObserverRegistry()) {}270 : Parent(g) {} 276 271 EdgeMap(const Graph& g, const Value& v) 277 : Parent(g, g.getEdgeObserverRegistry(),v) {}272 : Parent(g, v) {} 278 273 279 274 }; -
src/test/graph_test.cc
r959 r980 34 34 function_requires<IterableGraphComponentConcept<IterableGraphComponent> >(); 35 35 36 function_requires<IdMappableGraphComponentConcept<IdMappableGraphComponent> >();37 36 function_requires<MappableGraphComponentConcept<MappableGraphComponent> >(); 38 37
Note: See TracChangeset
for help on using the changeset viewer.