Changeset 2386:81b47fc5c444 in lemon-0.x for lemon/bfs.h
- Timestamp:
- 03/02/07 19:04:28 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3217
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bfs.h
r2376 r2386 489 489 /// 490 490 ///\param target The target node. 491 ///\retval reach edIndicates that the target node is reached.491 ///\retval reach Indicates that the target node is reached. 492 492 ///\return The processed node. 493 493 /// 494 494 ///\warning The queue must not be empty! 495 Node processNextNode(Node target, bool& reach ed)495 Node processNextNode(Node target, bool& reach) 496 496 { 497 497 if(_queue_tail==_queue_next_dist) { … … 508 508 _pred->set(m,e); 509 509 _dist->set(m,_curr_dist); 510 reach ed = reached|| (target == m);510 reach = reach || (target == m); 511 511 } 512 512 return n; … … 522 522 /// 523 523 ///\param nm The nodemaps of possible targets. 524 ///\retval reach edIndicates that one of the target nodes is reached.524 ///\retval reach Indicates that one of the target nodes is reached. 525 525 ///\return The processed node. 526 526 /// 527 527 ///\warning The queue must not be empty! 528 528 template<class NM> 529 Node processNextNode(const NM& nm, bool& reach ed)529 Node processNextNode(const NM& nm, bool& reach) 530 530 { 531 531 if(_queue_tail==_queue_next_dist) { … … 542 542 _pred->set(m,e); 543 543 _dist->set(m,_curr_dist); 544 reached = reach ed|| nm[m];544 reached = reach || nm[m]; 545 545 } 546 546 return n; … … 605 605 void start(Node dest) 606 606 { 607 bool reach ed= false;608 while ( !emptyQueue() && !reach ed) processNextNode(dest, reached);607 bool reach = false; 608 while ( !emptyQueue() && !reach) processNextNode(dest, reach); 609 609 } 610 610 … … 623 623 void start(const NM &nm) 624 624 { 625 bool reach ed= false;626 while ( !emptyQueue() && !reach ed) processNextNode(nm, reached);625 bool reach = false; 626 while ( !emptyQueue() && !reach) processNextNode(nm, reach); 627 627 } 628 628 … … 883 883 /// \param s is the initial value of \ref _source 884 884 BfsWizardBase(const GR &g, Node s=INVALID) : 885 _g( (void *)&g), _reached(0), _processed(0), _pred(0),886 _ dist(0), _source(s) {}885 _g(reinterpret_cast<void*>(const_cast<GR*>(&g))), 886 _reached(0), _processed(0), _pred(0), _dist(0), _source(s) {} 887 887 888 888 }; … … 958 958 { 959 959 if(Base::_source==INVALID) throw UninitializedParameter(); 960 Bfs<Graph,TR> alg(* (Graph*)Base::_g);960 Bfs<Graph,TR> alg(*reinterpret_cast<const Graph*>(Base::_g)); 961 961 if(Base::_reached) 962 alg.reachedMap(*(ReachedMap*)Base::_reached); 963 if(Base::_processed) alg.processedMap(*(ProcessedMap*)Base::_processed); 964 if(Base::_pred) alg.predMap(*(PredMap*)Base::_pred); 965 if(Base::_dist) alg.distMap(*(DistMap*)Base::_dist); 962 alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached)); 963 if(Base::_processed) 964 alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed)); 965 if(Base::_pred) 966 alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred)); 967 if(Base::_dist) 968 alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist)); 966 969 alg.run(Base::_source); 967 970 } … … 993 996 BfsWizard<DefPredMapBase<T> > predMap(const T &t) 994 997 { 995 Base::_pred= (void *)&t;998 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); 996 999 return BfsWizard<DefPredMapBase<T> >(*this); 997 1000 } … … 1014 1017 BfsWizard<DefReachedMapBase<T> > reachedMap(const T &t) 1015 1018 { 1016 Base::_pred= (void *)&t;1019 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); 1017 1020 return BfsWizard<DefReachedMapBase<T> >(*this); 1018 1021 } … … 1035 1038 BfsWizard<DefProcessedMapBase<T> > processedMap(const T &t) 1036 1039 { 1037 Base::_pred= (void *)&t;1040 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); 1038 1041 return BfsWizard<DefProcessedMapBase<T> >(*this); 1039 1042 } … … 1056 1059 BfsWizard<DefDistMapBase<T> > distMap(const T &t) 1057 1060 { 1058 Base::_dist= (void *)&t;1061 Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t)); 1059 1062 return BfsWizard<DefDistMapBase<T> >(*this); 1060 1063 } … … 1405 1408 /// 1406 1409 /// \param target The target node. 1407 /// \retval reach edIndicates that the target node is reached.1410 /// \retval reach Indicates that the target node is reached. 1408 1411 /// \return The processed node. 1409 1412 /// 1410 1413 /// \warning The queue must not be empty! 1411 Node processNextNode(Node target, bool& reach ed) {1414 Node processNextNode(Node target, bool& reach) { 1412 1415 Node n = _list[++_list_front]; 1413 1416 _visitor->process(n); … … 1420 1423 _reached->set(m, true); 1421 1424 _list[++_list_back] = m; 1422 reach ed = reached|| (target == m);1425 reach = reach || (target == m); 1423 1426 } else { 1424 1427 _visitor->examine(e); … … 1442 1445 /// \warning The queue must not be empty! 1443 1446 template <typename NM> 1444 Node processNextNode(const NM& nm, bool& reach ed) {1447 Node processNextNode(const NM& nm, bool& reach) { 1445 1448 Node n = _list[++_list_front]; 1446 1449 _visitor->process(n); … … 1453 1456 _reached->set(m, true); 1454 1457 _list[++_list_back] = m; 1455 reach ed = reached|| nm[m];1458 reach = reach || nm[m]; 1456 1459 } else { 1457 1460 _visitor->examine(e); … … 1500 1503 /// with addSource() before using this function. 1501 1504 void start(Node dest) { 1502 bool reach ed= false;1503 while (!emptyQueue() && !reach ed) {1504 processNextNode(dest, reach ed);1505 bool reach = false; 1506 while (!emptyQueue() && !reach) { 1507 processNextNode(dest, reach); 1505 1508 } 1506 1509 } … … 1518 1521 template <typename NM> 1519 1522 void start(const NM &nm) { 1520 bool reach ed= false;1521 while (!emptyQueue() && !reach ed) {1522 processNextNode(nm, reach ed);1523 bool reach = false; 1524 while (!emptyQueue() && !reach) { 1525 processNextNode(nm, reach); 1523 1526 } 1524 1527 }
Note: See TracChangeset
for help on using the changeset viewer.