Changeset 1741:7a98fe2ed989 in lemon-0.x for lemon/dijkstra.h
- Timestamp:
- 10/26/05 12:50:47 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2269
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/dijkstra.h
r1734 r1741 62 62 /// \param G is the graph, to which we would like to define the 63 63 /// HeapCrossRef. 64 /// \todo The graph alone may be insufficient for the initialization65 64 static HeapCrossRef *createHeapCrossRef(const GR &G) 66 65 { … … 75 74 ///\sa Dijkstra 76 75 typedef BinHeap<typename Graph::Node, typename LM::Value, 77 typename GR::template NodeMap<int>, 78 std::less<Value> > Heap; 76 HeapCrossRef, std::less<Value> > Heap; 79 77 80 78 static Heap *createHeap(HeapCrossRef& R) … … 361 359 typedef CR HeapCrossRef; 362 360 typedef H Heap; 363 static HeapCrossRef *createHeapCrossRef(const Graph & G) {364 return new HeapCrossRef(G);365 } 366 static Heap *createHeap(HeapCrossRef & R)361 static HeapCrossRef *createHeapCrossRef(const Graph &) { 362 throw UninitializedParameter(); 363 } 364 static Heap *createHeap(HeapCrossRef &) 367 365 { 368 return new Heap(R);366 throw UninitializedParameter(); 369 367 } 370 368 }; … … 379 377 : public Dijkstra< Graph, LengthMap, DefHeapTraits<H, CR> > { 380 378 typedef Dijkstra< Graph, LengthMap, DefHeapTraits<H, CR> > Create; 379 }; 380 381 template <class H, class CR> 382 struct DefStandardHeapTraits : public Traits { 383 typedef CR HeapCrossRef; 384 typedef H Heap; 385 static HeapCrossRef *createHeapCrossRef(const Graph &G) { 386 return new HeapCrossRef(G); 387 } 388 static Heap *createHeap(HeapCrossRef &R) 389 { 390 return new Heap(R); 391 } 392 }; 393 ///\ref named-templ-param "Named parameter" for setting heap and cross 394 ///reference type with automatic allocation 395 396 ///\ref named-templ-param "Named parameter" for setting heap and cross 397 ///reference type. It can allocate the heap and the cross reference 398 ///object if the cross reference's constructor waits for the graph as 399 ///parameter and the heap's constructor waits for the cross reference. 400 template <class H, class CR = typename Graph::template NodeMap<int> > 401 struct DefStandardHeap 402 : public Dijkstra< Graph, LengthMap, DefStandardHeapTraits<H, CR> > { 403 typedef Dijkstra< Graph, LengthMap, DefStandardHeapTraits<H, CR> > 404 Create; 381 405 }; 382 406 … … 454 478 } 455 479 _dist = &m; 480 return *this; 481 } 482 483 ///Sets the heap and the cross reference used by algorithm. 484 485 ///Sets the heap and the cross reference used by algorithm. 486 ///If you don't use this function before calling \ref run(), 487 ///it will allocate one. The destuctor deallocates this 488 ///automatically allocated map, of course. 489 ///\return <tt> (*this) </tt> 490 Dijkstra &heap(Heap& heap, HeapCrossRef &crossRef) 491 { 492 if(local_heap_cross_ref) { 493 delete _heap_cross_ref; 494 local_heap_cross_ref=false; 495 } 496 _heap_cross_ref = &crossRef; 497 if(local_heap) { 498 delete _heap; 499 local_heap=false; 500 } 501 _heap = &heap; 456 502 return *this; 457 503 }
Note: See TracChangeset
for help on using the changeset viewer.