Changeset 2386:81b47fc5c444 in lemon-0.x
- Timestamp:
- 03/02/07 19:04:28 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3217
- Files:
-
- 68 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/bench_tools.h
r1956 r2386 81 81 }; 82 82 83 inline void PrintTime(c har *ID,lemon::Timer &T)83 inline void PrintTime(const char *ID, lemon::Timer &T) 84 84 { 85 85 lemon::TimeStamp S(T); -
benchmark/hcube.cc
r1956 r2386 79 79 for(int i=0;i<5;i++) { 80 80 Primes P; 81 for(int i=0;i<dim*(1<<dim);i++) P();81 for(int j=0;j<dim*(1<<dim);j++) P(); 82 82 83 83 // for(EdgeIt e(G);G.valid(e);G.next(e)) map[e]=P(); -
benchmark/swap_bipartite_bench.cc
r2242 r2386 43 43 vector<LGraph::Node> lbNodes; 44 44 45 for (int i = 0; i < n; ++i) {45 for (int j = 0; j < n; ++j) { 46 46 Node node = graph.addANode(); 47 47 aNodes.push_back(node); … … 49 49 laNodes.push_back(lnode); 50 50 } 51 for (int i = 0; i < m; ++i) {51 for (int j = 0; j < m; ++j) { 52 52 Node node = graph.addBNode(); 53 53 bNodes.push_back(node); … … 55 55 lbNodes.push_back(lnode); 56 56 } 57 for (int i = 0; i < e; ++i) {57 for (int j = 0; j < e; ++j) { 58 58 int a,b; 59 59 Node aNode = aNodes[a=rnd[n]]; -
configure.ac
r2315 r2386 18 18 19 19 if test x"$lx_cmdline_cxxflags_set" != x"set" -a "$GXX" = yes; then 20 CXXFLAGS="$CXXFLAGS -Wall -W "20 CXXFLAGS="$CXXFLAGS -Wall -W -Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -Woverloaded-virtual -Wshadow -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas" 21 21 fi 22 22 -
demo/descriptor_map_demo.cc
r2242 r2386 63 63 Value operator[](const Key& key) const { 64 64 double angle = descriptor[key] * 2 * M_PI 65 / (double)descriptor.inverse().size();65 / double(descriptor.inverse().size()); 66 66 double x = std::cos(angle) * radius + center.x; 67 67 double y = std::sin(angle) * radius + center.y; … … 104 104 // The inversemap cannot works without its DescriptorMap because 105 105 // it holds reference to it. 106 const int EDGE = (int)(NODE * std::log(double(NODE)));106 const int EDGE = int(NODE * std::log(double(NODE))); 107 107 for (int i = 0; i < EDGE; ++i) { 108 108 int si = rnd[NODE]; -
demo/simann_maxcut_demo.cc
r2242 r2386 117 117 simann.run(); 118 118 119 Entity* be = (Entity *) simann.getBestEntity();119 Entity* be = static_cast<Entity*>(simann.getBestEntity()); 120 120 std::cout << be->sum << std::endl; 121 121 for (NodeIt n(g); n != INVALID; ++n) -
lemon/bellman_ford.h
r2376 r2386 437 437 /// paths. 438 438 bool processNextRound() { 439 for (int i = 0; i < (int)_process.size(); ++i) {439 for (int i = 0; i < int(_process.size()); ++i) { 440 440 _mask->set(_process[i], false); 441 441 } 442 442 std::vector<Node> nextProcess; 443 443 std::vector<Value> values(_process.size()); 444 for (int i = 0; i < (int)_process.size(); ++i) {444 for (int i = 0; i < int(_process.size()); ++i) { 445 445 values[i] = (*_dist)[_process[i]]; 446 446 } 447 for (int i = 0; i < (int)_process.size(); ++i) {447 for (int i = 0; i < int(_process.size()); ++i) { 448 448 for (OutEdgeIt it(*graph, _process[i]); it != INVALID; ++it) { 449 449 Node target = graph->target(it); … … 473 473 /// \return %True when the algorithm have not found more shorter paths. 474 474 bool processNextWeakRound() { 475 for (int i = 0; i < (int)_process.size(); ++i) {475 for (int i = 0; i < int(_process.size()); ++i) { 476 476 _mask->set(_process[i], false); 477 477 } 478 478 std::vector<Node> nextProcess; 479 for (int i = 0; i < (int)_process.size(); ++i) {479 for (int i = 0; i < int(_process.size()); ++i) { 480 480 for (OutEdgeIt it(*graph, _process[i]); it != INVALID; ++it) { 481 481 Node target = graph->target(it); … … 646 646 647 647 bool operator==(const ActiveIt& it) const { 648 return (Node)(*this) == (Node)it;648 return static_cast<Node>(*this) == static_cast<Node>(it); 649 649 } 650 650 bool operator!=(const ActiveIt& it) const { 651 return (Node)(*this) != (Node)it;651 return static_cast<Node>(*this) != static_cast<Node>(it); 652 652 } 653 653 bool operator<(const ActiveIt& it) const { 654 return (Node)(*this) < (Node)it;654 return static_cast<Node>(*this) < static_cast<Node>(it); 655 655 } 656 656 … … 866 866 const _LengthMap& length, 867 867 Node source = INVALID) : 868 _graph((void *)&graph), _length((void *)&length), _pred(0), 869 _dist(0), _source(source) {} 868 _graph(reinterpret_cast<void*>(const_cast<_Graph*>(&graph))), 869 _length(reinterpret_cast<void*>(const_cast<_LengthMap*>(&length))), 870 _pred(0), _dist(0), _source(source) {} 870 871 871 872 }; … … 924 925 /// These parameters will be the default values for the traits class. 925 926 BellmanFordWizard(const Graph& graph, const LengthMap& length, 926 Node s ource= INVALID)927 : _Traits(graph, length, s ource) {}927 Node src = INVALID) 928 : _Traits(graph, length, src) {} 928 929 929 930 /// \brief Copy constructor … … 939 940 if(Base::_source == INVALID) throw UninitializedParameter(); 940 941 BellmanFord<Graph,LengthMap,_Traits> 941 bf(*(Graph*)Base::_graph, *(LengthMap*)Base::_length); 942 if (Base::_pred) bf.predMap(*(PredMap*)Base::_pred); 943 if (Base::_dist) bf.distMap(*(DistMap*)Base::_dist); 942 bf(*reinterpret_cast<const Graph*>(Base::_graph), 943 *reinterpret_cast<const LengthMap*>(Base::_length)); 944 if (Base::_pred) bf.predMap(*reinterpret_cast<PredMap*>(Base::_pred)); 945 if (Base::_dist) bf.distMap(*reinterpret_cast<DistMap*>(Base::_dist)); 944 946 bf.run(Base::_source); 945 947 } … … 949 951 /// Runs BellmanFord algorithm from the given node. 950 952 /// \param source is the given source. 951 void run(Node s ource) {952 Base::_source = s ource;953 void run(Node src) { 954 Base::_source = src; 953 955 run(); 954 956 } … … 970 972 BellmanFordWizard<DefPredMapBase<T> > predMap(const T &t) 971 973 { 972 Base::_pred= (void *)&t;974 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); 973 975 return BellmanFordWizard<DefPredMapBase<T> >(*this); 974 976 } … … 989 991 template<class T> 990 992 BellmanFordWizard<DefDistMapBase<T> > distMap(const T &t) { 991 Base::_dist= (void *)&t;993 Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t)); 992 994 return BellmanFordWizard<DefDistMapBase<T> >(*this); 993 995 } … … 1014 1016 /// Sets the source node, from which the BellmanFord algorithm runs. 1015 1017 /// \param source is the source node. 1016 BellmanFordWizard<_Traits>& source(Node s ource) {1017 Base::_source = s ource;1018 BellmanFordWizard<_Traits>& source(Node src) { 1019 Base::_source = src; 1018 1020 return *this; 1019 1021 } -
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 } -
lemon/bipartite_matching.h
r2352 r2386 116 116 /// It initalizes the data structures with an initial matching. 117 117 template <typename MatchingMap> 118 void matchingInit(const MatchingMap& m atching) {118 void matchingInit(const MatchingMap& mm) { 119 119 for (ANodeIt it(*graph); it != INVALID; ++it) { 120 120 anode_matching[it] = INVALID; … … 125 125 matching_size = 0; 126 126 for (UEdgeIt it(*graph); it != INVALID; ++it) { 127 if (m atching[it]) {127 if (mm[it]) { 128 128 ++matching_size; 129 129 anode_matching[graph->aNode(it)] = it; … … 138 138 /// \return %True when the given map contains really a matching. 139 139 template <typename MatchingMap> 140 void checkedMatchingInit(const MatchingMap& m atching) {140 void checkedMatchingInit(const MatchingMap& mm) { 141 141 for (ANodeIt it(*graph); it != INVALID; ++it) { 142 142 anode_matching[it] = INVALID; … … 147 147 matching_size = 0; 148 148 for (UEdgeIt it(*graph); it != INVALID; ++it) { 149 if (m atching[it]) {149 if (mm[it]) { 150 150 ++matching_size; 151 151 if (anode_matching[graph->aNode(it)] != INVALID) { … … 188 188 while (!success && !queue.empty()) { 189 189 std::vector<Node> newqueue; 190 for (int i = 0; i < (int)queue.size(); ++i) {190 for (int i = 0; i < int(queue.size()); ++i) { 191 191 Node anode = queue[i]; 192 192 for (IncEdgeIt jt(*graph, anode); jt != INVALID; ++jt) { … … 214 214 typename Graph::template ANodeMap<bool> aused(*graph, false); 215 215 216 for (int i = 0; i < (int)bqueue.size(); ++i) {216 for (int i = 0; i < int(bqueue.size()); ++i) { 217 217 Node bnode = bqueue[i]; 218 218 … … 280 280 while (!queue.empty()) { 281 281 std::vector<Node> newqueue; 282 for (int i = 0; i < (int)queue.size(); ++i) {282 for (int i = 0; i < int(queue.size()); ++i) { 283 283 Node anode = queue[i]; 284 284 for (IncEdgeIt jt(*graph, anode); jt != INVALID; ++jt) { … … 364 364 while (!queue.empty()) { 365 365 std::vector<Node> newqueue; 366 for (int i = 0; i < (int)queue.size(); ++i) {366 for (int i = 0; i < int(queue.size()); ++i) { 367 367 Node anode = queue[i]; 368 368 for (IncEdgeIt jt(*graph, anode); jt != INVALID; ++jt) { … … 404 404 /// \return The number of the matching edges. 405 405 template <typename MatchingMap> 406 int quickMatching(MatchingMap& m atching) const {406 int quickMatching(MatchingMap& mm) const { 407 407 for (ANodeIt it(*graph); it != INVALID; ++it) { 408 408 if (anode_matching[it] != INVALID) { 409 m atching[anode_matching[it]] = true;409 mm[anode_matching[it]] = true; 410 410 } 411 411 } … … 418 418 /// \return The number of the matching edges. 419 419 template <typename MatchingMap> 420 int matching(MatchingMap& m atching) const {420 int matching(MatchingMap& mm) const { 421 421 for (UEdgeIt it(*graph); it != INVALID; ++it) { 422 m atching[it] = it == anode_matching[graph->aNode(it)];422 mm[it] = it == anode_matching[graph->aNode(it)]; 423 423 } 424 424 return matching_size; … … 684 684 /// automatically allocated map, of course. 685 685 /// \return \c (*this) 686 MaxWeightedBipartiteMatching& heap(Heap& h eap, HeapCrossRef &crossRef) {686 MaxWeightedBipartiteMatching& heap(Heap& hp, HeapCrossRef &cr) { 687 687 if(local_heap_cross_ref) { 688 688 delete _heap_cross_ref; 689 689 local_heap_cross_ref = false; 690 690 } 691 _heap_cross_ref = &cr ossRef;691 _heap_cross_ref = &cr; 692 692 if(local_heap) { 693 693 delete _heap; 694 694 local_heap = false; 695 695 } 696 _heap = &h eap;696 _heap = &hp; 697 697 return *this; 698 698 } … … 890 890 /// for each edges. 891 891 template <typename PotentialMap> 892 void potential(PotentialMap& p otential) const {893 for (ANodeIt it(*graph); it != INVALID; ++it) { 894 p otential[it] = anode_potential[it];892 void potential(PotentialMap& pt) const { 893 for (ANodeIt it(*graph); it != INVALID; ++it) { 894 pt[it] = anode_potential[it]; 895 895 } 896 896 for (BNodeIt it(*graph); it != INVALID; ++it) { 897 p otential[it] = bnode_potential[it];897 pt[it] = bnode_potential[it]; 898 898 } 899 899 } … … 905 905 /// \return The number of the matching edges. 906 906 template <typename MatchingMap> 907 int quickMatching(MatchingMap& m atching) const {907 int quickMatching(MatchingMap& mm) const { 908 908 for (ANodeIt it(*graph); it != INVALID; ++it) { 909 909 if (anode_matching[it] != INVALID) { 910 m atching[anode_matching[it]] = true;910 mm[anode_matching[it]] = true; 911 911 } 912 912 } … … 919 919 /// \return The number of the matching edges. 920 920 template <typename MatchingMap> 921 int matching(MatchingMap& m atching) const {921 int matching(MatchingMap& mm) const { 922 922 for (UEdgeIt it(*graph); it != INVALID; ++it) { 923 m atching[it] = it == anode_matching[graph->aNode(it)];923 mm[it] = it == anode_matching[graph->aNode(it)]; 924 924 } 925 925 return matching_size; … … 1255 1255 /// automatically allocated map, of course. 1256 1256 /// \return \c (*this) 1257 MinCostMaxBipartiteMatching& heap(Heap& h eap, HeapCrossRef &crossRef) {1257 MinCostMaxBipartiteMatching& heap(Heap& hp, HeapCrossRef &cr) { 1258 1258 if(local_heap_cross_ref) { 1259 1259 delete _heap_cross_ref; 1260 1260 local_heap_cross_ref = false; 1261 1261 } 1262 _heap_cross_ref = &cr ossRef;1262 _heap_cross_ref = &cr; 1263 1263 if(local_heap) { 1264 1264 delete _heap; 1265 1265 local_heap = false; 1266 1266 } 1267 _heap = &h eap;1267 _heap = &hp; 1268 1268 return *this; 1269 1269 } … … 1443 1443 /// for each edges. 1444 1444 template <typename PotentialMap> 1445 void potential(PotentialMap& p otential) const {1446 for (ANodeIt it(*graph); it != INVALID; ++it) { 1447 p otential[it] = anode_potential[it];1445 void potential(PotentialMap& pt) const { 1446 for (ANodeIt it(*graph); it != INVALID; ++it) { 1447 pt[it] = anode_potential[it]; 1448 1448 } 1449 1449 for (BNodeIt it(*graph); it != INVALID; ++it) { 1450 p otential[it] = bnode_potential[it];1450 pt[it] = bnode_potential[it]; 1451 1451 } 1452 1452 } … … 1458 1458 /// \return The number of the matching edges. 1459 1459 template <typename MatchingMap> 1460 int quickMatching(MatchingMap& m atching) const {1460 int quickMatching(MatchingMap& mm) const { 1461 1461 for (ANodeIt it(*graph); it != INVALID; ++it) { 1462 1462 if (anode_matching[it] != INVALID) { 1463 m atching[anode_matching[it]] = true;1463 mm[anode_matching[it]] = true; 1464 1464 } 1465 1465 } … … 1472 1472 /// \return The number of the matching edges. 1473 1473 template <typename MatchingMap> 1474 int matching(MatchingMap& m atching) const {1474 int matching(MatchingMap& mm) const { 1475 1475 for (UEdgeIt it(*graph); it != INVALID; ++it) { 1476 m atching[it] = it == anode_matching[graph->aNode(it)];1476 mm[it] = it == anode_matching[graph->aNode(it)]; 1477 1477 } 1478 1478 return matching_size; -
lemon/bits/alteration_notifier.h
r2384 r2386 149 149 /// 150 150 /// Constructor which attach the observer into notifier. 151 ObserverBase(AlterationNotifier& n otifier) {152 attach(n otifier);151 ObserverBase(AlterationNotifier& nf) { 152 attach(nf); 153 153 } 154 154 … … 159 159 ObserverBase(const ObserverBase& copy) { 160 160 if (copy.attached()) { 161 attach(*copy. _notifier());161 attach(*copy.notifier()); 162 162 } 163 163 } … … 174 174 /// This member attaches the observer into an AlterationNotifier. 175 175 /// 176 void attach(AlterationNotifier& n otifier) {177 n otifier.attach(*this);176 void attach(AlterationNotifier& nf) { 177 nf.attach(*this); 178 178 } 179 179 -
lemon/bits/array_map.h
r2384 r2386 82 82 Parent::attach(graph.notifier(Item())); 83 83 allocate_memory(); 84 Notifier* n otifier= Parent::notifier();85 Item it; 86 for (n otifier->first(it); it != INVALID; notifier->next(it)) {87 int id = n otifier->id(it);;84 Notifier* nf = Parent::notifier(); 85 Item it; 86 for (nf->first(it); it != INVALID; nf->next(it)) { 87 int id = nf->id(it);; 88 88 allocator.construct(&(values[id]), Value()); 89 89 } … … 96 96 Parent::attach(graph.notifier(Item())); 97 97 allocate_memory(); 98 Notifier* n otifier= Parent::notifier();99 Item it; 100 for (n otifier->first(it); it != INVALID; notifier->next(it)) {101 int id = n otifier->id(it);;98 Notifier* nf = Parent::notifier(); 99 Item it; 100 for (nf->first(it); it != INVALID; nf->next(it)) { 101 int id = nf->id(it);; 102 102 allocator.construct(&(values[id]), value); 103 103 } … … 114 114 if (capacity == 0) return; 115 115 values = allocator.allocate(capacity); 116 Notifier* n otifier= Parent::notifier();117 Item it; 118 for (n otifier->first(it); it != INVALID; notifier->next(it)) {119 int id = n otifier->id(it);;116 Notifier* nf = Parent::notifier(); 117 Item it; 118 for (nf->first(it); it != INVALID; nf->next(it)) { 119 int id = nf->id(it);; 120 120 allocator.construct(&(values[id]), copy.values[id]); 121 121 } … … 143 143 ArrayMap& operator=(const CMap& cmap) { 144 144 checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); 145 const typename Parent::Notifier* n otifier= Parent::notifier();146 Item it; 147 for (n otifier->first(it); it != INVALID; notifier->next(it)) {145 const typename Parent::Notifier* nf = Parent::notifier(); 146 Item it; 147 for (nf->first(it); it != INVALID; nf->next(it)) { 148 148 set(it, cmap[it]); 149 149 } … … 202 202 /// and it overrides the add() member function of the observer base. 203 203 virtual void add(const Key& key) { 204 Notifier* n otifier= Parent::notifier();205 int id = n otifier->id(key);204 Notifier* nf = Parent::notifier(); 205 int id = nf->id(key); 206 206 if (id >= capacity) { 207 207 int new_capacity = (capacity == 0 ? 1 : capacity); … … 211 211 Value* new_values = allocator.allocate(new_capacity); 212 212 Item it; 213 for (n otifier->first(it); it != INVALID; notifier->next(it)) {214 int jd = n otifier->id(it);;213 for (nf->first(it); it != INVALID; nf->next(it)) { 214 int jd = nf->id(it);; 215 215 if (id != jd) { 216 216 allocator.construct(&(new_values[jd]), values[jd]); … … 230 230 /// and it overrides the add() member function of the observer base. 231 231 virtual void add(const std::vector<Key>& keys) { 232 Notifier* n otifier= Parent::notifier();232 Notifier* nf = Parent::notifier(); 233 233 int max_id = -1; 234 for (int i = 0; i < (int)keys.size(); ++i) {235 int id = n otifier->id(keys[i]);234 for (int i = 0; i < int(keys.size()); ++i) { 235 int id = nf->id(keys[i]); 236 236 if (id > max_id) { 237 237 max_id = id; … … 245 245 Value* new_values = allocator.allocate(new_capacity); 246 246 Item it; 247 for (n otifier->first(it); it != INVALID; notifier->next(it)) {248 int id = n otifier->id(it);247 for (nf->first(it); it != INVALID; nf->next(it)) { 248 int id = nf->id(it); 249 249 bool found = false; 250 for (int i = 0; i < (int)keys.size(); ++i) {251 int jd = n otifier->id(keys[i]);250 for (int i = 0; i < int(keys.size()); ++i) { 251 int jd = nf->id(keys[i]); 252 252 if (id == jd) { 253 253 found = true; … … 263 263 capacity = new_capacity; 264 264 } 265 for (int i = 0; i < (int)keys.size(); ++i) {266 int id = n otifier->id(keys[i]);265 for (int i = 0; i < int(keys.size()); ++i) { 266 int id = nf->id(keys[i]); 267 267 allocator.construct(&(values[id]), Value()); 268 268 } … … 283 283 /// and it overrides the erase() member function of the observer base. 284 284 virtual void erase(const std::vector<Key>& keys) { 285 for (int i = 0; i < (int)keys.size(); ++i) {285 for (int i = 0; i < int(keys.size()); ++i) { 286 286 int id = Parent::notifier()->id(keys[i]); 287 287 allocator.destroy(&(values[id])); … … 294 294 /// and it overrides the build() member function of the observer base. 295 295 virtual void build() { 296 Notifier* n otifier= Parent::notifier();296 Notifier* nf = Parent::notifier(); 297 297 allocate_memory(); 298 298 Item it; 299 for (n otifier->first(it); it != INVALID; notifier->next(it)) {300 int id = n otifier->id(it);;299 for (nf->first(it); it != INVALID; nf->next(it)) { 300 int id = nf->id(it);; 301 301 allocator.construct(&(values[id]), Value()); 302 302 } … … 308 308 /// and it overrides the clear() member function of the observer base. 309 309 virtual void clear() { 310 Notifier* n otifier= Parent::notifier();310 Notifier* nf = Parent::notifier(); 311 311 if (capacity != 0) { 312 312 Item it; 313 for (n otifier->first(it); it != INVALID; notifier->next(it)) {314 int id = n otifier->id(it);313 for (nf->first(it); it != INVALID; nf->next(it)) { 314 int id = nf->id(it); 315 315 allocator.destroy(&(values[id])); 316 316 } -
lemon/bits/base_extender.h
r2260 r2386 194 194 } 195 195 196 Node nodeFromId(int i d) const {197 return Parent::nodeFromId(i d);198 } 199 200 Edge edgeFromId(int i d) const {201 return direct(Parent::edgeFromId(i d >> 1), bool(id& 1));202 } 203 204 UEdge uEdgeFromId(int i d) const {205 return Parent::edgeFromId(i d);196 Node nodeFromId(int ix) const { 197 return Parent::nodeFromId(ix); 198 } 199 200 Edge edgeFromId(int ix) const { 201 return direct(Parent::edgeFromId(ix >> 1), bool(ix & 1)); 202 } 203 204 UEdge uEdgeFromId(int ix) const { 205 return Parent::edgeFromId(ix); 206 206 } 207 207 … … 239 239 } 240 240 241 Edge findEdge(Node s ource, Node target, Edge prev= INVALID) const {242 if (p rev== INVALID) {243 UEdge edge = Parent::findEdge(s ource, target);241 Edge findEdge(Node s, Node t, Edge p = INVALID) const { 242 if (p == INVALID) { 243 UEdge edge = Parent::findEdge(s, t); 244 244 if (edge != INVALID) return direct(edge, true); 245 edge = Parent::findEdge(t arget, source);245 edge = Parent::findEdge(t, s); 246 246 if (edge != INVALID) return direct(edge, false); 247 } else if (direction(p rev)) {248 UEdge edge = Parent::findEdge(s ource, target, prev);247 } else if (direction(p)) { 248 UEdge edge = Parent::findEdge(s, t, p); 249 249 if (edge != INVALID) return direct(edge, true); 250 edge = Parent::findEdge(t arget, source);250 edge = Parent::findEdge(t, s); 251 251 if (edge != INVALID) return direct(edge, false); 252 252 } else { 253 UEdge edge = Parent::findEdge(t arget, source, prev);253 UEdge edge = Parent::findEdge(t, s, p); 254 254 if (edge != INVALID) return direct(edge, false); 255 255 } … … 257 257 } 258 258 259 UEdge findUEdge(Node s ource, Node target, UEdge prev= INVALID) const {260 if (s ource != target) {261 if (p rev== INVALID) {262 UEdge edge = Parent::findEdge(s ource, target);259 UEdge findUEdge(Node s, Node t, UEdge p = INVALID) const { 260 if (s != t) { 261 if (p == INVALID) { 262 UEdge edge = Parent::findEdge(s, t); 263 263 if (edge != INVALID) return edge; 264 edge = Parent::findEdge(t arget, source);264 edge = Parent::findEdge(t, s); 265 265 if (edge != INVALID) return edge; 266 } else if (Parent::s ource(prev) == source) {267 UEdge edge = Parent::findEdge(s ource, target, prev);266 } else if (Parent::s(p) == s) { 267 UEdge edge = Parent::findEdge(s, t, p); 268 268 if (edge != INVALID) return edge; 269 edge = Parent::findEdge(t arget, source);269 edge = Parent::findEdge(t, s); 270 270 if (edge != INVALID) return edge; 271 271 } else { 272 UEdge edge = Parent::findEdge(t arget, source, prev);272 UEdge edge = Parent::findEdge(t, s, p); 273 273 if (edge != INVALID) return edge; 274 274 } 275 275 } else { 276 return Parent::findEdge(s ource, target, prev);276 return Parent::findEdge(s, t, p); 277 277 } 278 278 return INVALID; … … 358 358 } 359 359 360 void firstInc(UEdge& edge, bool& dir ection, const Node& node) const {360 void firstInc(UEdge& edge, bool& dir, const Node& node) const { 361 361 if (Parent::aNode(node)) { 362 362 Parent::firstFromANode(edge, node); 363 dir ection= true;363 dir = true; 364 364 } else { 365 365 Parent::firstFromBNode(edge, node); 366 dir ection= static_cast<UEdge&>(edge) == INVALID;367 } 368 } 369 void nextInc(UEdge& edge, bool& dir ection) const {370 if (dir ection) {366 dir = static_cast<UEdge&>(edge) == INVALID; 367 } 368 } 369 void nextInc(UEdge& edge, bool& dir) const { 370 if (dir) { 371 371 Parent::nextFromANode(edge); 372 372 } else { 373 373 Parent::nextFromBNode(edge); 374 if (edge == INVALID) dir ection= true;374 if (edge == INVALID) dir = true; 375 375 } 376 376 } … … 458 458 (edge.forward ? 0 : 1); 459 459 } 460 Edge edgeFromId(int i d) const {461 return Edge(Parent::fromUEdgeId(i d >> 1), (id& 1) == 0);460 Edge edgeFromId(int ix) const { 461 return Edge(Parent::fromUEdgeId(ix >> 1), (ix & 1) == 0); 462 462 } 463 463 int maxEdgeId() const { … … 469 469 } 470 470 471 Edge direct(const UEdge& edge, bool dir ection) const {472 return Edge(edge, dir ection);471 Edge direct(const UEdge& edge, bool dir) const { 472 return Edge(edge, dir); 473 473 } 474 474 -
lemon/bits/debug_map.h
r2384 r2386 166 166 } 167 167 } 168 for (int i = 0; i < (int)flag.size(); ++i) {168 for (int i = 0; i < int(flag.size()); ++i) { 169 169 LEMON_ASSERT(!flag[i], MapError()); 170 170 } … … 236 236 virtual void add(const Key& key) { 237 237 int id = Parent::notifier()->id(key); 238 if (id >= (int)container.size()) {238 if (id >= int(container.size())) { 239 239 container.resize(id + 1); 240 240 flag.resize(id + 1, false); … … 247 247 Item it; 248 248 for (notifier->first(it); it != INVALID; notifier->next(it)) { 249 int id = Parent::notifier()->id(it);250 fl[ id] = true;249 int jd = Parent::notifier()->id(it); 250 fl[jd] = true; 251 251 } 252 252 LEMON_ASSERT(fl == flag, MapError()); … … 260 260 virtual void add(const std::vector<Key>& keys) { 261 261 int max = container.size() - 1; 262 for (int i = 0; i < (int)keys.size(); ++i) {262 for (int i = 0; i < int(keys.size()); ++i) { 263 263 int id = Parent::notifier()->id(keys[i]); 264 264 if (id >= max) { … … 268 268 container.resize(max + 1); 269 269 flag.resize(max + 1, false); 270 for (int i = 0; i < (int)keys.size(); ++i) {270 for (int i = 0; i < int(keys.size()); ++i) { 271 271 LEMON_ASSERT(!flag[Parent::notifier()->id(keys[i])], MapError()); 272 272 flag[Parent::notifier()->id(keys[i])] = true; … … 319 319 LEMON_ASSERT(fl == flag, MapError()); 320 320 } 321 for (int i = 0; i < (int)keys.size(); ++i) {321 for (int i = 0; i < int(keys.size()); ++i) { 322 322 container[Parent::notifier()->id(keys[i])] = Value(); 323 323 LEMON_ASSERT(flag[Parent::notifier()->id(keys[i])], MapError()); … … 332 332 virtual void build() { 333 333 if (strictCheck) { 334 for (int i = 0; i < (int)flag.size(); ++i) {334 for (int i = 0; i < int(flag.size()); ++i) { 335 335 LEMON_ASSERT(flag[i], MapError()); 336 336 } … … 363 363 } 364 364 if (strictCheck) { 365 for (int i = 0; i < (int)flag.size(); ++i) {365 for (int i = 0; i < int(flag.size()); ++i) { 366 366 LEMON_ASSERT(!flag[i], MapError()); 367 367 } -
lemon/bits/edge_set_extender.h
r2384 r2386 190 190 /// Returns the base node (ie. the source in this case) of the iterator 191 191 Node baseNode(const OutEdgeIt &e) const { 192 return Parent::source( (Edge)e);192 return Parent::source(static_cast<const Edge&>(e)); 193 193 } 194 194 /// \brief Running node of the iterator … … 197 197 /// iterator 198 198 Node runningNode(const OutEdgeIt &e) const { 199 return Parent::target( (Edge)e);199 return Parent::target(static_cast<const Edge&>(e)); 200 200 } 201 201 … … 204 204 /// Returns the base node (ie. the target in this case) of the iterator 205 205 Node baseNode(const InEdgeIt &e) const { 206 return Parent::target( (Edge)e);206 return Parent::target(static_cast<const Edge&>(e)); 207 207 } 208 208 /// \brief Running node of the iterator … … 211 211 /// iterator 212 212 Node runningNode(const InEdgeIt &e) const { 213 return Parent::source( (Edge)e);213 return Parent::source(static_cast<const Edge&>(e)); 214 214 } 215 215 … … 497 497 /// Returns the base node (ie. the source in this case) of the iterator 498 498 Node baseNode(const OutEdgeIt &e) const { 499 return Parent::source( (Edge)e);499 return Parent::source(static_cast<const Edge&>(e)); 500 500 } 501 501 /// \brief Running node of the iterator … … 504 504 /// iterator 505 505 Node runningNode(const OutEdgeIt &e) const { 506 return Parent::target( (Edge)e);506 return Parent::target(static_cast<const Edge&>(e)); 507 507 } 508 508 … … 511 511 /// Returns the base node (ie. the target in this case) of the iterator 512 512 Node baseNode(const InEdgeIt &e) const { 513 return Parent::target( (Edge)e);513 return Parent::target(static_cast<const Edge&>(e)); 514 514 } 515 515 /// \brief Running node of the iterator … … 518 518 /// iterator 519 519 Node runningNode(const InEdgeIt &e) const { 520 return Parent::source( (Edge)e);520 return Parent::source(static_cast<const Edge&>(e)); 521 521 } 522 522 -
lemon/bits/graph_adaptor_extender.h
r2231 r2386 400 400 /// Returns the base node (ie. the source in this case) of the iterator 401 401 Node baseNode(const OutEdgeIt &e) const { 402 return Parent::source( (Edge)e);402 return Parent::source(static_cast<const Edge&>(e)); 403 403 } 404 404 /// \brief Running node of the iterator … … 407 407 /// iterator 408 408 Node runningNode(const OutEdgeIt &e) const { 409 return Parent::target( (Edge)e);409 return Parent::target(static_cast<const Edge&>(e)); 410 410 } 411 411 … … 414 414 /// Returns the base node (ie. the target in this case) of the iterator 415 415 Node baseNode(const InEdgeIt &e) const { 416 return Parent::target( (Edge)e);416 return Parent::target(static_cast<const Edge&>(e)); 417 417 } 418 418 /// \brief Running node of the iterator … … 421 421 /// iterator 422 422 Node runningNode(const InEdgeIt &e) const { 423 return Parent::source( (Edge)e);423 return Parent::source(static_cast<const Edge&>(e)); 424 424 } 425 425 … … 652 652 /// Returns the base node (ie. the source in this case) of the iterator 653 653 Node baseNode(const OutEdgeIt &e) const { 654 return Parent::source( (Edge&)e);654 return Parent::source(static_cast<const Edge&>(e)); 655 655 } 656 656 /// \brief Running node of the iterator … … 659 659 /// iterator 660 660 Node runningNode(const OutEdgeIt &e) const { 661 return Parent::target( (Edge&)e);661 return Parent::target(static_cast<const Edge&>(e)); 662 662 } 663 663 … … 666 666 /// Returns the base node (ie. the target in this case) of the iterator 667 667 Node baseNode(const InEdgeIt &e) const { 668 return Parent::target( (Edge&)e);668 return Parent::target(static_cast<const Edge&>(e)); 669 669 } 670 670 /// \brief Running node of the iterator … … 673 673 /// iterator 674 674 Node runningNode(const InEdgeIt &e) const { 675 return Parent::source( (Edge&)e);675 return Parent::source(static_cast<const Edge&>(e)); 676 676 } 677 677 -
lemon/bits/graph_extender.h
r2384 r2386 557 557 /// Returns the base node (ie. the source in this case) of the iterator 558 558 Node baseNode(const OutEdgeIt &e) const { 559 return Parent::source( (Edge)e);559 return Parent::source(static_cast<const Edge&>(e)); 560 560 } 561 561 /// \brief Running node of the iterator … … 564 564 /// iterator 565 565 Node runningNode(const OutEdgeIt &e) const { 566 return Parent::target( (Edge)e);566 return Parent::target(static_cast<const Edge&>(e)); 567 567 } 568 568 … … 571 571 /// Returns the base node (ie. the target in this case) of the iterator 572 572 Node baseNode(const InEdgeIt &e) const { 573 return Parent::target( (Edge)e);573 return Parent::target(static_cast<const Edge&>(e)); 574 574 } 575 575 /// \brief Running node of the iterator … … 578 578 /// iterator 579 579 Node runningNode(const InEdgeIt &e) const { 580 return Parent::source( (Edge)e);580 return Parent::source(static_cast<const Edge&>(e)); 581 581 } 582 582 … … 680 680 UEdge uedge = Parent::addEdge(from, to); 681 681 notifier(UEdge()).add(uedge); 682 std::vector<Edge> e dges;683 e dges.push_back(Parent::direct(uedge, true));684 e dges.push_back(Parent::direct(uedge, false));685 notifier(Edge()).add(e dges);682 std::vector<Edge> ev; 683 ev.push_back(Parent::direct(uedge, true)); 684 ev.push_back(Parent::direct(uedge, false)); 685 notifier(Edge()).add(ev); 686 686 return uedge; 687 687 } … … 722 722 723 723 void erase(const UEdge& uedge) { 724 std::vector<Edge> e dges;725 e dges.push_back(Parent::direct(uedge, true));726 e dges.push_back(Parent::direct(uedge, false));727 notifier(Edge()).erase(e dges);724 std::vector<Edge> ev; 725 ev.push_back(Parent::direct(uedge, true)); 726 ev.push_back(Parent::direct(uedge, false)); 727 notifier(Edge()).erase(ev); 728 728 notifier(UEdge()).erase(uedge); 729 729 Parent::erase(uedge); … … 1008 1008 /// Returns the base node (ie. the source in this case) of the iterator 1009 1009 Node baseNode(const OutEdgeIt &e) const { 1010 return Parent::source( (Edge&)e);1010 return Parent::source(static_cast<const Edge&>(e)); 1011 1011 } 1012 1012 /// \brief Running node of the iterator … … 1015 1015 /// iterator 1016 1016 Node runningNode(const OutEdgeIt &e) const { 1017 return Parent::target( (Edge&)e);1017 return Parent::target(static_cast<const Edge&>(e)); 1018 1018 } 1019 1019 … … 1022 1022 /// Returns the base node (ie. the target in this case) of the iterator 1023 1023 Node baseNode(const InEdgeIt &e) const { 1024 return Parent::target( (Edge&)e);1024 return Parent::target(static_cast<const Edge&>(e)); 1025 1025 } 1026 1026 /// \brief Running node of the iterator … … 1029 1029 /// iterator 1030 1030 Node runningNode(const InEdgeIt &e) const { 1031 return Parent::source( (Edge&)e);1031 return Parent::source(static_cast<const Edge&>(e)); 1032 1032 } 1033 1033 … … 1296 1296 } 1297 1297 1298 UEdge addEdge(const Node& s ource, const Node& target) {1299 UEdge uedge = Parent::addEdge(s ource, target);1298 UEdge addEdge(const Node& s, const Node& t) { 1299 UEdge uedge = Parent::addEdge(s, t); 1300 1300 notifier(UEdge()).add(uedge); 1301 1301 1302 std::vector<Edge> e dges;1303 e dges.push_back(Parent::direct(uedge, true));1304 e dges.push_back(Parent::direct(uedge, false));1305 notifier(Edge()).add(e dges);1302 std::vector<Edge> ev; 1303 ev.push_back(Parent::direct(uedge, true)); 1304 ev.push_back(Parent::direct(uedge, false)); 1305 notifier(Edge()).add(ev); 1306 1306 1307 1307 return uedge; … … 1352 1352 1353 1353 void erase(const UEdge& uedge) { 1354 std::vector<Edge> e dges;1355 e dges.push_back(Parent::direct(uedge, true));1356 e dges.push_back(Parent::direct(uedge, false));1357 notifier(Edge()).erase(e dges);1354 std::vector<Edge> ev; 1355 ev.push_back(Parent::direct(uedge, true)); 1356 ev.push_back(Parent::direct(uedge, false)); 1357 notifier(Edge()).erase(ev); 1358 1358 notifier(UEdge()).erase(uedge); 1359 1359 Parent::erase(uedge); -
lemon/bits/item_reader.h
r2254 r2386 595 595 if (!(is >> temp)) 596 596 throw DataFormatError("DefaultReader<char> format error"); 597 value = (char)temp;597 value = static_cast<char>(temp); 598 598 break; 599 599 } -
lemon/bits/item_writer.h
r2255 r2386 156 156 if (escaped) { 157 157 std::ostringstream ls; 158 for (int i = 0; i < (int)value.size(); ++i) {158 for (int i = 0; i < int(value.size()); ++i) { 159 159 writeEscape(ls, value[i]); 160 160 } … … 205 205 default: 206 206 if (c < 0x20) { 207 os << '\\' << std::oct << (int)c;207 os << '\\' << std::oct << static_cast<int>(c); 208 208 } else { 209 209 os << c; -
lemon/bits/lp_id.h
r2363 r2386 78 78 impl.index[xn] = impl.first_free; 79 79 impl.first_free = xn; 80 for(int i = fn + 1; i < (int)impl.cross.size(); ++i) {80 for(int i = fn + 1; i < int(impl.cross.size()); ++i) { 81 81 impl.cross[i - 1] = impl.cross[i]; 82 82 impl.index[impl.cross[i]]--; … … 90 90 void firstFloating(int& fn) const { 91 91 fn = impl.first_index; 92 if (fn == (int)impl.cross.size()) fn = -1;92 if (fn == int(impl.cross.size())) fn = -1; 93 93 } 94 94 95 95 void nextFloating(int& fn) const { 96 96 ++fn; 97 if (fn == (int)impl.cross.size()) fn = -1;97 if (fn == int(impl.cross.size())) fn = -1; 98 98 } 99 99 -
lemon/bits/utility.h
r2177 r2386 70 70 71 71 72 class InvalidType { 73 private: 74 InvalidType(); 72 struct InvalidType { 75 73 }; 76 74 -
lemon/bits/variant.h
r2292 r2386 74 74 /// This constructor initalizes to the given value of the \c First 75 75 /// type. 76 BiVariant(const First& f irst) {76 BiVariant(const First& f) { 77 77 flag = true; 78 new(reinterpret_cast<First*>(data)) First(f irst);78 new(reinterpret_cast<First*>(data)) First(f); 79 79 } 80 80 … … 83 83 /// This constructor initalizes to the given value of the \c 84 84 /// Second type. 85 BiVariant(const Second& s econd) {85 BiVariant(const Second& s) { 86 86 flag = false; 87 new(reinterpret_cast<Second*>(data)) Second(s econd);87 new(reinterpret_cast<Second*>(data)) Second(s); 88 88 } 89 89 … … 122 122 /// This function sets the variant to the given value of the \c 123 123 /// First type. 124 BiVariant& setFirst(const First& f irst) {124 BiVariant& setFirst(const First& f) { 125 125 destroy(); 126 126 flag = true; 127 new(reinterpret_cast<First*>(data)) First(f irst);127 new(reinterpret_cast<First*>(data)) First(f); 128 128 return *this; 129 129 } … … 144 144 /// This function sets the variant to the given value of the \c 145 145 /// Second type. 146 BiVariant& setSecond(const Second& s econd) {146 BiVariant& setSecond(const Second& s) { 147 147 destroy(); 148 148 flag = false; 149 new(reinterpret_cast<Second*>(data)) Second(s econd);149 new(reinterpret_cast<Second*>(data)) Second(s); 150 150 return *this; 151 151 } 152 152 153 153 /// \brief Operator form of the \c setFirst() 154 BiVariant& operator=(const First& f irst) {155 return setFirst(f irst);154 BiVariant& operator=(const First& f) { 155 return setFirst(f); 156 156 } 157 157 158 158 /// \brief Operator form of the \c setSecond() 159 BiVariant& operator=(const Second& s econd) {160 return setSecond(s econd);159 BiVariant& operator=(const Second& s) { 160 return setSecond(s); 161 161 } 162 162 -
lemon/bits/vector_map.h
r2384 r2386 135 135 VectorMap& operator=(const CMap& cmap) { 136 136 checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); 137 const typename Parent::Notifier* n otifier= Parent::notifier();137 const typename Parent::Notifier* nf = Parent::notifier(); 138 138 Item it; 139 for (n otifier->first(it); it != INVALID; notifier->next(it)) {139 for (nf->first(it); it != INVALID; nf->next(it)) { 140 140 set(it, cmap[it]); 141 141 } … … 177 177 virtual void add(const Key& key) { 178 178 int id = Parent::notifier()->id(key); 179 if (id >= (int)container.size()) {179 if (id >= int(container.size())) { 180 180 container.resize(id + 1); 181 181 } … … 188 188 virtual void add(const std::vector<Key>& keys) { 189 189 int max = container.size() - 1; 190 for (int i = 0; i < (int)keys.size(); ++i) {190 for (int i = 0; i < int(keys.size()); ++i) { 191 191 int id = Parent::notifier()->id(keys[i]); 192 192 if (id >= max) { … … 210 210 /// and it overrides the erase() member function of the observer base. 211 211 virtual void erase(const std::vector<Key>& keys) { 212 for (int i = 0; i < (int)keys.size(); ++i) {212 for (int i = 0; i < int(keys.size()); ++i) { 213 213 container[Parent::notifier()->id(keys[i])] = Value(); 214 214 } -
lemon/bpugraph_adaptor.h
r2384 r2386 128 128 129 129 typedef FindEdgeTagIndicator<Graph> FindEdgeTag; 130 Edge findEdge(const Node& source, const Node& target,130 Edge findEdge(const Node& u, const Node& v, 131 131 const Edge& prev = INVALID) { 132 return graph->findEdge( source, target, prev);133 } 134 UEdge findUEdge(const Node& source, const Node& target,132 return graph->findEdge(u, v, prev); 133 } 134 UEdge findUEdge(const Node& u, const Node& v, 135 135 const UEdge& prev = INVALID) { 136 return graph->findUEdge( source, target, prev);136 return graph->findUEdge(u, v, prev); 137 137 } 138 138 139 139 Node addANode() const { return graph->addANode(); } 140 140 Node addBNode() const { return graph->addBNode(); } 141 UEdge addEdge(const Node& source, const Node& target) const {142 return graph->addEdge( source, target);141 UEdge addEdge(const Node& u, const Node& v) const { 142 return graph->addEdge(u, v); 143 143 } 144 144 … … 157 157 int id(const UEdge& e) const { return graph->id(e); } 158 158 159 Node fromNodeId(int i d) const { return graph->fromNodeId(id); }160 ANode nodeFromANodeId(int i d) const { return graph->nodeFromANodeId(id); }161 BNode nodeFromBNodeId(int i d) const { return graph->nodeFromBNodeId(id); }162 Edge fromEdgeId(int i d) const { return graph->fromEdgeId(id); }163 UEdge fromUEdgeId(int i d) const { return graph->fromUEdgeId(id); }159 Node fromNodeId(int ix) const { return graph->fromNodeId(ix); } 160 ANode nodeFromANodeId(int ix) const { return graph->nodeFromANodeId(ix); } 161 BNode nodeFromBNodeId(int ix) const { return graph->nodeFromBNodeId(ix); } 162 Edge fromEdgeId(int ix) const { return graph->fromEdgeId(ix); } 163 UEdge fromUEdgeId(int ix) const { return graph->fromUEdgeId(ix); } 164 164 165 165 int maxNodeId() const { return graph->maxNodeId(); } … … 362 362 int id(const BNode& v) const { return Parent::id(v); } 363 363 364 ANode nodeFromANodeId(int i d) const { return Parent::nodeFromBNodeId(id); }365 BNode nodeFromBNodeId(int i d) const { return Parent::nodeFromANodeId(id); }364 ANode nodeFromANodeId(int ix) const { return Parent::nodeFromBNodeId(ix); } 365 BNode nodeFromBNodeId(int ix) const { return Parent::nodeFromANodeId(ix); } 366 366 367 367 int maxANodeId() const { return Parent::maxBNodeId(); } -
lemon/bucket_heap.h
r2263 r2386 101 101 102 102 void relocate_last(int idx) { 103 if (idx + 1 < (int)data.size()) {103 if (idx + 1 < int(data.size())) { 104 104 data[idx] = data.back(); 105 105 if (data[idx].prev != -1) { … … 128 128 129 129 void lace(int idx) { 130 if ( (int)first.size() <= data[idx].value) {130 if (int(first.size()) <= data[idx].value) { 131 131 first.resize(data[idx].value + 1, -1); 132 132 } … … 355 355 356 356 void relocate_last(int idx) { 357 if (idx + 1 != (int)data.size()) {357 if (idx + 1 != int(data.size())) { 358 358 data[idx] = data.back(); 359 359 if (data[idx].prev != -1) { … … 382 382 383 383 void lace(int idx) { 384 if ( (int)first.size() <= data[idx].value) {384 if (int(first.size()) <= data[idx].value) { 385 385 first.resize(data[idx].value + 1, -1); 386 386 } … … 608 608 } 609 609 index[i] = idx; 610 if (p >= (int)first.size()) first.resize(p + 1, -1);610 if (p >= int(first.size())) first.resize(p + 1, -1); 611 611 data[idx].next = first[p]; 612 612 first[p] = idx; … … 751 751 } 752 752 index[i] = idx; 753 if (p >= (int)first.size()) first.resize(p + 1, -1);753 if (p >= int(first.size())) first.resize(p + 1, -1); 754 754 data[idx].next = first[p]; 755 755 first[p] = idx; -
lemon/csp.h
r2377 r2386 89 89 ///\e 90 90 /// 91 ConstrainedShortestPath(Graph &g, CM &c ost, DM &delay)92 : _g(g), _cost(c ost), _delay(delay),93 _co_map(c ost,delay), _dij(_g,_co_map) {}91 ConstrainedShortestPath(Graph &g, CM &ct, DM &dl) 92 : _g(g), _cost(ct), _delay(dl), 93 _co_map(ct,dl), _dij(_g,_co_map) {} 94 94 95 95 -
lemon/dfs.h
r2376 r2386 859 859 /// \param s is the initial value of \ref _source 860 860 DfsWizardBase(const GR &g, Node s=INVALID) : 861 _g( (void *)&g), _reached(0), _processed(0), _pred(0),862 _ dist(0), _source(s) {}861 _g(reinterpret_cast<void*>(const_cast<GR*>(&g))), 862 _reached(0), _processed(0), _pred(0), _dist(0), _source(s) {} 863 863 864 864 }; … … 934 934 { 935 935 if(Base::_source==INVALID) throw UninitializedParameter(); 936 Dfs<Graph,TR> alg(*(Graph*)Base::_g); 937 if(Base::_reached) alg.reachedMap(*(ReachedMap*)Base::_reached); 938 if(Base::_processed) alg.processedMap(*(ProcessedMap*)Base::_processed); 939 if(Base::_pred) alg.predMap(*(PredMap*)Base::_pred); 940 if(Base::_dist) alg.distMap(*(DistMap*)Base::_dist); 936 Dfs<Graph,TR> alg(*reinterpret_cast<const Graph*>(Base::_g)); 937 if(Base::_reached) 938 alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached)); 939 if(Base::_processed) 940 alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed)); 941 if(Base::_pred) 942 alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred)); 943 if(Base::_dist) 944 alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist)); 941 945 alg.run(Base::_source); 942 946 } … … 968 972 DfsWizard<DefPredMapBase<T> > predMap(const T &t) 969 973 { 970 Base::_pred= (void *)&t;974 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); 971 975 return DfsWizard<DefPredMapBase<T> >(*this); 972 976 } … … 989 993 DfsWizard<DefReachedMapBase<T> > reachedMap(const T &t) 990 994 { 991 Base::_pred= (void *)&t;995 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); 992 996 return DfsWizard<DefReachedMapBase<T> >(*this); 993 997 } … … 1010 1014 DfsWizard<DefProcessedMapBase<T> > processedMap(const T &t) 1011 1015 { 1012 Base::_pred= (void *)&t;1016 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); 1013 1017 return DfsWizard<DefProcessedMapBase<T> >(*this); 1014 1018 } … … 1030 1034 DfsWizard<DefDistMapBase<T> > distMap(const T &t) 1031 1035 { 1032 Base::_dist= (void *)&t;1036 Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t)); 1033 1037 return DfsWizard<DefDistMapBase<T> >(*this); 1034 1038 } -
lemon/dijkstra.h
r2376 r2386 488 488 ///automatically allocated heap and cross reference, of course. 489 489 ///\return <tt> (*this) </tt> 490 Dijkstra &heap(Heap& h eap, HeapCrossRef &crossRef)490 Dijkstra &heap(Heap& hp, HeapCrossRef &cr) 491 491 { 492 492 if(local_heap_cross_ref) { … … 494 494 local_heap_cross_ref=false; 495 495 } 496 _heap_cross_ref = &cr ossRef;496 _heap_cross_ref = &cr; 497 497 if(local_heap) { 498 498 delete _heap; 499 499 local_heap=false; 500 500 } 501 _heap = &h eap;501 _heap = &hp; 502 502 return *this; 503 503 } … … 963 963 /// \param s is the initial value of \ref _source 964 964 DijkstraWizardBase(const GR &g,const LM &l, Node s=INVALID) : 965 _g((void *)&g), _length((void *)&l), _pred(0), 966 _dist(0), _source(s) {} 965 _g(reinterpret_cast<void*>(const_cast<GR*>(&g))), 966 _length(reinterpret_cast<void*>(const_cast<LM*>(&l))), 967 _pred(0), _dist(0), _source(s) {} 967 968 968 969 }; … … 1038 1039 if(Base::_source==INVALID) throw UninitializedParameter(); 1039 1040 Dijkstra<Graph,LengthMap,TR> 1040 dij(*(Graph*)Base::_g,*(LengthMap*)Base::_length); 1041 if(Base::_pred) dij.predMap(*(PredMap*)Base::_pred); 1042 if(Base::_dist) dij.distMap(*(DistMap*)Base::_dist); 1041 dij(*reinterpret_cast<const Graph*>(Base::_g), 1042 *reinterpret_cast<const LengthMap*>(Base::_length)); 1043 if(Base::_pred) dij.predMap(*reinterpret_cast<PredMap*>(Base::_pred)); 1044 if(Base::_dist) dij.distMap(*reinterpret_cast<DistMap*>(Base::_dist)); 1043 1045 dij.run(Base::_source); 1044 1046 } … … 1070 1072 DijkstraWizard<DefPredMapBase<T> > predMap(const T &t) 1071 1073 { 1072 Base::_pred= (void *)&t;1074 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); 1073 1075 return DijkstraWizard<DefPredMapBase<T> >(*this); 1074 1076 } … … 1090 1092 DijkstraWizard<DefDistMapBase<T> > distMap(const T &t) 1091 1093 { 1092 Base::_dist= (void *)&t;1094 Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t)); 1093 1095 return DijkstraWizard<DefDistMapBase<T> >(*this); 1094 1096 } -
lemon/edge_set.h
r2384 r2386 87 87 ListEdgeSetBase() : first_edge(-1), first_free_edge(-1) {} 88 88 89 Edge addEdge(const Node& source, const Node& target) {89 Edge addEdge(const Node& u, const Node& v) { 90 90 int n; 91 91 if (first_free_edge == -1) { … … 96 96 first_free_edge = edges[first_free_edge].next_in; 97 97 } 98 edges[n].next_in = (*nodes)[ target].first_in;99 if ((*nodes)[ target].first_in != -1) {100 edges[(*nodes)[ target].first_in].prev_in = n;101 } 102 (*nodes)[ target].first_in = n;103 edges[n].next_out = (*nodes)[ source].first_out;104 if ((*nodes)[ source].first_out != -1) {105 edges[(*nodes)[ source].first_out].prev_out = n;106 } 107 (*nodes)[ source].first_out = n;108 edges[n].source = source;109 edges[n].target = target;98 edges[n].next_in = (*nodes)[v].first_in; 99 if ((*nodes)[v].first_in != -1) { 100 edges[(*nodes)[v].first_in].prev_in = n; 101 } 102 (*nodes)[v].first_in = n; 103 edges[n].next_out = (*nodes)[u].first_out; 104 if ((*nodes)[u].first_out != -1) { 105 edges[(*nodes)[u].first_out].prev_out = n; 106 } 107 (*nodes)[u].first_out = n; 108 edges[n].source = u; 109 edges[n].target = v; 110 110 return Edge(n); 111 111 } … … 189 189 int id(const Edge& edge) const { return edge.id; } 190 190 191 Node nodeFromId(int i d) const { return graph->nodeFromId(id); }192 Edge edgeFromId(int i d) const { return Edge(id); }191 Node nodeFromId(int ix) const { return graph->nodeFromId(ix); } 192 Edge edgeFromId(int ix) const { return Edge(ix); } 193 193 194 194 int maxNodeId() const { return graph->maxNodeId(); }; … … 294 294 } 295 295 virtual void erase(const std::vector<Node>& nodes) { 296 for (int i = 0; i < (int)nodes.size(); ++i) {296 for (int i = 0; i < int(nodes.size()); ++i) { 297 297 _edgeset.eraseNode(nodes[i]); 298 298 } … … 383 383 } 384 384 virtual void erase(const std::vector<Node>& nodes) { 385 for (int i = 0; i < (int)nodes.size(); ++i) {385 for (int i = 0; i < int(nodes.size()); ++i) { 386 386 _edgeset.eraseNode(nodes[i]); 387 387 } … … 461 461 SmartEdgeSetBase() {} 462 462 463 Edge addEdge(const Node& source, const Node& target) {463 Edge addEdge(const Node& u, const Node& v) { 464 464 int n = edges.size(); 465 465 edges.push_back(EdgeT()); 466 edges[n].next_in = (*nodes)[ target].first_in;467 (*nodes)[ target].first_in = n;468 edges[n].next_out = (*nodes)[ source].first_out;469 (*nodes)[ source].first_out = n;470 edges[n].source = source;471 edges[n].target = target;466 edges[n].next_in = (*nodes)[v].first_in; 467 (*nodes)[v].first_in = n; 468 edges[n].next_out = (*nodes)[u].first_out; 469 (*nodes)[u].first_out = n; 470 edges[n].source = u; 471 edges[n].target = v; 472 472 return Edge(n); 473 473 } … … 517 517 int id(const Edge& edge) const { return edge.id; } 518 518 519 Node nodeFromId(int i d) const { return graph->nodeFromId(id); }520 Edge edgeFromId(int i d) const { return Edge(id); }519 Node nodeFromId(int ix) const { return graph->nodeFromId(ix); } 520 Edge edgeFromId(int ix) const { return Edge(ix); } 521 521 522 522 int maxNodeId() const { return graph->maxNodeId(); }; … … 627 627 virtual void erase(const std::vector<Node>& nodes) { 628 628 try { 629 for (int i = 0; i < (int)nodes.size(); ++i) {629 for (int i = 0; i < int(nodes.size()); ++i) { 630 630 _edgeset.eraseNode(nodes[i]); 631 631 } … … 732 732 virtual void erase(const std::vector<Node>& nodes) { 733 733 try { 734 for (int i = 0; i < (int)nodes.size(); ++i) {734 for (int i = 0; i < int(nodes.size()); ++i) { 735 735 _edgeset.eraseNode(nodes[i]); 736 736 } -
lemon/error.h
r2175 r2386 127 127 128 128 ///\e 129 ErrorMessage(const char *m essage) throw() {129 ErrorMessage(const char *msg) throw() { 130 130 init(); 131 *this << m essage;132 } 133 134 ///\e 135 ErrorMessage(const std::string &m essage) throw() {131 *this << msg; 132 } 133 134 ///\e 135 ErrorMessage(const std::string &msg) throw() { 136 136 init(); 137 *this << m essage;137 *this << msg; 138 138 } 139 139 … … 267 267 268 268 ///\e 269 void line(int l ine) { _line = line; }270 ///\e 271 void message(const std::string& m essage) { _message.set(message); }272 ///\e 273 void file(const std::string &f ile) { _file.set(file); }269 void line(int ln) { _line = ln; } 270 ///\e 271 void message(const std::string& msg) { _message.set(msg); } 272 ///\e 273 void file(const std::string &fl) { _file.set(fl); } 274 274 275 275 ///\e … … 330 330 331 331 ///\e 332 explicit FileOpenError(const std::string& f ile)333 : _file(f ile) {}334 335 336 ///\e 337 void file(const std::string &f ile) { _file.set(file); }332 explicit FileOpenError(const std::string& fl) 333 : _file(fl) {} 334 335 336 ///\e 337 void file(const std::string &fl) { _file.set(fl); } 338 338 339 339 /// \brief Returns the filename. … … 383 383 384 384 ///\e 385 void message(const std::string& m essage) { _message.set(message); }386 ///\e 387 void file(const std::string &f ile) { _file.set(file); }385 void message(const std::string& msg) { _message.set(msg); } 386 ///\e 387 void file(const std::string &fl) { _file.set(fl); } 388 388 389 389 ///\e -
lemon/full_graph.h
r2384 r2386 57 57 typedef True EdgeNumTag; 58 58 59 Node operator()(int i ndex) const { return Node(index); }59 Node operator()(int ix) const { return Node(ix); } 60 60 int index(const Node& node) const { return node.id; } 61 61 … … 130 130 } 131 131 132 void first(Edge& e dge) const {133 e dge.id = _edgeNum-1;134 } 135 136 static void next(Edge& e dge) {137 --e dge.id;138 } 139 140 void firstOut(Edge& e dge, const Node& node) const {141 e dge.id = _edgeNum + node.id - _nodeNum;142 } 143 144 void nextOut(Edge& e dge) const {145 e dge.id -= _nodeNum;146 if (e dge.id < 0) edge.id = -1;147 } 148 149 void firstIn(Edge& e dge, const Node& node) const {150 e dge.id = node.id * _nodeNum;132 void first(Edge& e) const { 133 e.id = _edgeNum-1; 134 } 135 136 static void next(Edge& e) { 137 --e.id; 138 } 139 140 void firstOut(Edge& e, const Node& n) const { 141 e.id = _edgeNum + n.id - _nodeNum; 142 } 143 144 void nextOut(Edge& e) const { 145 e.id -= _nodeNum; 146 if (e.id < 0) e.id = -1; 147 } 148 149 void firstIn(Edge& e, const Node& n) const { 150 e.id = n.id * _nodeNum; 151 151 } 152 152 153 void nextIn(Edge& e dge) const {154 ++e dge.id;155 if (e dge.id % _nodeNum == 0) edge.id = -1;153 void nextIn(Edge& e) const { 154 ++e.id; 155 if (e.id % _nodeNum == 0) e.id = -1; 156 156 } 157 157 … … 208 208 /// by the range from 0 to \e nodeNum()-1 and the index of 209 209 /// the node can accessed by the \e index() member. 210 Node operator()(int i ndex) const { return Parent::operator()(index); }210 Node operator()(int ix) const { return Parent::operator()(ix); } 211 211 212 212 /// \brief Returns the index of the node. … … 251 251 252 252 253 Node operator()(int i ndex) const { return Node(index); }253 Node operator()(int ix) const { return Node(ix); } 254 254 int index(const Node& node) const { return node.id; } 255 255 … … 272 272 Node source(Edge e) const { 273 273 /// \todo we may do it faster 274 return Node(( (int)sqrt((double)(1 + 8 * e.id)) + 1) / 2);274 return Node((int(sqrt(double(1 + 8 * e.id)) + 1)) / 2); 275 275 } 276 276 277 277 Node target(Edge e) const { 278 int s ource = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;279 return Node(e.id - (source) * (source- 1) / 2);278 int s = (int(sqrt(double(1 + 8 * e.id)) + 1)) / 2; 279 return Node(e.id - s * (s - 1) / 2); 280 280 } 281 281 … … 323 323 }; 324 324 325 void first(Node& n ode) const {326 n ode.id = _nodeNum - 1;327 } 328 329 static void next(Node& n ode) {330 --n ode.id;331 } 332 333 void first(Edge& e dge) const {334 e dge.id = _edgeNum - 1;335 } 336 337 static void next(Edge& e dge) {338 --e dge.id;339 } 340 341 void firstOut(Edge& e dge, const Node& node) const {342 int src = n ode.id;325 void first(Node& n) const { 326 n.id = _nodeNum - 1; 327 } 328 329 static void next(Node& n) { 330 --n.id; 331 } 332 333 void first(Edge& e) const { 334 e.id = _edgeNum - 1; 335 } 336 337 static void next(Edge& e) { 338 --e.id; 339 } 340 341 void firstOut(Edge& e, const Node& n) const { 342 int src = n.id; 343 343 int trg = 0; 344 e dge.id = (trg < src ? src * (src - 1) / 2 + trg : -1);344 e.id = (trg < src ? src * (src - 1) / 2 + trg : -1); 345 345 } 346 346 347 347 /// \todo with specialized iterators we can make faster iterating 348 void nextOut(Edge& e dge) const {349 int src = source(e dge).id;350 int trg = target(e dge).id;348 void nextOut(Edge& e) const { 349 int src = source(e).id; 350 int trg = target(e).id; 351 351 ++trg; 352 e dge.id = (trg < src ? src * (src - 1) / 2 + trg : -1);353 } 354 355 void firstIn(Edge& e dge, const Node& node) const {356 int src = n ode.id + 1;357 int trg = n ode.id;358 e dge.id = (src < _nodeNum ? src * (src - 1) / 2 + trg : -1);352 e.id = (trg < src ? src * (src - 1) / 2 + trg : -1); 353 } 354 355 void firstIn(Edge& e, const Node& n) const { 356 int src = n.id + 1; 357 int trg = n.id; 358 e.id = (src < _nodeNum ? src * (src - 1) / 2 + trg : -1); 359 359 } 360 360 361 void nextIn(Edge& e dge) const {362 int src = source(e dge).id;363 int trg = target(e dge).id;361 void nextIn(Edge& e) const { 362 int src = source(e).id; 363 int trg = target(e).id; 364 364 ++src; 365 e dge.id = (src < _nodeNum ? src * (src - 1) / 2 + trg : -1);365 e.id = (src < _nodeNum ? src * (src - 1) / 2 + trg : -1); 366 366 } 367 367 … … 422 422 /// by the range from 0 to \e nodeNum()-1 and the index of 423 423 /// the node can accessed by the \e index() member. 424 Node operator()(int i ndex) const { return Parent::operator()(index); }424 Node operator()(int ix) const { return Parent::operator()(ix); } 425 425 426 426 /// \brief Returns the index of the node. … … 479 479 FullBpUGraphBase() {} 480 480 481 void construct(int a NodeNum, int bNodeNum) {482 _aNodeNum = a NodeNum;483 _bNodeNum = b NodeNum;484 _edgeNum = a NodeNum * bNodeNum;481 void construct(int ann, int bnn) { 482 _aNodeNum = ann; 483 _bNodeNum = bnn; 484 _edgeNum = ann * bnn; 485 485 } 486 486 … … 522 522 }; 523 523 524 Node aNode(int i ndex) const { return Node(index << 1); }525 Node bNode(int i ndex) const { return Node((index << 1) + 1); }524 Node aNode(int ix) const { return Node(ix << 1); } 525 Node bNode(int ix) const { return Node((ix << 1) + 1); } 526 526 527 527 int aNodeIndex(const Node& node) const { return node.id >> 1; } … … 696 696 } 697 697 698 FullBpUGraph(int a NodeNum, int bNodeNum) {699 Parent::construct(a NodeNum, bNodeNum);698 FullBpUGraph(int ann, int bnn) { 699 Parent::construct(ann, bnn); 700 700 } 701 701 … … 738 738 /// by the range from 0 to \e aNodeNum()-1 and the index of 739 739 /// the node can accessed by the \e aNodeIndex() member. 740 Node aNode(int i ndex) const { return Parent::aNode(index); }740 Node aNode(int ix) const { return Parent::aNode(ix); } 741 741 742 742 /// \brief Returns the B-node with the given index. … … 746 746 /// by the range from 0 to \e bNodeNum()-1 and the index of 747 747 /// the node can accessed by the \e bNodeIndex() member. 748 Node bNode(int i ndex) const { return Parent::bNode(index); }748 Node bNode(int ix) const { return Parent::bNode(ix); } 749 749 750 750 /// \brief Returns the index of the A-node. -
lemon/graph_adaptor.h
r2384 r2386 94 94 95 95 typedef FindEdgeTagIndicator<Graph> FindEdgeTag; 96 Edge findEdge(const Node& source, const Node& target,96 Edge findEdge(const Node& u, const Node& v, 97 97 const Edge& prev = INVALID) { 98 return graph->findEdge( source, target, prev);98 return graph->findEdge(u, v, prev); 99 99 } 100 100 … … 103 103 } 104 104 105 Edge addEdge(const Node& source, const Node& target) const {106 return Edge(graph->addEdge( source, target));105 Edge addEdge(const Node& u, const Node& v) const { 106 return Edge(graph->addEdge(u, v)); 107 107 } 108 108 … … 115 115 int id(const Edge& e) const { return graph->id(e); } 116 116 117 Node fromNodeId(int i d) const {118 return graph->fromNodeId(i d);119 } 120 121 Edge fromEdgeId(int i d) const {122 return graph->fromEdgeId(i d);117 Node fromNodeId(int ix) const { 118 return graph->fromNodeId(ix); 119 } 120 121 Edge fromEdgeId(int ix) const { 122 return graph->fromEdgeId(ix); 123 123 } 124 124 … … 244 244 245 245 typedef FindEdgeTagIndicator<Graph> FindEdgeTag; 246 Edge findEdge(const Node& source, const Node& target,246 Edge findEdge(const Node& u, const Node& v, 247 247 const Edge& prev = INVALID) { 248 return Parent::findEdge( target, source, prev);248 return Parent::findEdge(v, u, prev); 249 249 } 250 250 … … 461 461 template NodeMap<_Value> > Parent; 462 462 463 NodeMap(const Graph& g raph)464 : Parent(g raph) {}465 NodeMap(const Graph& g raph, const _Value& value)466 : Parent(g raph, value) {}463 NodeMap(const Graph& g) 464 : Parent(g) {} 465 NodeMap(const Graph& g, const _Value& v) 466 : Parent(g, v) {} 467 467 468 468 NodeMap& operator=(const NodeMap& cmap) { … … 487 487 template EdgeMap<_Value> > Parent; 488 488 489 EdgeMap(const Graph& g raph)490 : Parent(g raph) {}491 EdgeMap(const Graph& g raph, const _Value& value)492 : Parent(g raph, value) {}489 EdgeMap(const Graph& g) 490 : Parent(g) {} 491 EdgeMap(const Graph& g, const _Value& v) 492 : Parent(g, v) {} 493 493 494 494 EdgeMap& operator=(const EdgeMap& cmap) { … … 634 634 template NodeMap<_Value> > Parent; 635 635 636 NodeMap(const Graph& g raph)637 : Parent(g raph) {}638 NodeMap(const Graph& g raph, const _Value& value)639 : Parent(g raph, value) {}636 NodeMap(const Graph& g) 637 : Parent(g) {} 638 NodeMap(const Graph& g, const _Value& v) 639 : Parent(g, v) {} 640 640 641 641 NodeMap& operator=(const NodeMap& cmap) { … … 660 660 template EdgeMap<_Value> > Parent; 661 661 662 EdgeMap(const Graph& g raph)663 : Parent(g raph) {}664 EdgeMap(const Graph& g raph, const _Value& value)665 : Parent(g raph, value) {}662 EdgeMap(const Graph& g) 663 : Parent(g) {} 664 EdgeMap(const Graph& g, const _Value& v) 665 : Parent(g, v) {} 666 666 667 667 EdgeMap& operator=(const EdgeMap& cmap) { … … 1106 1106 typedef SubMapExtender<Adaptor, EdgeMapBase<_Value> > Parent; 1107 1107 1108 EdgeMap(const Graph& g raph)1109 : Parent(g raph) {}1110 EdgeMap(const Graph& g raph, const _Value& value)1111 : Parent(g raph, value) {}1108 EdgeMap(const Graph& g) 1109 : Parent(g) {} 1110 EdgeMap(const Graph& g, const _Value& v) 1111 : Parent(g, v) {} 1112 1112 1113 1113 EdgeMap& operator=(const EdgeMap& cmap) { … … 1181 1181 : Parent(), edge_notifier(*this), edge_notifier_proxy(*this) {} 1182 1182 1183 void setGraph(_Graph& g raph) {1184 Parent::setGraph(g raph);1185 edge_notifier_proxy.setNotifier(g raph.notifier(GraphEdge()));1183 void setGraph(_Graph& g) { 1184 Parent::setGraph(g); 1185 edge_notifier_proxy.setNotifier(g.notifier(GraphEdge())); 1186 1186 } 1187 1187 … … 1221 1221 } 1222 1222 1223 void setNotifier(typename Graph::EdgeNotifier& n otifier) {1224 Parent::attach(n otifier);1223 void setNotifier(typename Graph::EdgeNotifier& nf) { 1224 Parent::attach(nf); 1225 1225 } 1226 1226 … … 1236 1236 virtual void add(const std::vector<GraphEdge>& ge) { 1237 1237 std::vector<Edge> edges; 1238 for (int i = 0; i < (int)ge.size(); ++i) {1238 for (int i = 0; i < int(ge.size()); ++i) { 1239 1239 edges.push_back(AdaptorBase::Parent::direct(ge[i], true)); 1240 1240 edges.push_back(AdaptorBase::Parent::direct(ge[i], false)); … … 1250 1250 virtual void erase(const std::vector<GraphEdge>& ge) { 1251 1251 std::vector<Edge> edges; 1252 for (int i = 0; i < (int)ge.size(); ++i) {1252 for (int i = 0; i < int(ge.size()); ++i) { 1253 1253 edges.push_back(AdaptorBase::Parent::direct(ge[i], true)); 1254 1254 edges.push_back(AdaptorBase::Parent::direct(ge[i], false)); … … 1822 1822 }; 1823 1823 1824 void first(Node& n ode) const {1825 Parent::first(n ode);1826 n ode.in_node = true;1827 } 1828 1829 void next(Node& n ode) const {1830 if (n ode.in_node) {1831 n ode.in_node = false;1824 void first(Node& n) const { 1825 Parent::first(n); 1826 n.in_node = true; 1827 } 1828 1829 void next(Node& n) const { 1830 if (n.in_node) { 1831 n.in_node = false; 1832 1832 } else { 1833 n ode.in_node = true;1834 Parent::next(n ode);1835 } 1836 } 1837 1838 void first(Edge& e dge) const {1839 e dge.item.setSecond();1840 Parent::first(e dge.item.second());1841 if (e dge.item.second() == INVALID) {1842 e dge.item.setFirst();1843 Parent::first(e dge.item.first());1844 } 1845 } 1846 1847 void next(Edge& e dge) const {1848 if (e dge.item.secondState()) {1849 Parent::next(e dge.item.second());1850 if (e dge.item.second() == INVALID) {1851 e dge.item.setFirst();1852 Parent::first(e dge.item.first());1833 n.in_node = true; 1834 Parent::next(n); 1835 } 1836 } 1837 1838 void first(Edge& e) const { 1839 e.item.setSecond(); 1840 Parent::first(e.item.second()); 1841 if (e.item.second() == INVALID) { 1842 e.item.setFirst(); 1843 Parent::first(e.item.first()); 1844 } 1845 } 1846 1847 void next(Edge& e) const { 1848 if (e.item.secondState()) { 1849 Parent::next(e.item.second()); 1850 if (e.item.second() == INVALID) { 1851 e.item.setFirst(); 1852 Parent::first(e.item.first()); 1853 1853 } 1854 1854 } else { 1855 Parent::next(e dge.item.first());1855 Parent::next(e.item.first()); 1856 1856 } 1857 1857 } 1858 1858 1859 void firstOut(Edge& e dge, const Node& node) const {1860 if (n ode.in_node) {1861 e dge.item.setSecond(node);1859 void firstOut(Edge& e, const Node& n) const { 1860 if (n.in_node) { 1861 e.item.setSecond(n); 1862 1862 } else { 1863 e dge.item.setFirst();1864 Parent::firstOut(e dge.item.first(), node);1865 } 1866 } 1867 1868 void nextOut(Edge& e dge) const {1869 if (!e dge.item.firstState()) {1870 e dge.item.setFirst(INVALID);1863 e.item.setFirst(); 1864 Parent::firstOut(e.item.first(), n); 1865 } 1866 } 1867 1868 void nextOut(Edge& e) const { 1869 if (!e.item.firstState()) { 1870 e.item.setFirst(INVALID); 1871 1871 } else { 1872 Parent::nextOut(e dge.item.first());1872 Parent::nextOut(e.item.first()); 1873 1873 } 1874 1874 } 1875 1875 1876 void firstIn(Edge& e dge, const Node& node) const {1877 if (!n ode.in_node) {1878 e dge.item.setSecond(node);1876 void firstIn(Edge& e, const Node& n) const { 1877 if (!n.in_node) { 1878 e.item.setSecond(n); 1879 1879 } else { 1880 e dge.item.setFirst();1881 Parent::firstIn(e dge.item.first(), node);1882 } 1883 } 1884 1885 void nextIn(Edge& e dge) const {1886 if (!e dge.item.firstState()) {1887 e dge.item.setFirst(INVALID);1880 e.item.setFirst(); 1881 Parent::firstIn(e.item.first(), n); 1882 } 1883 } 1884 1885 void nextIn(Edge& e) const { 1886 if (!e.item.firstState()) { 1887 e.item.setFirst(INVALID); 1888 1888 } else { 1889 Parent::nextIn(e dge.item.first());1890 } 1891 } 1892 1893 Node source(const Edge& e dge) const {1894 if (e dge.item.firstState()) {1895 return Node(Parent::source(e dge.item.first()), false);1889 Parent::nextIn(e.item.first()); 1890 } 1891 } 1892 1893 Node source(const Edge& e) const { 1894 if (e.item.firstState()) { 1895 return Node(Parent::source(e.item.first()), false); 1896 1896 } else { 1897 return Node(e dge.item.second(), true);1898 } 1899 } 1900 1901 Node target(const Edge& e dge) const {1902 if (e dge.item.firstState()) {1903 return Node(Parent::target(e dge.item.first()), true);1897 return Node(e.item.second(), true); 1898 } 1899 } 1900 1901 Node target(const Edge& e) const { 1902 if (e.item.firstState()) { 1903 return Node(Parent::target(e.item.first()), true); 1904 1904 } else { 1905 return Node(e dge.item.second(), false);1906 } 1907 } 1908 1909 int id(const Node& n ode) const {1910 return (Parent::id(n ode) << 1) | (node.in_node ? 0 : 1);1911 } 1912 Node nodeFromId(int i d) const {1913 return Node(Parent::nodeFromId(i d >> 1), (id& 1) == 0);1905 return Node(e.item.second(), false); 1906 } 1907 } 1908 1909 int id(const Node& n) const { 1910 return (Parent::id(n) << 1) | (n.in_node ? 0 : 1); 1911 } 1912 Node nodeFromId(int ix) const { 1913 return Node(Parent::nodeFromId(ix >> 1), (ix & 1) == 0); 1914 1914 } 1915 1915 int maxNodeId() const { … … 1917 1917 } 1918 1918 1919 int id(const Edge& e dge) const {1920 if (e dge.item.firstState()) {1921 return Parent::id(e dge.item.first()) << 1;1919 int id(const Edge& e) const { 1920 if (e.item.firstState()) { 1921 return Parent::id(e.item.first()) << 1; 1922 1922 } else { 1923 return (Parent::id(e dge.item.second()) << 1) | 1;1924 } 1925 } 1926 Edge edgeFromId(int i d) const {1927 if ((i d& 1) == 0) {1928 return Edge(Parent::edgeFromId(i d>> 1));1923 return (Parent::id(e.item.second()) << 1) | 1; 1924 } 1925 } 1926 Edge edgeFromId(int ix) const { 1927 if ((ix & 1) == 0) { 1928 return Edge(Parent::edgeFromId(ix >> 1)); 1929 1929 } else { 1930 return Edge(Parent::nodeFromId(i d>> 1));1930 return Edge(Parent::nodeFromId(ix >> 1)); 1931 1931 } 1932 1932 } … … 1939 1939 /// 1940 1940 /// Returns true when the node is in-node. 1941 static bool inNode(const Node& n ode) {1942 return n ode.in_node;1941 static bool inNode(const Node& n) { 1942 return n.in_node; 1943 1943 } 1944 1944 … … 1946 1946 /// 1947 1947 /// Returns true when the node is out-node. 1948 static bool outNode(const Node& n ode) {1949 return !n ode.in_node;1948 static bool outNode(const Node& n) { 1949 return !n.in_node; 1950 1950 } 1951 1951 … … 1953 1953 /// 1954 1954 /// Returns true when the edge is edge in the original graph. 1955 static bool origEdge(const Edge& e dge) {1956 return e dge.item.firstState();1955 static bool origEdge(const Edge& e) { 1956 return e.item.firstState(); 1957 1957 } 1958 1958 … … 1960 1960 /// 1961 1961 /// Returns true when the edge binds an in-node and an out-node. 1962 static bool bindEdge(const Edge& e dge) {1963 return e dge.item.secondState();1962 static bool bindEdge(const Edge& e) { 1963 return e.item.secondState(); 1964 1964 } 1965 1965 … … 1967 1967 /// 1968 1968 /// Gives back the in-node created from the \c node. 1969 static Node inNode(const GraphNode& n ode) {1970 return Node(n ode, true);1969 static Node inNode(const GraphNode& n) { 1970 return Node(n, true); 1971 1971 } 1972 1972 … … 1974 1974 /// 1975 1975 /// Gives back the out-node created from the \c node. 1976 static Node outNode(const GraphNode& n ode) {1977 return Node(n ode, false);1976 static Node outNode(const GraphNode& n) { 1977 return Node(n, false); 1978 1978 } 1979 1979 … … 1981 1981 /// 1982 1982 /// Gives back the edge binds the two part of the node. 1983 static Edge edge(const GraphNode& n ode) {1984 return Edge(n ode);1983 static Edge edge(const GraphNode& n) { 1984 return Edge(n); 1985 1985 } 1986 1986 … … 1988 1988 /// 1989 1989 /// Gives back the edge of the original edge. 1990 static Edge edge(const GraphEdge& e dge) {1991 return Edge(e dge);1990 static Edge edge(const GraphEdge& e) { 1991 return Edge(e); 1992 1992 } 1993 1993 … … 2006 2006 typedef True FindEdgeTag; 2007 2007 2008 Edge findEdge(const Node& source, const Node& target,2008 Edge findEdge(const Node& u, const Node& v, 2009 2009 const Edge& prev = INVALID) const { 2010 if (inNode(source)) { 2011 if (outNode(target)) { 2012 if ((GraphNode&)source == (GraphNode&)target && prev == INVALID) { 2013 return Edge(source); 2010 if (inNode(u)) { 2011 if (outNode(v)) { 2012 if (static_cast<const GraphNode&>(u) == 2013 static_cast<const GraphNode&>(v) && prev == INVALID) { 2014 return Edge(u); 2014 2015 } 2015 2016 } 2016 2017 } else { 2017 if (inNode( target)) {2018 return Edge(findEdge(*Parent::graph, source, target, prev));2018 if (inNode(v)) { 2019 return Edge(findEdge(*Parent::graph, u, v, prev)); 2019 2020 } 2020 2021 } … … 2192 2193 virtual void add(const std::vector<GraphNode>& gn) { 2193 2194 std::vector<Node> nodes; 2194 for (int i = 0; i < (int)gn.size(); ++i) {2195 for (int i = 0; i < int(gn.size()); ++i) { 2195 2196 nodes.push_back(AdaptorBase::Parent::inNode(gn[i])); 2196 2197 nodes.push_back(AdaptorBase::Parent::outNode(gn[i])); … … 2208 2209 virtual void erase(const std::vector<GraphNode>& gn) { 2209 2210 std::vector<Node> nodes; 2210 for (int i = 0; i < (int)gn.size(); ++i) {2211 for (int i = 0; i < int(gn.size()); ++i) { 2211 2212 nodes.push_back(AdaptorBase::Parent::inNode(gn[i])); 2212 2213 nodes.push_back(AdaptorBase::Parent::outNode(gn[i])); … … 2254 2255 node_notifier_proxy(*this), edge_notifier_proxy(*this) {} 2255 2256 2256 void setGraph(_Graph& g raph) {2257 Parent::setGraph(g raph);2258 node_notifier_proxy.setNotifier(g raph.notifier(GraphNode()));2259 edge_notifier_proxy.setNotifier(g raph.notifier(GraphEdge()));2257 void setGraph(_Graph& g) { 2258 Parent::setGraph(g); 2259 node_notifier_proxy.setNotifier(g.notifier(GraphNode())); 2260 edge_notifier_proxy.setNotifier(g.notifier(GraphEdge())); 2260 2261 } 2261 2262 … … 2308 2309 std::vector<Node> nodes; 2309 2310 std::vector<Edge> edges; 2310 for (int i = 0; i < (int)gn.size(); ++i) {2311 for (int i = 0; i < int(gn.size()); ++i) { 2311 2312 edges.push_back(AdaptorBase::Parent::edge(gn[i])); 2312 2313 nodes.push_back(AdaptorBase::Parent::inNode(gn[i])); … … 2326 2327 std::vector<Node> nodes; 2327 2328 std::vector<Edge> edges; 2328 for (int i = 0; i < (int)gn.size(); ++i) {2329 for (int i = 0; i < int(gn.size()); ++i) { 2329 2330 edges.push_back(AdaptorBase::Parent::edge(gn[i])); 2330 2331 nodes.push_back(AdaptorBase::Parent::inNode(gn[i])); … … 2336 2337 virtual void build() { 2337 2338 std::vector<Edge> edges; 2338 const typename Parent::Notifier* n otifier= Parent::notifier();2339 const typename Parent::Notifier* nf = Parent::notifier(); 2339 2340 GraphNode it; 2340 for (n otifier->first(it); it != INVALID; notifier->next(it)) {2341 for (nf->first(it); it != INVALID; nf->next(it)) { 2341 2342 edges.push_back(AdaptorBase::Parent::edge(it)); 2342 2343 } … … 2346 2347 virtual void clear() { 2347 2348 std::vector<Edge> edges; 2348 const typename Parent::Notifier* n otifier= Parent::notifier();2349 const typename Parent::Notifier* nf = Parent::notifier(); 2349 2350 GraphNode it; 2350 for (n otifier->first(it); it != INVALID; notifier->next(it)) {2351 for (nf->first(it); it != INVALID; nf->next(it)) { 2351 2352 edges.push_back(AdaptorBase::Parent::edge(it)); 2352 2353 } … … 2386 2387 virtual void add(const std::vector<GraphEdge>& ge) { 2387 2388 std::vector<Edge> edges; 2388 for (int i = 0; i < (int)ge.size(); ++i) {2389 for (int i = 0; i < int(ge.size()); ++i) { 2389 2390 edges.push_back(AdaptorBase::edge(ge[i])); 2390 2391 } … … 2396 2397 virtual void erase(const std::vector<GraphEdge>& ge) { 2397 2398 std::vector<Edge> edges; 2398 for (int i = 0; i < (int)ge.size(); ++i) {2399 for (int i = 0; i < int(ge.size()); ++i) { 2399 2400 edges.push_back(AdaptorBase::edge(ge[i])); 2400 2401 } … … 2403 2404 virtual void build() { 2404 2405 std::vector<Edge> edges; 2405 const typename Parent::Notifier* n otifier= Parent::notifier();2406 const typename Parent::Notifier* nf = Parent::notifier(); 2406 2407 GraphEdge it; 2407 for (n otifier->first(it); it != INVALID; notifier->next(it)) {2408 for (nf->first(it); it != INVALID; nf->next(it)) { 2408 2409 edges.push_back(AdaptorBase::Parent::edge(it)); 2409 2410 } … … 2412 2413 virtual void clear() { 2413 2414 std::vector<Edge> edges; 2414 const typename Parent::Notifier* n otifier= Parent::notifier();2415 const typename Parent::Notifier* nf = Parent::notifier(); 2415 2416 GraphEdge it; 2416 for (n otifier->first(it); it != INVALID; notifier->next(it)) {2417 for (nf->first(it); it != INVALID; nf->next(it)) { 2417 2418 edges.push_back(AdaptorBase::Parent::edge(it)); 2418 2419 } … … 2510 2511 /// 2511 2512 /// Constructor of the adaptor. 2512 SplitGraphAdaptor(_Graph& g raph) {2513 Parent::setGraph(g raph);2513 SplitGraphAdaptor(_Graph& g) { 2514 Parent::setGraph(g); 2514 2515 } 2515 2516 -
lemon/graph_reader.h
r2334 r2386 185 185 /// 186 186 /// Give a new node map reading command to the reader. 187 template <typename Reader, typename Map>187 template <typename ItemReader, typename Map> 188 188 GraphReader& readNodeMap(std::string name, Map& map, 189 const Reader& reader =Reader()) {190 nodeset_reader.readNodeMap(name, map, reader);191 return *this; 192 } 193 194 template <typename Reader, typename Map>189 const ItemReader& ir = ItemReader()) { 190 nodeset_reader.readNodeMap(name, map, ir); 191 return *this; 192 } 193 194 template <typename ItemReader, typename Map> 195 195 GraphReader& readNodeMap(std::string name, const Map& map, 196 const Reader& reader =Reader()) {197 nodeset_reader.readNodeMap(name, map, reader);196 const ItemReader& ir = ItemReader()) { 197 nodeset_reader.readNodeMap(name, map, ir); 198 198 return *this; 199 199 } … … 202 202 /// 203 203 /// Give a new node map skipping command to the reader. 204 template <typename Reader>204 template <typename ItemReader> 205 205 GraphReader& skipNodeMap(std::string name, 206 const Reader& reader =Reader()) {207 nodeset_reader.skipNodeMap(name, reader);206 const ItemReader& ir = ItemReader()) { 207 nodeset_reader.skipNodeMap(name, ir); 208 208 return *this; 209 209 } … … 228 228 /// 229 229 /// Give a new edge map reading command to the reader. 230 template <typename Reader, typename Map>230 template <typename ItemReader, typename Map> 231 231 GraphReader& readEdgeMap(std::string name, Map& map, 232 const Reader& reader =Reader()) {233 edgeset_reader.readEdgeMap(name, map, reader);234 return *this; 235 } 236 237 template <typename Reader, typename Map>232 const ItemReader& ir = ItemReader()) { 233 edgeset_reader.readEdgeMap(name, map, ir); 234 return *this; 235 } 236 237 template <typename ItemReader, typename Map> 238 238 GraphReader& readEdgeMap(std::string name, const Map& map, 239 const Reader& reader =Reader()) {240 edgeset_reader.readEdgeMap(name, map, reader);239 const ItemReader& ir = ItemReader()) { 240 edgeset_reader.readEdgeMap(name, map, ir); 241 241 return *this; 242 242 } … … 245 245 /// 246 246 /// Give a new edge map skipping command to the reader. 247 template <typename Reader>247 template <typename ItemReader> 248 248 GraphReader& skipEdgeMap(std::string name, 249 const Reader& reader =Reader()) {250 edgeset_reader.skipEdgeMap(name, reader);249 const ItemReader& ir = ItemReader()) { 250 edgeset_reader.skipEdgeMap(name, ir); 251 251 return *this; 252 252 } … … 280 280 /// 281 281 /// Give a new attribute reading command. 282 template <typename Reader, typename Value>282 template <typename ItemReader, typename Value> 283 283 GraphReader& readAttribute(std::string name, Value& value, 284 const Reader& reader) {285 attribute_reader.readAttribute <Reader>(name, value, reader);284 const ItemReader& ir = ItemReader()) { 285 attribute_reader.readAttribute(name, value, ir); 286 286 return *this; 287 287 } … … 505 505 /// 506 506 /// Give a new node map reading command to the reader. 507 template <typename Reader, typename Map>507 template <typename ItemReader, typename Map> 508 508 UGraphReader& readNodeMap(std::string name, Map& map, 509 const Reader& reader =Reader()) {510 nodeset_reader.readNodeMap(name, map, reader);511 return *this; 512 } 513 514 template <typename Reader, typename Map>509 const ItemReader& ir = ItemReader()) { 510 nodeset_reader.readNodeMap(name, map, ir); 511 return *this; 512 } 513 514 template <typename ItemReader, typename Map> 515 515 UGraphReader& readNodeMap(std::string name, const Map& map, 516 const Reader& reader =Reader()) {517 nodeset_reader.readNodeMap(name, map, reader);516 const ItemReader& ir = ItemReader()) { 517 nodeset_reader.readNodeMap(name, map, ir); 518 518 return *this; 519 519 } … … 522 522 /// 523 523 /// Give a new node map skipping command to the reader. 524 template <typename Reader>524 template <typename ItemReader> 525 525 UGraphReader& skipNodeMap(std::string name, 526 const Reader& reader =Reader()) {527 nodeset_reader.skipNodeMap(name, reader);526 const ItemReader& ir = ItemReader()) { 527 nodeset_reader.skipNodeMap(name, ir); 528 528 return *this; 529 529 } … … 548 548 /// 549 549 /// Give a new undirected edge map reading command to the reader. 550 template <typename Reader, typename Map>550 template <typename ItemReader, typename Map> 551 551 UGraphReader& readUEdgeMap(std::string name, Map& map, 552 const Reader& reader =Reader()) {553 u_edgeset_reader.readUEdgeMap(name, map, reader);554 return *this; 555 } 556 557 template <typename Reader, typename Map>552 const ItemReader& ir = ItemReader()) { 553 u_edgeset_reader.readUEdgeMap(name, map, ir); 554 return *this; 555 } 556 557 template <typename ItemReader, typename Map> 558 558 UGraphReader& readUEdgeMap(std::string name, const Map& map, 559 const Reader& reader =Reader()) {560 u_edgeset_reader.readUEdgeMap(name, map, reader);559 const ItemReader& ir = ItemReader()) { 560 u_edgeset_reader.readUEdgeMap(name, map, ir); 561 561 return *this; 562 562 } … … 565 565 /// 566 566 /// Give a new undirected edge map skipping command to the reader. 567 template <typename Reader>567 template <typename ItemReader> 568 568 UGraphReader& skipUEdgeMap(std::string name, 569 const Reader& reader =Reader()) {570 u_edgeset_reader.skipUMap(name, reader);569 const ItemReader& ir = ItemReader()) { 570 u_edgeset_reader.skipUMap(name, ir); 571 571 return *this; 572 572 } … … 592 592 /// 593 593 /// Give a new edge map reading command to the reader. 594 template <typename Reader, typename Map>594 template <typename ItemReader, typename Map> 595 595 UGraphReader& readEdgeMap(std::string name, Map& map, 596 const Reader& reader =Reader()) {597 u_edgeset_reader.readEdgeMap(name, map, reader);598 return *this; 599 } 600 601 template <typename Reader, typename Map>596 const ItemReader& ir = ItemReader()) { 597 u_edgeset_reader.readEdgeMap(name, map, ir); 598 return *this; 599 } 600 601 template <typename ItemReader, typename Map> 602 602 UGraphReader& readEdgeMap(std::string name, const Map& map, 603 const Reader& reader =Reader()) {604 u_edgeset_reader.readEdgeMap(name, map, reader);603 const ItemReader& ir = ItemReader()) { 604 u_edgeset_reader.readEdgeMap(name, map, ir); 605 605 return *this; 606 606 } … … 609 609 /// 610 610 /// Give a new edge map skipping command to the reader. 611 template <typename Reader>611 template <typename ItemReader> 612 612 UGraphReader& skipEdgeMap(std::string name, 613 const Reader& reader =Reader()) {614 u_edgeset_reader.skipEdgeMap(name, reader);613 const ItemReader& ir = ItemReader()) { 614 u_edgeset_reader.skipEdgeMap(name, ir); 615 615 return *this; 616 616 } … … 651 651 /// 652 652 /// Give a new attribute reading command. 653 template <typename Reader, typename Value>653 template <typename ItemReader, typename Value> 654 654 UGraphReader& readAttribute(std::string name, Value& value, 655 const Reader& reader) {656 attribute_reader.readAttribute <Reader>(name, value, reader);655 const ItemReader& ir = ItemReader()) { 656 attribute_reader.readAttribute(name, value, ir); 657 657 return *this; 658 658 } -
lemon/graph_to_eps.h
r2379 r2386 950 950 dim2::Bezier3 bez(s,mm,mm,t); 951 951 double t1=0,t2=1; 952 for(int i =0;i<INTERPOL_PREC;++i)952 for(int ii=0;ii<INTERPOL_PREC;++ii) 953 953 if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t2=(t1+t2)/2; 954 954 else t1=(t1+t2)/2; … … 957 957 rn*=rn; 958 958 t2=(t1+t2)/2;t1=0; 959 for(int i =0;i<INTERPOL_PREC;++i)959 for(int ii=0;ii<INTERPOL_PREC;++ii) 960 960 if((bez((t1+t2)/2)-apoint).normSquare()>rn) t1=(t1+t2)/2; 961 961 else t2=(t1+t2)/2; -
lemon/graph_utils.h
r2384 r2386 791 791 /// Destructor of the GraphCopy 792 792 ~GraphCopy() { 793 for (int i = 0; i < (int)nodeMapCopies.size(); ++i) {793 for (int i = 0; i < int(nodeMapCopies.size()); ++i) { 794 794 delete nodeMapCopies[i]; 795 795 } 796 for (int i = 0; i < (int)edgeMapCopies.size(); ++i) {796 for (int i = 0; i < int(edgeMapCopies.size()); ++i) { 797 797 delete edgeMapCopies[i]; 798 798 } … … 837 837 /// 838 838 /// Make a copy of the given node. 839 GraphCopy& node(TNode& tnode, const Node& node) {839 GraphCopy& node(TNode& tnode, const Node& snode) { 840 840 nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, Node, 841 NodeRefMap, TNode>(tnode, node));841 NodeRefMap, TNode>(tnode, snode)); 842 842 return *this; 843 843 } … … 880 880 /// 881 881 /// Make a copy of the given edge. 882 GraphCopy& edge(TEdge& tedge, const Edge& edge) {882 GraphCopy& edge(TEdge& tedge, const Edge& sedge) { 883 883 edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, Edge, 884 EdgeRefMap, TEdge>(tedge, edge));884 EdgeRefMap, TEdge>(tedge, sedge)); 885 885 return *this; 886 886 } … … 894 894 _graph_utils_bits::GraphCopySelector<Target>:: 895 895 copy(target, source, nodeRefMap, edgeRefMap); 896 for (int i = 0; i < (int)nodeMapCopies.size(); ++i) {896 for (int i = 0; i < int(nodeMapCopies.size()); ++i) { 897 897 nodeMapCopies[i]->copy(source, nodeRefMap); 898 898 } 899 for (int i = 0; i < (int)edgeMapCopies.size(); ++i) {899 for (int i = 0; i < int(edgeMapCopies.size()); ++i) { 900 900 edgeMapCopies[i]->copy(source, edgeRefMap); 901 901 } … … 968 968 969 969 Value operator[](const Key& key) const { 970 bool forward = (source.direction(key) == 971 (node_ref[source.source((UEdge)key)] == 972 target.source(uedge_ref[(UEdge)key]))); 970 bool forward = 971 (source.direction(key) == 972 (node_ref[source.source(static_cast<const UEdge&>(key))] == 973 target.source(uedge_ref[static_cast<const UEdge&>(key)]))); 973 974 return target.direct(uedge_ref[key], forward); 974 975 } … … 995 996 /// Destructor of the GraphCopy 996 997 ~UGraphCopy() { 997 for (int i = 0; i < (int)nodeMapCopies.size(); ++i) {998 for (int i = 0; i < int(nodeMapCopies.size()); ++i) { 998 999 delete nodeMapCopies[i]; 999 1000 } 1000 for (int i = 0; i < (int)edgeMapCopies.size(); ++i) {1001 for (int i = 0; i < int(edgeMapCopies.size()); ++i) { 1001 1002 delete edgeMapCopies[i]; 1002 1003 } 1003 for (int i = 0; i < (int)uEdgeMapCopies.size(); ++i) {1004 for (int i = 0; i < int(uEdgeMapCopies.size()); ++i) { 1004 1005 delete uEdgeMapCopies[i]; 1005 1006 } … … 1044 1045 /// 1045 1046 /// Make a copy of the given node. 1046 UGraphCopy& node(TNode& tnode, const Node& node) {1047 UGraphCopy& node(TNode& tnode, const Node& snode) { 1047 1048 nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, Node, 1048 NodeRefMap, TNode>(tnode, node));1049 NodeRefMap, TNode>(tnode, snode)); 1049 1050 return *this; 1050 1051 } … … 1087 1088 /// 1088 1089 /// Make a copy of the given edge. 1089 UGraphCopy& edge(TEdge& tedge, const Edge& edge) {1090 UGraphCopy& edge(TEdge& tedge, const Edge& sedge) { 1090 1091 edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, Edge, 1091 EdgeRefMap, TEdge>(tedge, edge));1092 EdgeRefMap, TEdge>(tedge, sedge)); 1092 1093 return *this; 1093 1094 } … … 1130 1131 /// 1131 1132 /// Make a copy of the given undirected edge. 1132 UGraphCopy& uEdge(TUEdge& tuedge, const UEdge& uedge) {1133 UGraphCopy& uEdge(TUEdge& tuedge, const UEdge& suedge) { 1133 1134 uEdgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, UEdge, 1134 UEdgeRefMap, TUEdge>(tuedge, uedge));1135 UEdgeRefMap, TUEdge>(tuedge, suedge)); 1135 1136 return *this; 1136 1137 } … … 1145 1146 _graph_utils_bits::UGraphCopySelector<Target>:: 1146 1147 copy(target, source, nodeRefMap, uEdgeRefMap); 1147 for (int i = 0; i < (int)nodeMapCopies.size(); ++i) {1148 for (int i = 0; i < int(nodeMapCopies.size()); ++i) { 1148 1149 nodeMapCopies[i]->copy(source, nodeRefMap); 1149 1150 } 1150 for (int i = 0; i < (int)uEdgeMapCopies.size(); ++i) {1151 for (int i = 0; i < int(uEdgeMapCopies.size()); ++i) { 1151 1152 uEdgeMapCopies[i]->copy(source, uEdgeRefMap); 1152 1153 } 1153 for (int i = 0; i < (int)edgeMapCopies.size(); ++i) {1154 for (int i = 0; i < int(edgeMapCopies.size()); ++i) { 1154 1155 edgeMapCopies[i]->copy(source, edgeRefMap); 1155 1156 } … … 1246 1247 1247 1248 Value operator[](const Key& key) const { 1248 bool forward = (source.direction(key) == 1249 (node_ref[source.source((UEdge)key)] == 1250 target.source(uedge_ref[(UEdge)key]))); 1249 bool forward = 1250 (source.direction(key) == 1251 (node_ref[source.source(static_cast<const UEdge&>(key))] == 1252 target.source(uedge_ref[static_cast<const UEdge&>(key)]))); 1251 1253 return target.direct(uedge_ref[key], forward); 1252 1254 } … … 1272 1274 /// Destructor of the GraphCopy 1273 1275 ~BpUGraphCopy() { 1274 for (int i = 0; i < (int)aNodeMapCopies.size(); ++i) {1276 for (int i = 0; i < int(aNodeMapCopies.size()); ++i) { 1275 1277 delete aNodeMapCopies[i]; 1276 1278 } 1277 for (int i = 0; i < (int)bNodeMapCopies.size(); ++i) {1279 for (int i = 0; i < int(bNodeMapCopies.size()); ++i) { 1278 1280 delete bNodeMapCopies[i]; 1279 1281 } 1280 for (int i = 0; i < (int)nodeMapCopies.size(); ++i) {1282 for (int i = 0; i < int(nodeMapCopies.size()); ++i) { 1281 1283 delete nodeMapCopies[i]; 1282 1284 } 1283 for (int i = 0; i < (int)edgeMapCopies.size(); ++i) {1285 for (int i = 0; i < int(edgeMapCopies.size()); ++i) { 1284 1286 delete edgeMapCopies[i]; 1285 1287 } 1286 for (int i = 0; i < (int)uEdgeMapCopies.size(); ++i) {1288 for (int i = 0; i < int(uEdgeMapCopies.size()); ++i) { 1287 1289 delete uEdgeMapCopies[i]; 1288 1290 } … … 1394 1396 /// 1395 1397 /// Make a copy of the given node. 1396 BpUGraphCopy& node(TNode& tnode, const Node& node) {1398 BpUGraphCopy& node(TNode& tnode, const Node& snode) { 1397 1399 nodeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, Node, 1398 NodeRefMap, TNode>(tnode, node));1400 NodeRefMap, TNode>(tnode, snode)); 1399 1401 return *this; 1400 1402 } … … 1437 1439 /// 1438 1440 /// Make a copy of the given edge. 1439 BpUGraphCopy& edge(TEdge& tedge, const Edge& edge) {1441 BpUGraphCopy& edge(TEdge& tedge, const Edge& sedge) { 1440 1442 edgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, Edge, 1441 EdgeRefMap, TEdge>(tedge, edge));1443 EdgeRefMap, TEdge>(tedge, sedge)); 1442 1444 return *this; 1443 1445 } … … 1480 1482 /// 1481 1483 /// Make a copy of the given undirected edge. 1482 BpUGraphCopy& uEdge(TUEdge& tuedge, const UEdge& uedge) {1484 BpUGraphCopy& uEdge(TUEdge& tuedge, const UEdge& suedge) { 1483 1485 uEdgeMapCopies.push_back(new _graph_utils_bits::ItemCopy<Source, UEdge, 1484 UEdgeRefMap, TUEdge>(tuedge, uedge));1486 UEdgeRefMap, TUEdge>(tuedge, suedge)); 1485 1487 return *this; 1486 1488 } … … 1497 1499 _graph_utils_bits::BpUGraphCopySelector<Target>:: 1498 1500 copy(target, source, aNodeRefMap, bNodeRefMap, uEdgeRefMap); 1499 for (int i = 0; i < (int)aNodeMapCopies.size(); ++i) {1501 for (int i = 0; i < int(aNodeMapCopies.size()); ++i) { 1500 1502 aNodeMapCopies[i]->copy(source, aNodeRefMap); 1501 1503 } 1502 for (int i = 0; i < (int)bNodeMapCopies.size(); ++i) {1504 for (int i = 0; i < int(bNodeMapCopies.size()); ++i) { 1503 1505 bNodeMapCopies[i]->copy(source, bNodeRefMap); 1504 1506 } 1505 for (int i = 0; i < (int)nodeMapCopies.size(); ++i) {1507 for (int i = 0; i < int(nodeMapCopies.size()); ++i) { 1506 1508 nodeMapCopies[i]->copy(source, nodeRefMap); 1507 1509 } 1508 for (int i = 0; i < (int)uEdgeMapCopies.size(); ++i) {1510 for (int i = 0; i < int(uEdgeMapCopies.size()); ++i) { 1509 1511 uEdgeMapCopies[i]->copy(source, uEdgeRefMap); 1510 1512 } 1511 for (int i = 0; i < (int)edgeMapCopies.size(); ++i) {1513 for (int i = 0; i < int(edgeMapCopies.size()); ++i) { 1512 1514 edgeMapCopies[i]->copy(source, edgeRefMap); 1513 1515 } … … 1778 1780 /// \c AlterationNotifier. 1779 1781 virtual void erase(const std::vector<Key>& keys) { 1780 for (int i = 0; i < (int)keys.size(); ++i) {1782 for (int i = 0; i < int(keys.size()); ++i) { 1781 1783 Value val = Map::operator[](keys[i]); 1782 1784 typename Container::iterator it = invMap.find(val); … … 1874 1876 explicit DescriptorMap(const Graph& _graph) : Map(_graph) { 1875 1877 Item it; 1876 const typename Map::Notifier* n otifier= Map::notifier();1877 for (n otifier->first(it); it != INVALID; notifier->next(it)) {1878 const typename Map::Notifier* nf = Map::notifier(); 1879 for (nf->first(it); it != INVALID; nf->next(it)) { 1878 1880 Map::set(it, invMap.size()); 1879 1881 invMap.push_back(it); … … 1899 1901 virtual void add(const std::vector<Item>& items) { 1900 1902 Map::add(items); 1901 for (int i = 0; i < (int)items.size(); ++i) {1903 for (int i = 0; i < int(items.size()); ++i) { 1902 1904 Map::set(items[i], invMap.size()); 1903 1905 invMap.push_back(items[i]); … … 1921 1923 /// \c AlterationNotifier. 1922 1924 virtual void erase(const std::vector<Item>& items) { 1923 for (int i = 0; i < (int)items.size(); ++i) {1925 for (int i = 0; i < int(items.size()); ++i) { 1924 1926 Map::set(invMap.back(), Map::operator[](items[i])); 1925 1927 invMap[Map::operator[](items[i])] = invMap.back(); … … 1936 1938 Map::build(); 1937 1939 Item it; 1938 const typename Map::Notifier* n otifier= Map::notifier();1939 for (n otifier->first(it); it != INVALID; notifier->next(it)) {1940 const typename Map::Notifier* nf = Map::notifier(); 1941 for (nf->first(it); it != INVALID; nf->next(it)) { 1940 1942 Map::set(it, invMap.size()); 1941 1943 invMap.push_back(it); … … 2281 2283 virtual void add(const std::vector<Key>& keys) { 2282 2284 Parent::add(keys); 2283 for (int i = 0; i < (int)keys.size(); ++i) {2285 for (int i = 0; i < int(keys.size()); ++i) { 2284 2286 Parent::set(keys[i], 0); 2285 2287 } … … 2314 2316 2315 2317 virtual void add(const std::vector<Edge>& edges) { 2316 for (int i = 0; i < (int)edges.size(); ++i) {2318 for (int i = 0; i < int(edges.size()); ++i) { 2317 2319 ++deg[graph.target(edges[i])]; 2318 2320 } … … 2324 2326 2325 2327 virtual void erase(const std::vector<Edge>& edges) { 2326 for (int i = 0; i < (int)edges.size(); ++i) {2328 for (int i = 0; i < int(edges.size()); ++i) { 2327 2329 --deg[graph.target(edges[i])]; 2328 2330 } … … 2393 2395 virtual void add(const std::vector<Key>& keys) { 2394 2396 Parent::add(keys); 2395 for (int i = 0; i < (int)keys.size(); ++i) {2397 for (int i = 0; i < int(keys.size()); ++i) { 2396 2398 Parent::set(keys[i], 0); 2397 2399 } … … 2426 2428 2427 2429 virtual void add(const std::vector<Edge>& edges) { 2428 for (int i = 0; i < (int)edges.size(); ++i) {2430 for (int i = 0; i < int(edges.size()); ++i) { 2429 2431 ++deg[graph.source(edges[i])]; 2430 2432 } … … 2436 2438 2437 2439 virtual void erase(const std::vector<Edge>& edges) { 2438 for (int i = 0; i < (int)edges.size(); ++i) {2440 for (int i = 0; i < int(edges.size()); ++i) { 2439 2441 --deg[graph.source(edges[i])]; 2440 2442 } -
lemon/graph_writer.h
r2200 r2386 159 159 /// This function issues a new <i> node map writing command</i> to the writer. 160 160 template <typename Map> 161 GraphWriter& writeNodeMap(std::string name, const Map& map) {162 nodeset_writer.writeNodeMap( name, map);161 GraphWriter& writeNodeMap(std::string label, const Map& map) { 162 nodeset_writer.writeNodeMap(label, map); 163 163 return *this; 164 164 } … … 168 168 /// 169 169 /// This function issues a new <i> node map writing command</i> to the writer. 170 template <typename Writer, typename Map>171 GraphWriter& writeNodeMap(std::string name, const Map& map,172 const Writer& writer =Writer()) {173 nodeset_writer.writeNodeMap( name, map, writer);170 template <typename ItemWriter, typename Map> 171 GraphWriter& writeNodeMap(std::string label, const Map& map, 172 const ItemWriter& iw = ItemWriter()) { 173 nodeset_writer.writeNodeMap(label, map, iw); 174 174 return *this; 175 175 } … … 180 180 /// This function issues a new <i> edge map writing command</i> to the writer. 181 181 template <typename Map> 182 GraphWriter& writeEdgeMap(std::string name, const Map& map) {183 edgeset_writer.writeEdgeMap( name, map);182 GraphWriter& writeEdgeMap(std::string label, const Map& map) { 183 edgeset_writer.writeEdgeMap(label, map); 184 184 return *this; 185 185 } … … 189 189 /// 190 190 /// This function issues a new <i> edge map writing command</i> to the writer. 191 template <typename Writer, typename Map>192 GraphWriter& writeEdgeMap(std::string name, const Map& map,193 const Writer& writer =Writer()) {194 edgeset_writer.writeEdgeMap( name, map, writer);191 template <typename ItemWriter, typename Map> 192 GraphWriter& writeEdgeMap(std::string label, const Map& map, 193 const ItemWriter& iw = ItemWriter()) { 194 edgeset_writer.writeEdgeMap(label, map, iw); 195 195 return *this; 196 196 } … … 200 200 /// This function issues a new <i> labeled node writing command</i> 201 201 /// to the writer. 202 GraphWriter& writeNode(std::string name, const Node& node) {203 node_writer.writeNode( name, node);202 GraphWriter& writeNode(std::string label, const Node& node) { 203 node_writer.writeNode(label, node); 204 204 return *this; 205 205 } … … 209 209 /// This function issues a new <i> labeled edge writing command</i> 210 210 /// to the writer. 211 GraphWriter& writeEdge(std::string name, const Edge& edge) {212 edge_writer.writeEdge( name, edge);211 GraphWriter& writeEdge(std::string label, const Edge& edge) { 212 edge_writer.writeEdge(label, edge); 213 213 } 214 214 … … 218 218 /// to the writer. 219 219 template <typename Value> 220 GraphWriter& writeAttribute(std::string name, const Value& value) {221 attribute_writer.writeAttribute( name, value);220 GraphWriter& writeAttribute(std::string label, const Value& value) { 221 attribute_writer.writeAttribute(label, value); 222 222 return *this; 223 223 } … … 227 227 /// This function issues a new <i> attribute writing command</i> 228 228 /// to the writer. 229 template <typename Writer, typename Value>230 GraphWriter& writeAttribute(std::string name, const Value& value,231 const Writer& writer) {232 attribute_writer.writeAttribute <Writer>(name, value, writer);229 template <typename ItemWriter, typename Value> 230 GraphWriter& writeAttribute(std::string label, const Value& value, 231 const ItemWriter& iw = ItemWriter()) { 232 attribute_writer.writeAttribute(label, value, iw); 233 233 return *this; 234 234 } … … 413 413 /// the writer. 414 414 template <typename Map> 415 UGraphWriter& writeNodeMap(std::string name, const Map& map) {416 nodeset_writer.writeNodeMap( name, map);415 UGraphWriter& writeNodeMap(std::string label, const Map& map) { 416 nodeset_writer.writeNodeMap(label, map); 417 417 return *this; 418 418 } … … 422 422 /// This function issues a new <i> node map writing command</i> to 423 423 /// the writer. 424 template <typename Writer, typename Map>425 UGraphWriter& writeNodeMap(std::string name, const Map& map,426 const Writer& writer =Writer()) {427 nodeset_writer.writeNodeMap( name, map, writer);424 template <typename ItemWriter, typename Map> 425 UGraphWriter& writeNodeMap(std::string label, const Map& map, 426 const ItemWriter& iw = ItemWriter()) { 427 nodeset_writer.writeNodeMap(label, map, iw); 428 428 return *this; 429 429 } … … 434 434 /// the writer. 435 435 template <typename Map> 436 UGraphWriter& writeEdgeMap(std::string name, const Map& map) {437 u_edgeset_writer.writeEdgeMap( name, map);436 UGraphWriter& writeEdgeMap(std::string label, const Map& map) { 437 u_edgeset_writer.writeEdgeMap(label, map); 438 438 return *this; 439 439 } … … 443 443 /// This function issues a new <i> edge map writing command</i> to 444 444 /// the writer. 445 template <typename Writer, typename Map>446 UGraphWriter& writeEdgeMap(std::string name, const Map& map,447 const Writer& writer =Writer()) {448 u_edgeset_writer.writeEdgeMap( name, map, writer);445 template <typename ItemWriter, typename Map> 446 UGraphWriter& writeEdgeMap(std::string label, const Map& map, 447 const ItemWriter& iw = ItemWriter()) { 448 u_edgeset_writer.writeEdgeMap(label, map, iw); 449 449 return *this; 450 450 } … … 455 455 /// command</i> to the writer. 456 456 template <typename Map> 457 UGraphWriter& writeUEdgeMap(std::string name, const Map& map) {458 u_edgeset_writer.writeUEdgeMap( name, map);457 UGraphWriter& writeUEdgeMap(std::string label, const Map& map) { 458 u_edgeset_writer.writeUEdgeMap(label, map); 459 459 return *this; 460 460 } … … 464 464 /// This function issues a new <i> undirected edge map writing 465 465 /// command</i> to the writer. 466 template <typename Writer, typename Map>467 UGraphWriter& writeUEdgeMap(std::string name, const Map& map,468 const Writer& writer =Writer()) {469 u_edgeset_writer.writeUEdgeMap( name, map, writer);466 template <typename ItemWriter, typename Map> 467 UGraphWriter& writeUEdgeMap(std::string label, const Map& map, 468 const ItemWriter& iw = ItemWriter()) { 469 u_edgeset_writer.writeUEdgeMap(label, map, iw); 470 470 return *this; 471 471 } … … 475 475 /// This function issues a new <i> labeled node writing 476 476 /// command</i> to the writer. 477 UGraphWriter& writeNode(std::string name, const Node& node) {478 node_writer.writeNode( name, node);477 UGraphWriter& writeNode(std::string label, const Node& node) { 478 node_writer.writeNode(label, node); 479 479 return *this; 480 480 } … … 484 484 /// This function issues a new <i> labeled edge writing 485 485 /// command</i> to the writer. 486 UGraphWriter& writeEdge(std::string name, const Edge& edge) {487 u_edge_writer.writeEdge( name, edge);486 UGraphWriter& writeEdge(std::string label, const Edge& edge) { 487 u_edge_writer.writeEdge(label, edge); 488 488 } 489 489 … … 493 493 /// Issue a new <i>labeled undirected edge writing command</i> to 494 494 /// the writer. 495 UGraphWriter& writeUEdge(std::string name, const UEdge& edge) {496 u_edge_writer.writeUEdge( name, edge);495 UGraphWriter& writeUEdge(std::string label, const UEdge& edge) { 496 u_edge_writer.writeUEdge(label, edge); 497 497 } 498 498 … … 502 502 /// command</i> to the writer. 503 503 template <typename Value> 504 UGraphWriter& writeAttribute(std::string name, const Value& value) {505 attribute_writer.writeAttribute( name, value);504 UGraphWriter& writeAttribute(std::string label, const Value& value) { 505 attribute_writer.writeAttribute(label, value); 506 506 return *this; 507 507 } … … 511 511 /// This function issues a new <i> attribute writing 512 512 /// command</i> to the writer. 513 template <typename Writer, typename Value>514 UGraphWriter& writeAttribute(std::string name, const Value& value,515 const Writer& writer) {516 attribute_writer.writeAttribute <Writer>(name, value, writer);513 template <typename ItemWriter, typename Value> 514 UGraphWriter& writeAttribute(std::string label, const Value& value, 515 const ItemWriter& iw = ItemWriter()) { 516 attribute_writer.writeAttribute(label, value, iw); 517 517 return *this; 518 518 } -
lemon/grid_ugraph.h
r2384 r2386 50 50 protected: 51 51 52 void construct(int w idth, int height) {53 _height = h eight; _width = width;54 _nodeNum = h eight * width; _edgeNum = 2 * _nodeNum - width - height;55 _edgeLimit = _nodeNum - w idth;52 void construct(int w, int h) { 53 _height = h; _width = w; 54 _nodeNum = h * w; _edgeNum = 2 * _nodeNum - w - h; 55 _edgeLimit = _nodeNum - w; 56 56 } 57 57 -
lemon/hao_orlin.h
r2376 r2386 198 198 template <typename ResGraph> 199 199 void findMinCut(const Node& target, bool out, ResGraph& res_graph) { 200 typedef typename Graph::Node Node;201 200 typedef typename ResGraph::Edge ResEdge; 202 201 typedef typename ResGraph::OutEdgeIt ResOutEdgeIt; … … 328 327 _dormant[0].push_front(_target); 329 328 (*_source_set)[_target] = true; 330 if ( (int)_dormant[0].size() == _node_num){329 if (int(_dormant[0].size()) == _node_num){ 331 330 _dormant[0].clear(); 332 331 return false; -
lemon/hypercube_graph.h
r2260 r2386 155 155 156 156 bool projection(Node node, int n) const { 157 return (bool)(node.id & (1 << n));157 return static_cast<bool>(node.id & (1 << n)); 158 158 } 159 159 … … 166 166 } 167 167 168 Node operator()(int i ndex) const {169 return Node(i ndex);168 Node operator()(int ix) const { 169 return Node(ix); 170 170 } 171 171 … … 237 237 /// 238 238 /// Gives back the node by its index. 239 Node operator()(int i ndex) const {240 return Parent::operator()(i ndex);239 Node operator()(int ix) const { 240 return Parent::operator()(ix); 241 241 } 242 242 -
lemon/iterable_maps.h
r2210 r2386 98 98 99 99 Reference& operator=(const Reference& value) { 100 _map.set(_key, (bool)value);100 _map.set(_key, static_cast<bool>(value)); 101 101 return *this; 102 102 } … … 248 248 /// \param _map The IterableIntMap 249 249 explicit FalseIt(const IterableBoolMap& _map) 250 : Parent(_map.sep < (int)_map.array.size() ?250 : Parent(_map.sep < int(_map.array.size()) ? 251 251 _map.array.back() : INVALID), map(&_map) {} 252 252 … … 289 289 ItemIt(const IterableBoolMap& _map, bool value) 290 290 : Parent(value ? (_map.sep > 0 ? _map.array[_map.sep - 1] : INVALID) : 291 (_map.sep < (int)_map.array.size() ?291 (_map.sep < int(_map.array.size()) ? 292 292 _map.array.back() : INVALID)), map(&_map) {} 293 293 … … 322 322 virtual void add(const std::vector<Key>& keys) { 323 323 Parent::add(keys); 324 for (int i = 0; i < (int)keys.size(); ++i) {324 for (int i = 0; i < int(keys.size()); ++i) { 325 325 Parent::set(keys[i], array.size()); 326 326 array.push_back(keys[i]); … … 346 346 347 347 virtual void erase(const std::vector<Key>& keys) { 348 for (int i = 0; i < (int)keys.size(); ++i) {348 for (int i = 0; i < int(keys.size()); ++i) { 349 349 int pos = position(keys[i]); 350 350 if (pos < sep) { … … 457 457 typename Parent::Value& node = Parent::operator[](key); 458 458 if (node.value < 0) return; 459 if (node.value >= (int)first.size()) {459 if (node.value >= int(first.size())) { 460 460 first.resize(node.value + 1, INVALID); 461 461 } … … 485 485 486 486 Reference& operator=(const Reference& value) { 487 _map.set(_key, (const int&)value);487 _map.set(_key, static_cast<const int&>(value)); 488 488 return *this; 489 489 } … … 618 618 /// \param value The value 619 619 ItemIt(const IterableIntMap& map, int value) : _map(&map) { 620 if (value < 0 || value >= (int)_map->first.size()) {620 if (value < 0 || value >= int(_map->first.size())) { 621 621 Parent::operator=(INVALID); 622 622 } else { … … 647 647 648 648 virtual void erase(const std::vector<Key>& keys) { 649 for (int i = 0; i < (int)keys.size(); ++i) {649 for (int i = 0; i < int(keys.size()); ++i) { 650 650 unlace(keys[i]); 651 651 } … … 885 885 virtual void add(const std::vector<Key>& keys) { 886 886 Parent::add(keys); 887 for (int i = 0; i < (int)keys.size(); ++i) {887 for (int i = 0; i < int(keys.size()); ++i) { 888 888 lace(keys[i]); 889 889 } … … 896 896 897 897 virtual void erase(const std::vector<Key>& keys) { 898 for (int i = 0; i < (int)keys.size(); ++i) {898 for (int i = 0; i < int(keys.size()); ++i) { 899 899 unlace(keys[i]); 900 900 } -
lemon/johnson.h
r2376 r2386 564 564 BellmanFordType bellmanford(*graph, *length); 565 565 566 NullMap<Node, Edge> p redMap;567 568 bellmanford.predMap(p redMap);566 NullMap<Node, Edge> pm; 567 568 bellmanford.predMap(pm); 569 569 570 570 bellmanford.init(OperationTraits::zero()); … … 591 591 BellmanFordType bellmanford(*graph, *length); 592 592 593 NullMap<Node, Edge> p redMap;594 595 bellmanford.predMap(p redMap);593 NullMap<Node, Edge> pm; 594 595 bellmanford.predMap(pm); 596 596 597 597 bellmanford.init(OperationTraits::zero()); -
lemon/kruskal.h
r2354 r2386 103 103 // //,typename OUT::Key = typename GR::Edge() 104 104 const typename IN::value_type::first_type * = 105 (const typename IN::value_type::first_type *)(0), 106 const typename OUT::Key * = (const typename OUT::Key *)(0) 105 reinterpret_cast<const typename IN::value_type::first_type*>(0), 106 const typename OUT::Key * = 107 reinterpret_cast<const typename OUT::Key*>(0) 107 108 ) 108 109 #endif … … 171 172 // typename OUT::Key = GR::Edge() 172 173 const typename IN::value_type::first_type * = 173 (const typename IN::value_type::first_type *)(0), 174 const typename OUT::Key * = (const typename OUT::Key *)(0) 174 reinterpret_cast<const typename IN::value_type::first_type*>(0), 175 const typename OUT::Key * = 176 reinterpret_cast<const typename OUT::Key*>(0) 175 177 ) 176 178 { … … 358 360 //typename IN::Key = typename IN::Key (), 359 361 // typename RET::Key = typename GR::Edge() 360 const typename IN::Key * = (const typename IN::Key *)(0), 361 const typename RET::Key * = (const typename RET::Key *)(0) 362 const typename IN::Key * = 363 reinterpret_cast<const typename IN::Key*>(0), 364 const typename RET::Key * = 365 reinterpret_cast<const typename RET::Key*>(0) 362 366 ) 363 367 { … … 408 412 RET out, 409 413 const typename RET::value_type * = 410 (const typename RET::value_type *)(0)414 reinterpret_cast<const typename RET::value_type*>(0) 411 415 ) 412 416 { -
lemon/lemon_reader.h
r2368 r2386 534 534 virtual std::streambuf* setbuf(char *buf, std::streamsize len) { 535 535 if (base()) return 0; 536 if (buf != 0 && len >= (int)sizeof(small_buf)) {536 if (buf != 0 && len >= int(sizeof(small_buf))) { 537 537 setb(buf, len); 538 538 } else { … … 710 710 FilterStreamBuf buffer(*is, line_num); 711 711 buffer.pubsetbuf(buf, sizeof(buf)); 712 std::istream is(&buffer);713 it->first->read( is);712 std::istream ss(&buffer); 713 it->first->read(ss); 714 714 break; 715 715 } … … 798 798 /// Add a new node map reader command for the reader. 799 799 template <typename Map> 800 NodeSetReader& readNodeMap(std::string name, Map& map) {800 NodeSetReader& readNodeMap(std::string label, Map& map) { 801 801 return _readMap< 802 802 typename Traits::template Reader<typename Map::Value>, Map, 803 typename _reader_bits::Arg<Map>::Type>( name, map);803 typename _reader_bits::Arg<Map>::Type>(label, map); 804 804 } 805 805 806 806 template <typename Map> 807 NodeSetReader& readNodeMap(std::string name, const Map& map) {807 NodeSetReader& readNodeMap(std::string label, const Map& map) { 808 808 return _readMap< 809 809 typename Traits::template Reader<typename Map::Value>, Map, 810 typename _reader_bits::Arg<Map>::Type>( name, map);810 typename _reader_bits::Arg<Map>::Type>(label, map); 811 811 } 812 812 … … 814 814 /// 815 815 /// Add a new node map reader command for the reader. 816 template <typename Reader, typename Map>817 NodeSetReader& readNodeMap(std::string name, Map& map,818 const Reader& reader =Reader()) {819 return _readMap< Reader, Map, typename _reader_bits::Arg<Map>::Type>820 ( name, map, reader);821 } 822 823 template <typename Reader, typename Map>824 NodeSetReader& readNodeMap(std::string name, const Map& map,825 const Reader& reader =Reader()) {826 return _readMap< Reader, Map, typename _reader_bits::Arg<Map>::Type>827 ( name, map, reader);816 template <typename ItemReader, typename Map> 817 NodeSetReader& readNodeMap(std::string label, Map& map, 818 const ItemReader& ir = ItemReader()) { 819 return _readMap<ItemReader, Map, typename _reader_bits::Arg<Map>::Type> 820 (label, map, ir); 821 } 822 823 template <typename ItemReader, typename Map> 824 NodeSetReader& readNodeMap(std::string label, const Map& map, 825 const ItemReader& ir = ItemReader()) { 826 return _readMap<ItemReader, Map, typename _reader_bits::Arg<Map>::Type> 827 (label, map, ir); 828 828 } 829 829 830 830 private: 831 831 832 template <typename Reader, typename Map, typename MapParameter>833 NodeSetReader& _readMap(std::string name, MapParameter map,834 const Reader& reader =Reader()) {832 template <typename ItemReader, typename Map, typename MapParameter> 833 NodeSetReader& _readMap(std::string label, MapParameter map, 834 const ItemReader& ir = ItemReader()) { 835 835 checkConcept<concepts::WriteMap<Node, typename Map::Value>, Map>(); 836 checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>();837 if (readers.find( name) != readers.end()) {836 checkConcept<_reader_bits::ItemReader<typename Map::Value>, ItemReader>(); 837 if (readers.find(label) != readers.end()) { 838 838 ErrorMessage msg; 839 msg << "Multiple read rule for node map: " << name;839 msg << "Multiple read rule for node map: " << label; 840 840 throw IoParameterError(msg.message()); 841 841 } 842 842 readers.insert( 843 make_pair( name, new _reader_bits::844 MapReader<Node, Map, Reader>(map, reader)));843 make_pair(label, new _reader_bits:: 844 MapReader<Node, Map, ItemReader>(map, ir))); 845 845 return *this; 846 846 } … … 851 851 /// 852 852 /// Add a new node map skipper command for the reader. 853 template <typename Reader>854 NodeSetReader& skipNodeMap(std::string name,855 const Reader& reader =Reader()) {856 if (readers.find( name) != readers.end()) {853 template <typename ItemReader> 854 NodeSetReader& skipNodeMap(std::string label, 855 const ItemReader& ir = ItemReader()) { 856 if (readers.find(label) != readers.end()) { 857 857 ErrorMessage msg; 858 msg << "Multiple read rule for node map: " << name;858 msg << "Multiple read rule for node map: " << label; 859 859 throw IoParameterError(msg.message()); 860 860 } 861 readers.insert(make_pair( name, new _reader_bits::862 SkipReader<Node, Reader>(reader)));861 readers.insert(make_pair(label, new _reader_bits:: 862 SkipReader<Node, ItemReader>(ir))); 863 863 return *this; 864 864 } … … 886 886 std::string line; 887 887 888 getline(is, line); 889 std::istringstream ls(line); 890 std::string id; 891 while (ls >> id) { 892 typename MapReaders::iterator it = readers.find(id); 893 if (it != readers.end()) { 894 it->second->touch(); 895 index.push_back(it->second); 896 } else { 897 index.push_back(&skipper); 898 } 899 if (id == "label") { 900 inverter.reset(index.back()->getInverter()); 901 index.back() = inverter.get(); 902 } 888 { 889 getline(is, line); 890 std::istringstream ls(line); 891 std::string id; 892 while (ls >> id) { 893 typename MapReaders::iterator it = readers.find(id); 894 if (it != readers.end()) { 895 it->second->touch(); 896 index.push_back(it->second); 897 } else { 898 index.push_back(&skipper); 899 } 900 if (id == "label") { 901 inverter.reset(index.back()->getInverter()); 902 index.back() = inverter.get(); 903 } 904 } 903 905 } 904 906 for (typename MapReaders::iterator it = readers.begin(); … … 913 915 Node node = graph.addNode(); 914 916 std::istringstream ls(line); 915 for (int i = 0; i < (int)index.size(); ++i) {917 for (int i = 0; i < int(index.size()); ++i) { 916 918 index[i]->read(ls, node); 917 919 } … … 1028 1030 /// Add a new edge map reader command for the reader. 1029 1031 template <typename Map> 1030 EdgeSetReader& readEdgeMap(std::string name, Map& map) {1032 EdgeSetReader& readEdgeMap(std::string label, Map& map) { 1031 1033 return _readMap< 1032 1034 typename Traits::template Reader<typename Map::Value>, Map, 1033 typename _reader_bits::Arg<Map>::Type>( name, map);1035 typename _reader_bits::Arg<Map>::Type>(label, map); 1034 1036 } 1035 1037 1036 1038 template <typename Map> 1037 EdgeSetReader& readEdgeMap(std::string name, const Map& map) {1039 EdgeSetReader& readEdgeMap(std::string label, const Map& map) { 1038 1040 return _readMap< 1039 1041 typename Traits::template Reader<typename Map::Value>, Map, 1040 typename _reader_bits::Arg<Map>::Type>( name, map);1042 typename _reader_bits::Arg<Map>::Type>(label, map); 1041 1043 } 1042 1044 … … 1044 1046 /// 1045 1047 /// Add a new edge map reader command for the reader. 1046 template <typename Reader, typename Map>1047 EdgeSetReader& readEdgeMap(std::string name, Map& map,1048 const Reader& reader =Reader()) {1049 return _readMap< Reader, Map,1050 typename _reader_bits::Arg<Map>::Type>( name, map, reader);1051 } 1052 1053 template <typename Reader, typename Map>1054 EdgeSetReader& readEdgeMap(std::string name, const Map& map,1055 const Reader& reader =Reader()) {1056 return _readMap< Reader, Map,1057 typename _reader_bits::Arg<Map>::Type>( name, map, reader);1048 template <typename ItemReader, typename Map> 1049 EdgeSetReader& readEdgeMap(std::string label, Map& map, 1050 const ItemReader& ir = ItemReader()) { 1051 return _readMap<ItemReader, Map, 1052 typename _reader_bits::Arg<Map>::Type>(label, map, ir); 1053 } 1054 1055 template <typename ItemReader, typename Map> 1056 EdgeSetReader& readEdgeMap(std::string label, const Map& map, 1057 const ItemReader& ir = ItemReader()) { 1058 return _readMap<ItemReader, Map, 1059 typename _reader_bits::Arg<Map>::Type>(label, map, ir); 1058 1060 } 1059 1061 1060 1062 private: 1061 1063 1062 template <typename Reader, typename Map, typename MapParameter>1063 EdgeSetReader& _readMap(std::string name, MapParameter map,1064 const Reader& reader =Reader()) {1064 template <typename ItemReader, typename Map, typename MapParameter> 1065 EdgeSetReader& _readMap(std::string label, MapParameter map, 1066 const ItemReader& ir = ItemReader()) { 1065 1067 checkConcept<concepts::WriteMap<Edge, typename Map::Value>, Map>(); 1066 checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>();1067 if (readers.find( name) != readers.end()) {1068 checkConcept<_reader_bits::ItemReader<typename Map::Value>, ItemReader>(); 1069 if (readers.find(label) != readers.end()) { 1068 1070 ErrorMessage msg; 1069 msg << "Multiple read rule for edge map: " << name;1071 msg << "Multiple read rule for edge map: " << label; 1070 1072 throw IoParameterError(msg.message()); 1071 1073 } 1072 1074 readers.insert( 1073 make_pair( name, new _reader_bits::1074 MapReader<Edge, Map, Reader>(map, reader)));1075 make_pair(label, new _reader_bits:: 1076 MapReader<Edge, Map, ItemReader>(map, ir))); 1075 1077 return *this; 1076 1078 } … … 1081 1083 /// 1082 1084 /// Add a new edge map skipper command for the reader. 1083 template <typename Reader>1084 EdgeSetReader& skipEdgeMap(std::string name,1085 const Reader& reader =Reader()) {1086 if (readers.find( name) != readers.end()) {1085 template <typename ItemReader> 1086 EdgeSetReader& skipEdgeMap(std::string label, 1087 const ItemReader& ir = ItemReader()) { 1088 if (readers.find(label) != readers.end()) { 1087 1089 ErrorMessage msg; 1088 msg << "Multiple read rule for edge map: " << name;1090 msg << "Multiple read rule for edge map: " << label; 1089 1091 throw IoParameterError(msg.message()); 1090 1092 } 1091 readers.insert(make_pair( name, new _reader_bits::1092 SkipReader<Edge, Reader>(reader)));1093 readers.insert(make_pair(label, new _reader_bits:: 1094 SkipReader<Edge, ItemReader>(ir))); 1093 1095 return *this; 1094 1096 } … … 1119 1121 std::string line; 1120 1122 1121 getline(is, line); 1122 std::istringstream ls(line); 1123 std::string id; 1124 while (ls >> id) { 1125 typename MapReaders::iterator it = readers.find(id); 1126 if (it != readers.end()) { 1127 index.push_back(it->second); 1128 it->second->touch(); 1129 } else { 1130 index.push_back(&skipper); 1131 } 1132 if (id == "label") { 1133 inverter.reset(index.back()->getInverter()); 1134 index.back() = inverter.get(); 1135 } 1123 { 1124 getline(is, line); 1125 std::istringstream ls(line); 1126 std::string id; 1127 while (ls >> id) { 1128 typename MapReaders::iterator it = readers.find(id); 1129 if (it != readers.end()) { 1130 index.push_back(it->second); 1131 it->second->touch(); 1132 } else { 1133 index.push_back(&skipper); 1134 } 1135 if (id == "label") { 1136 inverter.reset(index.back()->getInverter()); 1137 index.back() = inverter.get(); 1138 } 1139 } 1136 1140 } 1137 1141 for (typename MapReaders::iterator it = readers.begin(); … … 1148 1152 Node to = nodeLabelReader->read(ls); 1149 1153 Edge edge = graph.addEdge(from, to); 1150 for (int i = 0; i < (int)index.size(); ++i) {1154 for (int i = 0; i < int(index.size()); ++i) { 1151 1155 index[i]->read(ls, edge); 1152 1156 } … … 1272 1276 /// Add a new edge undirected map reader command for the reader. 1273 1277 template <typename Map> 1274 UEdgeSetReader& readUEdgeMap(std::string name, Map& map) {1278 UEdgeSetReader& readUEdgeMap(std::string label, Map& map) { 1275 1279 return _readMap< 1276 1280 typename Traits::template Reader<typename Map::Value>, Map, 1277 typename _reader_bits::Arg<Map>::Type>( name, map);1281 typename _reader_bits::Arg<Map>::Type>(label, map); 1278 1282 } 1279 1283 1280 1284 template <typename Map> 1281 UEdgeSetReader& readUEdgeMap(std::string name, const Map& map) {1285 UEdgeSetReader& readUEdgeMap(std::string label, const Map& map) { 1282 1286 return _readMap< 1283 1287 typename Traits::template Reader<typename Map::Value>, Map, 1284 typename _reader_bits::Arg<Map>::Type>( name, map);1288 typename _reader_bits::Arg<Map>::Type>(label, map); 1285 1289 } 1286 1290 … … 1288 1292 /// 1289 1293 /// Add a new edge undirected map reader command for the reader. 1290 template <typename Reader, typename Map>1291 UEdgeSetReader& readUEdgeMap(std::string name, Map& map,1292 const Reader& reader =Reader()) {1293 return _readMap< Reader, Map, typename _reader_bits::Arg<Map>::Type>1294 ( name, map, reader);1295 } 1296 1297 template <typename Reader, typename Map>1298 UEdgeSetReader& readUEdgeMap(std::string name, const Map& map,1299 const Reader& reader =Reader()) {1300 return _readMap< Reader, Map, typename _reader_bits::Arg<Map>::Type >1301 ( name, map, reader);1294 template <typename ItemReader, typename Map> 1295 UEdgeSetReader& readUEdgeMap(std::string label, Map& map, 1296 const ItemReader& ir = ItemReader()) { 1297 return _readMap<ItemReader, Map, typename _reader_bits::Arg<Map>::Type> 1298 (label, map, ir); 1299 } 1300 1301 template <typename ItemReader, typename Map> 1302 UEdgeSetReader& readUEdgeMap(std::string label, const Map& map, 1303 const ItemReader& ir = ItemReader()) { 1304 return _readMap<ItemReader, Map, typename _reader_bits::Arg<Map>::Type > 1305 (label, map, ir); 1302 1306 } 1303 1307 1304 1308 private: 1305 1309 1306 template <typename Reader, typename Map, typename MapParameter>1307 UEdgeSetReader& _readMap(std::string name, MapParameter map,1308 const Reader& reader =Reader()) {1310 template <typename ItemReader, typename Map, typename MapParameter> 1311 UEdgeSetReader& _readMap(std::string label, MapParameter map, 1312 const ItemReader& ir = ItemReader()) { 1309 1313 checkConcept<concepts::WriteMap<UEdge, typename Map::Value>, Map>(); 1310 checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>();1311 if (readers.find( name) != readers.end()) {1314 checkConcept<_reader_bits::ItemReader<typename Map::Value>, ItemReader>(); 1315 if (readers.find(label) != readers.end()) { 1312 1316 ErrorMessage msg; 1313 msg << "Multiple read rule for edge map: " << name;1317 msg << "Multiple read rule for edge map: " << label; 1314 1318 throw IoParameterError(msg.message()); 1315 1319 } 1316 1320 readers.insert( 1317 make_pair( name, new _reader_bits::1318 MapReader<UEdge, Map, Reader>(map, reader)));1321 make_pair(label, new _reader_bits:: 1322 MapReader<UEdge, Map, ItemReader>(map, ir))); 1319 1323 return *this; 1320 1324 } … … 1325 1329 /// 1326 1330 /// Add a new undirected edge map skipper command for the reader. 1327 template <typename Reader>1328 UEdgeSetReader& skipUEdgeMap(std::string name,1329 const Reader& reader =Reader()) {1330 if (readers.find( name) != readers.end()) {1331 template <typename ItemReader> 1332 UEdgeSetReader& skipUEdgeMap(std::string label, 1333 const ItemReader& ir = ItemReader()) { 1334 if (readers.find(label) != readers.end()) { 1331 1335 ErrorMessage msg; 1332 msg << "Multiple read rule for node map: " << name;1336 msg << "Multiple read rule for node map: " << label; 1333 1337 throw IoParameterError(msg.message()); 1334 1338 } 1335 readers.insert(make_pair( name, new _reader_bits::1336 SkipReader<UEdge, Reader>(reader)));1339 readers.insert(make_pair(label, new _reader_bits:: 1340 SkipReader<UEdge, ItemReader>(ir))); 1337 1341 return *this; 1338 1342 } … … 1342 1346 /// Add a new directed edge map reader command for the reader. 1343 1347 template <typename Map> 1344 UEdgeSetReader& readEdgeMap(std::string name, Map& map) {1348 UEdgeSetReader& readEdgeMap(std::string label, Map& map) { 1345 1349 return _readDirMap< 1346 1350 typename Traits::template Reader<typename Map::Value>, Map, 1347 typename _reader_bits::Arg<Map>::Type>( name, map);1351 typename _reader_bits::Arg<Map>::Type>(label, map); 1348 1352 } 1349 1353 1350 1354 template <typename Map> 1351 UEdgeSetReader& readEdgeMap(std::string name, const Map& map) {1355 UEdgeSetReader& readEdgeMap(std::string label, const Map& map) { 1352 1356 return _readDirMap< 1353 1357 typename Traits::template Reader<typename Map::Value>, Map, 1354 typename _reader_bits::Arg<Map>::Type>( name, map);1358 typename _reader_bits::Arg<Map>::Type>(label, map); 1355 1359 } 1356 1360 … … 1358 1362 /// 1359 1363 /// Add a new directed edge map reader command for the reader. 1360 template <typename Reader, typename Map>1361 UEdgeSetReader& readEdgeMap(std::string name, Map& map,1362 const Reader& reader =Reader()) {1363 return _readDirMap< Reader, Map, typename _reader_bits::Arg<Map>::Type>1364 (name, map, reader);1365 } 1366 1367 template <typename Reader, typename Map>1368 UEdgeSetReader& readEdgeMap(std::string name, const Map& map,1369 const Reader& reader =Reader()) {1370 return _readDirMap< Reader, Map, typename _reader_bits::Arg<Map>::Type>1371 (name, map, reader);1364 template <typename ItemReader, typename Map> 1365 UEdgeSetReader& readEdgeMap(std::string label, Map& map, 1366 const ItemReader& ir = ItemReader()) { 1367 return _readDirMap<ItemReader, Map, 1368 typename _reader_bits::Arg<Map>::Type>(label, map, ir); 1369 } 1370 1371 template <typename ItemReader, typename Map> 1372 UEdgeSetReader& readEdgeMap(std::string label, const Map& map, 1373 const ItemReader& ir = ItemReader()) { 1374 return _readDirMap<ItemReader, Map, 1375 typename _reader_bits::Arg<Map>::Type>(label, map, ir); 1372 1376 } 1373 1377 1374 1378 private: 1375 1379 1376 template <typename Reader, typename Map, typename MapParameter>1377 UEdgeSetReader& _readDirMap(std::string name, MapParameter map,1378 const Reader& reader =Reader()) {1379 checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>();1380 template <typename ItemReader, typename Map, typename MapParameter> 1381 UEdgeSetReader& _readDirMap(std::string label, MapParameter map, 1382 const ItemReader& ir = ItemReader()) { 1383 checkConcept<_reader_bits::ItemReader<typename Map::Value>, ItemReader>(); 1380 1384 checkConcept<concepts::WriteMap<Edge, typename Map::Value>, Map>(); 1381 readUEdgeMap("+" + name,1382 _reader_bits::forwardComposeMap(graph, map), reader);1383 readUEdgeMap("-" + name,1384 _reader_bits::backwardComposeMap(graph, map), reader);1385 readUEdgeMap("+" + label, 1386 _reader_bits::forwardComposeMap(graph, map), ir); 1387 readUEdgeMap("-" + label, 1388 _reader_bits::backwardComposeMap(graph, map), ir); 1385 1389 return *this; 1386 1390 } … … 1391 1395 /// 1392 1396 /// Add a new directed edge map skipper command for the reader. 1393 template <typename Reader>1394 UEdgeSetReader& skipEdgeMap(std::string name,1395 const Reader& reader =Reader()) {1396 skipUEdgeMap("+" + name, reader);1397 skipUEdgeMap("-" + name, reader);1397 template <typename ItemReader> 1398 UEdgeSetReader& skipEdgeMap(std::string label, 1399 const ItemReader& ir = ItemReader()) { 1400 skipUEdgeMap("+" + label, ir); 1401 skipUEdgeMap("-" + label, ir); 1398 1402 return *this; 1399 1403 } … … 1424 1428 std::string line; 1425 1429 1426 getline(is, line); 1427 std::istringstream ls(line); 1428 std::string id; 1429 while (ls >> id) { 1430 typename MapReaders::iterator it = readers.find(id); 1431 if (it != readers.end()) { 1432 index.push_back(it->second); 1433 it->second->touch(); 1434 } else { 1435 index.push_back(&skipper); 1436 } 1437 if (id == "label") { 1438 inverter.reset(index.back()->getInverter()); 1439 index.back() = inverter.get(); 1440 } 1441 } 1442 for (typename MapReaders::iterator it = readers.begin(); 1443 it != readers.end(); ++it) { 1444 if (!it->second->touched()) { 1445 ErrorMessage msg; 1446 msg << "Map not found in file: " << it->first; 1447 throw IoParameterError(msg.message()); 1448 } 1430 { 1431 getline(is, line); 1432 std::istringstream ls(line); 1433 std::string id; 1434 while (ls >> id) { 1435 typename MapReaders::iterator it = readers.find(id); 1436 if (it != readers.end()) { 1437 index.push_back(it->second); 1438 it->second->touch(); 1439 } else { 1440 index.push_back(&skipper); 1441 } 1442 if (id == "label") { 1443 inverter.reset(index.back()->getInverter()); 1444 index.back() = inverter.get(); 1445 } 1446 } 1447 for (typename MapReaders::iterator it = readers.begin(); 1448 it != readers.end(); ++it) { 1449 if (!it->second->touched()) { 1450 ErrorMessage msg; 1451 msg << "Map not found in file: " << it->first; 1452 throw IoParameterError(msg.message()); 1453 } 1454 } 1449 1455 } 1450 1456 while (getline(is, line)) { … … 1453 1459 Node to = nodeLabelReader->read(ls); 1454 1460 UEdge edge = graph.addEdge(from, to); 1455 for (int i = 0; i < (int)index.size(); ++i) {1461 for (int i = 0; i < int(index.size()); ++i) { 1456 1462 index[i]->read(ls, edge); 1457 1463 } … … 1564 1570 /// 1565 1571 /// Add a node reader command for the NodeReader. 1566 void readNode( const std::string& name, Node& item) {1567 if (readers.find( name) != readers.end()) {1572 void readNode(std::string label, Node& item) { 1573 if (readers.find(label) != readers.end()) { 1568 1574 ErrorMessage msg; 1569 msg << "Multiple read rule for node: " << name;1575 msg << "Multiple read rule for node: " << label; 1570 1576 throw IoParameterError(msg.message()); 1571 1577 } 1572 readers.insert(make_pair( name, _reader_bits::ItemStore<Node>(item)));1578 readers.insert(make_pair(label, _reader_bits::ItemStore<Node>(item))); 1573 1579 } 1574 1580 … … 1677 1683 /// 1678 1684 /// Add an edge reader command for the EdgeReader. 1679 void readEdge( const std::string& name, Edge& item) {1680 if (readers.find( name) != readers.end()) {1685 void readEdge(std::string label, Edge& item) { 1686 if (readers.find(label) != readers.end()) { 1681 1687 ErrorMessage msg; 1682 msg << "Multiple read rule for edge: " << name;1688 msg << "Multiple read rule for edge: " << label; 1683 1689 throw IoParameterError(msg.message()); 1684 1690 } 1685 readers.insert(make_pair( name, _reader_bits::ItemStore<Edge>(item)));1691 readers.insert(make_pair(label, _reader_bits::ItemStore<Edge>(item))); 1686 1692 } 1687 1693 … … 1795 1801 /// 1796 1802 /// Add an undirected edge reader command for the UEdgeReader. 1797 void readUEdge( const std::string& name, UEdge& item) {1798 if (uEdgeReaders.find( name) != uEdgeReaders.end()) {1803 void readUEdge(std::string label, UEdge& item) { 1804 if (uEdgeReaders.find(label) != uEdgeReaders.end()) { 1799 1805 ErrorMessage msg; 1800 msg << "Multiple read rule for undirected edge: " << name;1806 msg << "Multiple read rule for undirected edge: " << label; 1801 1807 throw IoParameterError(msg.message()); 1802 1808 } 1803 uEdgeReaders.insert(make_pair( name, _reader_bits::1809 uEdgeReaders.insert(make_pair(label, _reader_bits:: 1804 1810 ItemStore<UEdge>(item))); 1805 1811 } … … 1808 1814 /// 1809 1815 /// Add an edge reader command for the UEdgeReader. 1810 void readEdge( const std::string& name, Edge& item) {1811 if (edgeReaders.find( name) != edgeReaders.end()) {1816 void readEdge(std::string label, Edge& item) { 1817 if (edgeReaders.find(label) != edgeReaders.end()) { 1812 1818 ErrorMessage msg; 1813 msg << "Multiple read rule for edge: " << name;1819 msg << "Multiple read rule for edge: " << label; 1814 1820 throw IoParameterError(msg.message()); 1815 1821 } 1816 edgeReaders.insert(make_pair( name, _reader_bits::ItemStore<Edge>(item)));1822 edgeReaders.insert(make_pair(label, _reader_bits::ItemStore<Edge>(item))); 1817 1823 } 1818 1824 … … 1954 1960 /// 1955 1961 /// Add an attribute reader command for the reader. 1956 template <typename Reader, typename Value>1957 AttributeReader& readAttribute( const std::string& name, Value& value,1958 const Reader& reader =Reader()) {1959 checkConcept<_reader_bits::ItemReader<Value>, Reader>();1960 if (readers.find( name) != readers.end()) {1962 template <typename ItemReader, typename Value> 1963 AttributeReader& readAttribute(std::string label, Value& value, 1964 const ItemReader& ir = ItemReader()) { 1965 checkConcept<_reader_bits::ItemReader<Value>, ItemReader>(); 1966 if (readers.find(label) != readers.end()) { 1961 1967 ErrorMessage msg; 1962 msg << "Multiple read rule for attribute: " << name;1968 msg << "Multiple read rule for attribute: " << label; 1963 1969 throw IoParameterError(msg.message()); 1964 1970 } 1965 readers.insert(make_pair( name, new _reader_bits::1966 ValueReader<Value, Reader>(value, reader)));1971 readers.insert(make_pair(label, new _reader_bits:: 1972 ValueReader<Value, ItemReader>(value, ir))); 1967 1973 return *this; 1968 1974 } -
lemon/lemon_writer.h
r2282 r2386 473 473 /// Add a new node map writer command for the writer. 474 474 template <typename Map> 475 NodeSetWriter& writeNodeMap(std::string name, const Map& map) {475 NodeSetWriter& writeNodeMap(std::string label, const Map& map) { 476 476 return writeNodeMap<typename Traits:: 477 template Writer<typename Map::Value>, Map>( name, map);477 template Writer<typename Map::Value>, Map>(label, map); 478 478 } 479 479 … … 481 481 /// 482 482 /// Add a new node map writer command for the writer. 483 template <typename Writer, typename Map>484 NodeSetWriter& writeNodeMap(std::string name, const Map& map,485 const Writer& writer =Writer()) {483 template <typename ItemWriter, typename Map> 484 NodeSetWriter& writeNodeMap(std::string label, const Map& map, 485 const ItemWriter& iw = ItemWriter()) { 486 486 checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>(); 487 checkConcept<_writer_bits::ItemWriter<typename Map::Value>, 487 checkConcept<_writer_bits::ItemWriter<typename Map::Value>,ItemWriter>(); 488 488 writers.push_back( 489 make_pair( name, new _writer_bits::490 MapWriter<Node, Map, Writer>(map, writer)));489 make_pair(label, new _writer_bits:: 490 MapWriter<Node, Map, ItemWriter>(map, iw))); 491 491 return *this; 492 492 } … … 505 505 /// Write the content of the section. 506 506 virtual void write(std::ostream& os) { 507 for (int i = 0; i < (int)writers.size(); ++i) {507 for (int i = 0; i < int(writers.size()); ++i) { 508 508 if (writers[i].first == "label") { 509 509 labelMap = writers[i].second; … … 529 529 os << "label\t"; 530 530 } 531 for (int i = 0; i < (int)writers.size(); ++i) {531 for (int i = 0; i < int(writers.size()); ++i) { 532 532 os << writers[i].first << '\t'; 533 533 } … … 538 538 os << graph.id(*it) << '\t'; 539 539 } 540 for (int i = 0; i < (int)writers.size(); ++i) {540 for (int i = 0; i < int(writers.size()); ++i) { 541 541 writers[i].second->write(os, *it); 542 542 os << '\t'; … … 662 662 /// Add a new edge map writer command for the writer. 663 663 template <typename Map> 664 EdgeSetWriter& writeEdgeMap(std::string name, const Map& map) {664 EdgeSetWriter& writeEdgeMap(std::string label, const Map& map) { 665 665 return writeEdgeMap<typename Traits:: 666 template Writer<typename Map::Value>, Map>( name, map);666 template Writer<typename Map::Value>, Map>(label, map); 667 667 } 668 668 … … 670 670 /// 671 671 /// Add a new edge map writer command for the writer. 672 template <typename Writer, typename Map>673 EdgeSetWriter& writeEdgeMap(std::string name, const Map& map,674 const Writer& writer =Writer()) {672 template <typename ItemWriter, typename Map> 673 EdgeSetWriter& writeEdgeMap(std::string label, const Map& map, 674 const ItemWriter& iw = ItemWriter()) { 675 675 checkConcept<concepts::ReadMap<Edge, typename Map::Value>, Map>(); 676 checkConcept<_writer_bits::ItemWriter<typename Map::Value>, Writer>();676 checkConcept<_writer_bits::ItemWriter<typename Map::Value>, ItemWriter>(); 677 677 writers.push_back( 678 make_pair( name, new _writer_bits::679 MapWriter<Edge, Map, Writer>(map, writer)));678 make_pair(label, new _writer_bits:: 679 MapWriter<Edge, Map, ItemWriter>(map, iw))); 680 680 return *this; 681 681 } … … 697 697 throw DataFormatError("Cannot find nodeset or label map"); 698 698 } 699 for (int i = 0; i < (int)writers.size(); ++i) {699 for (int i = 0; i < int(writers.size()); ++i) { 700 700 if (writers[i].first == "label") { 701 701 labelMap = writers[i].second; … … 722 722 os << "label\t"; 723 723 } 724 for (int i = 0; i < (int)writers.size(); ++i) {724 for (int i = 0; i < int(writers.size()); ++i) { 725 725 os << writers[i].first << '\t'; 726 726 } … … 735 735 os << graph.id(*it) << '\t'; 736 736 } 737 for (int i = 0; i < (int)writers.size(); ++i) {737 for (int i = 0; i < int(writers.size()); ++i) { 738 738 writers[i].second->write(os, *it); 739 739 os << '\t'; … … 868 868 /// Add a new undirected map writer command for the writer. 869 869 template <typename Map> 870 UEdgeSetWriter& writeUEdgeMap(std::string name, const Map& map) {870 UEdgeSetWriter& writeUEdgeMap(std::string label, const Map& map) { 871 871 return writeUEdgeMap<typename Traits:: 872 template Writer<typename Map::Value>, Map>( name, map);872 template Writer<typename Map::Value>, Map>(label, map); 873 873 } 874 874 … … 876 876 /// 877 877 /// Add a new undirected map writer command for the writer. 878 template <typename Writer, typename Map>879 UEdgeSetWriter& writeUEdgeMap(std::string name, const Map& map,880 const Writer& writer =Writer()) {878 template <typename ItemWriter, typename Map> 879 UEdgeSetWriter& writeUEdgeMap(std::string label, const Map& map, 880 const ItemWriter& iw = ItemWriter()) { 881 881 checkConcept<concepts::ReadMap<UEdge, typename Map::Value>, Map>(); 882 checkConcept<_writer_bits::ItemWriter<typename Map::Value>, Writer>();882 checkConcept<_writer_bits::ItemWriter<typename Map::Value>, ItemWriter>(); 883 883 writers.push_back( 884 make_pair( name, new _writer_bits::885 MapWriter<UEdge, Map, Writer>(map, writer)));884 make_pair(label, new _writer_bits:: 885 MapWriter<UEdge, Map, ItemWriter>(map, iw))); 886 886 return *this; 887 887 } … … 891 891 /// Add a new directed map writer command for the writer. 892 892 template <typename Map> 893 UEdgeSetWriter& writeEdgeMap(std::string name, const Map& map) {893 UEdgeSetWriter& writeEdgeMap(std::string label, const Map& map) { 894 894 return writeEdgeMap<typename Traits:: 895 template Writer<typename Map::Value>, Map>( name, map);895 template Writer<typename Map::Value>, Map>(label, map); 896 896 } 897 897 … … 899 899 /// 900 900 /// Add a new directed map writer command for the writer. 901 template <typename Writer, typename Map>902 UEdgeSetWriter& writeEdgeMap(std::string name, const Map& map,903 const Writer& writer =Writer()) {901 template <typename ItemWriter, typename Map> 902 UEdgeSetWriter& writeEdgeMap(std::string label, const Map& map, 903 const ItemWriter& iw = ItemWriter()) { 904 904 checkConcept<concepts::ReadMap<Edge, typename Map::Value>, Map>(); 905 checkConcept<_writer_bits::ItemWriter<typename Map::Value>, Writer>();905 checkConcept<_writer_bits::ItemWriter<typename Map::Value>, ItemWriter>(); 906 906 writeUEdgeMap("+" + name, 907 _writer_bits::forwardComposeMap(graph, map), writer);907 _writer_bits::forwardComposeMap(graph, map), iw); 908 908 writeUEdgeMap("-" + name, 909 _writer_bits::backwardComposeMap(graph, map), writer);909 _writer_bits::backwardComposeMap(graph, map), iw); 910 910 return *this; 911 911 } … … 927 927 throw DataFormatError("Cannot find nodeset or label map"); 928 928 } 929 for (int i = 0; i < (int)writers.size(); ++i) {929 for (int i = 0; i < int(writers.size()); ++i) { 930 930 if (writers[i].first == "label") { 931 931 labelMap = writers[i].second; … … 952 952 os << "label\t"; 953 953 } 954 for (int i = 0; i < (int)writers.size(); ++i) {954 for (int i = 0; i < int(writers.size()); ++i) { 955 955 os << writers[i].first << '\t'; 956 956 } … … 965 965 os << graph.id(*it) << '\t'; 966 966 } 967 for (int i = 0; i < (int)writers.size(); ++i) {967 for (int i = 0; i < int(writers.size()); ++i) { 968 968 writers[i].second->write(os, *it); 969 969 os << '\t'; … … 1081 1081 /// 1082 1082 /// Add a node writer command for the NodeWriter. 1083 void writeNode( const std::string& name, const Node& item) {1084 writers.push_back(make_pair( name, &item));1083 void writeNode(std::string label, const Node& item) { 1084 writers.push_back(make_pair(label, &item)); 1085 1085 } 1086 1086 … … 1101 1101 throw DataFormatError("Cannot find nodeset or label map"); 1102 1102 } 1103 for (int i = 0; i < (int)writers.size(); ++i) {1103 for (int i = 0; i < int(writers.size()); ++i) { 1104 1104 os << writers[i].first << ' '; 1105 1105 labelWriter->write(os, *(writers[i].second)); … … 1165 1165 /// 1166 1166 /// Add an edge writer command for the EdgeWriter. 1167 void writeEdge( const std::string& name, const Edge& item) {1168 writers.push_back(make_pair( name, &item));1167 void writeEdge(std::string label, const Edge& item) { 1168 writers.push_back(make_pair(label, &item)); 1169 1169 } 1170 1170 … … 1185 1185 throw DataFormatError("Cannot find edgeset or label map"); 1186 1186 } 1187 for (int i = 0; i < (int)writers.size(); ++i) {1187 for (int i = 0; i < int(writers.size()); ++i) { 1188 1188 os << writers[i].first << ' '; 1189 1189 labelWriter->write(os, *(writers[i].second)); … … 1257 1257 /// 1258 1258 /// Add an edge writer command for the UEdgeWriter. 1259 void writeEdge( const std::string& name, const Edge& item) {1260 edgeWriters.push_back(make_pair( name, &item));1259 void writeEdge(std::string label, const Edge& item) { 1260 edgeWriters.push_back(make_pair(label, &item)); 1261 1261 } 1262 1262 … … 1264 1264 /// 1265 1265 /// Add an undirected edge writer command for the UEdgeWriter. 1266 void writeUEdge( const std::string& name, const UEdge& item) {1267 uEdgeWriters.push_back(make_pair( name, &item));1266 void writeUEdge(std::string label, const UEdge& item) { 1267 uEdgeWriters.push_back(make_pair(label, &item)); 1268 1268 } 1269 1269 … … 1287 1287 throw DataFormatError("Cannot find undirected edgeset or label map"); 1288 1288 } 1289 for (int i = 0; i < (int)uEdgeWriters.size(); ++i) {1289 for (int i = 0; i < int(uEdgeWriters.size()); ++i) { 1290 1290 os << uEdgeWriters[i].first << ' '; 1291 1291 uEdgeLabelWriter->write(os, *(uEdgeWriters[i].second)); 1292 1292 os << std::endl; 1293 1293 } 1294 for (int i = 0; i < (int)edgeWriters.size(); ++i) {1294 for (int i = 0; i < int(edgeWriters.size()); ++i) { 1295 1295 os << edgeWriters[i].first << ' '; 1296 1296 edgeLabelWriter->write(os, *(edgeWriters[i].second)); … … 1364 1364 /// Add an attribute writer command for the writer. 1365 1365 template <typename Value> 1366 AttributeWriter& writeAttribute( const std::string& name,1366 AttributeWriter& writeAttribute(std::string label, 1367 1367 const Value& value) { 1368 1368 return … … 1373 1373 /// 1374 1374 /// Add an attribute writer command for the writer. 1375 template <typename Writer, typename Value> 1376 AttributeWriter& writeAttribute(const std::string& name, 1377 const Value& value, 1378 const Writer& writer = Writer()) { 1379 checkConcept<_writer_bits::ItemWriter<Value>, Writer>(); 1380 writers.push_back(make_pair(name, new _writer_bits:: 1381 ValueWriter<Value, Writer>(value, writer))); 1375 template <typename ItemWriter, typename Value> 1376 AttributeWriter& writeAttribute(std::string label, const Value& value, 1377 const ItemWriter& iw = ItemWriter()) { 1378 checkConcept<_writer_bits::ItemWriter<Value>, ItemWriter>(); 1379 writers.push_back(make_pair(label, new _writer_bits:: 1380 ValueWriter<Value, ItemWriter>(value, iw))); 1382 1381 return *this; 1383 1382 } -
lemon/list_graph.h
r2381 r2386 523 523 } 524 524 virtual void erase(const std::vector<Node>& nodes) { 525 for (int i = 0; i < (int)nodes.size(); ++i) {525 for (int i = 0; i < int(nodes.size()); ++i) { 526 526 snapshot.eraseNode(nodes[i]); 527 527 } 528 528 } 529 529 virtual void build() { 530 NodeNotifier* _notifier = notifier();531 530 Node node; 532 531 std::vector<Node> nodes; 533 for ( _notifier->first(node); node != INVALID;534 _notifier->next(node)) {532 for (notifier()->first(node); node != INVALID; 533 notifier()->next(node)) { 535 534 nodes.push_back(node); 536 535 } … … 540 539 } 541 540 virtual void clear() { 542 NodeNotifier* _notifier = notifier();543 541 Node node; 544 for ( _notifier->first(node); node != INVALID;545 _notifier->next(node)) {542 for (notifier()->first(node); node != INVALID; 543 notifier()->next(node)) { 546 544 snapshot.eraseNode(node); 547 545 } … … 575 573 } 576 574 virtual void erase(const std::vector<Edge>& edges) { 577 for (int i = 0; i < (int)edges.size(); ++i) {575 for (int i = 0; i < int(edges.size()); ++i) { 578 576 snapshot.eraseEdge(edges[i]); 579 577 } 580 578 } 581 579 virtual void build() { 582 EdgeNotifier* _notifier = notifier();583 580 Edge edge; 584 581 std::vector<Edge> edges; 585 for ( _notifier->first(edge); edge != INVALID;586 _notifier->next(edge)) {582 for (notifier()->first(edge); edge != INVALID; 583 notifier()->next(edge)) { 587 584 edges.push_back(edge); 588 585 } … … 592 589 } 593 590 virtual void clear() { 594 EdgeNotifier* _notifier = notifier();595 591 Edge edge; 596 for (_notifier->first(edge); edge != INVALID; _notifier->next(edge)) { 592 for (notifier()->first(edge); edge != INVALID; 593 notifier()->next(edge)) { 597 594 snapshot.eraseEdge(edge); 598 595 } … … 1270 1267 } 1271 1268 virtual void erase(const std::vector<Node>& nodes) { 1272 for (int i = 0; i < (int)nodes.size(); ++i) {1269 for (int i = 0; i < int(nodes.size()); ++i) { 1273 1270 snapshot.eraseNode(nodes[i]); 1274 1271 } 1275 1272 } 1276 1273 virtual void build() { 1277 NodeNotifier* _notifier = notifier();1278 1274 Node node; 1279 1275 std::vector<Node> nodes; 1280 for ( _notifier->first(node); node != INVALID;1281 _notifier->next(node)) {1276 for (notifier()->first(node); node != INVALID; 1277 notifier()->next(node)) { 1282 1278 nodes.push_back(node); 1283 1279 } … … 1287 1283 } 1288 1284 virtual void clear() { 1289 NodeNotifier* _notifier = notifier();1290 1285 Node node; 1291 for ( _notifier->first(node); node != INVALID;1292 _notifier->next(node)) {1286 for (notifier()->first(node); node != INVALID; 1287 notifier()->next(node)) { 1293 1288 snapshot.eraseNode(node); 1294 1289 } … … 1322 1317 } 1323 1318 virtual void erase(const std::vector<UEdge>& edges) { 1324 for (int i = 0; i < (int)edges.size(); ++i) {1319 for (int i = 0; i < int(edges.size()); ++i) { 1325 1320 snapshot.eraseUEdge(edges[i]); 1326 1321 } 1327 1322 } 1328 1323 virtual void build() { 1329 UEdgeNotifier* _notifier = notifier();1330 1324 UEdge edge; 1331 1325 std::vector<UEdge> edges; 1332 for ( _notifier->first(edge); edge != INVALID;1333 _notifier->next(edge)) {1326 for (notifier()->first(edge); edge != INVALID; 1327 notifier()->next(edge)) { 1334 1328 edges.push_back(edge); 1335 1329 } … … 1339 1333 } 1340 1334 virtual void clear() { 1341 UEdgeNotifier* _notifier = notifier();1342 1335 UEdge edge; 1343 for ( _notifier->first(edge); edge != INVALID;1344 _notifier->next(edge)) {1336 for (notifier()->first(edge); edge != INVALID; 1337 notifier()->next(edge)) { 1345 1338 snapshot.eraseUEdge(edge); 1346 1339 } … … 1576 1569 1577 1570 void first(UEdge& edge) const { 1578 int a NodeId = first_anode;1579 while (a NodeId != -1 && aNodes[aNodeId].first_edge == -1) {1580 a NodeId = aNodes[aNodeId].next != -1 ?1581 aNodes[a NodeId].next >> 1 : -1;1582 } 1583 if (a NodeId != -1) {1584 edge.id = aNodes[a NodeId].first_edge;1571 int aid = first_anode; 1572 while (aid != -1 && aNodes[aid].first_edge == -1) { 1573 aid = aNodes[aid].next != -1 ? 1574 aNodes[aid].next >> 1 : -1; 1575 } 1576 if (aid != -1) { 1577 edge.id = aNodes[aid].first_edge; 1585 1578 } else { 1586 1579 edge.id = -1; … … 1588 1581 } 1589 1582 void next(UEdge& edge) const { 1590 int a NodeId = edges[edge.id].aNode >> 1;1583 int aid = edges[edge.id].aNode >> 1; 1591 1584 edge.id = edges[edge.id].next_out; 1592 1585 if (edge.id == -1) { 1593 a NodeId = aNodes[aNodeId].next != -1 ?1594 aNodes[a NodeId].next >> 1 : -1;1595 while (a NodeId != -1 && aNodes[aNodeId].first_edge == -1) {1596 a NodeId = aNodes[aNodeId].next != -1 ?1597 aNodes[a NodeId].next >> 1 : -1;1598 } 1599 if (a NodeId != -1) {1600 edge.id = aNodes[a NodeId].first_edge;1586 aid = aNodes[aid].next != -1 ? 1587 aNodes[aid].next >> 1 : -1; 1588 while (aid != -1 && aNodes[aid].first_edge == -1) { 1589 aid = aNodes[aid].next != -1 ? 1590 aNodes[aid].next >> 1 : -1; 1591 } 1592 if (aid != -1) { 1593 edge.id = aNodes[aid].first_edge; 1601 1594 } else { 1602 1595 edge.id = -1; … … 1678 1671 1679 1672 Node addANode() { 1680 int a NodeId;1673 int aid; 1681 1674 if (first_free_anode == -1) { 1682 a NodeId = aNodes.size();1675 aid = aNodes.size(); 1683 1676 aNodes.push_back(NodeT()); 1684 1677 } else { 1685 a NodeId = first_free_anode;1678 aid = first_free_anode; 1686 1679 first_free_anode = aNodes[first_free_anode].next; 1687 1680 } 1688 1681 if (first_anode != -1) { 1689 aNodes[a NodeId].next = first_anode << 1;1690 aNodes[first_anode].prev = a NodeId << 1;1691 } else { 1692 aNodes[a NodeId].next = -1;1693 } 1694 aNodes[a NodeId].prev = -1;1695 first_anode = a NodeId;1696 aNodes[a NodeId].first_edge = -1;1697 return Node(a NodeId << 1);1682 aNodes[aid].next = first_anode << 1; 1683 aNodes[first_anode].prev = aid << 1; 1684 } else { 1685 aNodes[aid].next = -1; 1686 } 1687 aNodes[aid].prev = -1; 1688 first_anode = aid; 1689 aNodes[aid].first_edge = -1; 1690 return Node(aid << 1); 1698 1691 } 1699 1692 1700 1693 Node addBNode() { 1701 int b NodeId;1694 int bid; 1702 1695 if (first_free_bnode == -1) { 1703 b NodeId = bNodes.size();1696 bid = bNodes.size(); 1704 1697 bNodes.push_back(NodeT()); 1705 1698 } else { 1706 b NodeId = first_free_bnode;1699 bid = first_free_bnode; 1707 1700 first_free_bnode = bNodes[first_free_bnode].next; 1708 1701 } 1709 1702 if (first_bnode != -1) { 1710 bNodes[b NodeId].next = (first_bnode << 1) + 1;1711 bNodes[first_bnode].prev = (b NodeId << 1) + 1;1712 } else { 1713 bNodes[b NodeId].next = -1;1714 } 1715 bNodes[b NodeId].prev = -1;1716 first_bnode = b NodeId;1717 bNodes[b NodeId].first_edge = -1;1718 return Node((b NodeId << 1) + 1);1703 bNodes[bid].next = (first_bnode << 1) + 1; 1704 bNodes[first_bnode].prev = (bid << 1) + 1; 1705 } else { 1706 bNodes[bid].next = -1; 1707 } 1708 bNodes[bid].prev = -1; 1709 first_bnode = bid; 1710 bNodes[bid].first_edge = -1; 1711 return Node((bid << 1) + 1); 1719 1712 } 1720 1713 … … 1753 1746 void erase(const Node& node) { 1754 1747 if (aNode(node)) { 1755 int a NodeId = node.id >> 1;1756 if (aNodes[a NodeId].prev != -1) {1757 aNodes[aNodes[a NodeId].prev >> 1].next = aNodes[aNodeId].next;1748 int aid = node.id >> 1; 1749 if (aNodes[aid].prev != -1) { 1750 aNodes[aNodes[aid].prev >> 1].next = aNodes[aid].next; 1758 1751 } else { 1759 1752 first_anode = 1760 aNodes[a NodeId].next != -1 ? aNodes[aNodeId].next >> 1 : -1;1761 } 1762 if (aNodes[a NodeId].next != -1) {1763 aNodes[aNodes[a NodeId].next >> 1].prev = aNodes[aNodeId].prev;1764 } 1765 aNodes[a NodeId].next = first_free_anode;1766 first_free_anode = a NodeId;1767 } else { 1768 int b NodeId = node.id >> 1;1769 if (bNodes[b NodeId].prev != -1) {1770 bNodes[bNodes[b NodeId].prev >> 1].next = bNodes[bNodeId].next;1753 aNodes[aid].next != -1 ? aNodes[aid].next >> 1 : -1; 1754 } 1755 if (aNodes[aid].next != -1) { 1756 aNodes[aNodes[aid].next >> 1].prev = aNodes[aid].prev; 1757 } 1758 aNodes[aid].next = first_free_anode; 1759 first_free_anode = aid; 1760 } else { 1761 int bid = node.id >> 1; 1762 if (bNodes[bid].prev != -1) { 1763 bNodes[bNodes[bid].prev >> 1].next = bNodes[bid].next; 1771 1764 } else { 1772 1765 first_bnode = 1773 bNodes[b NodeId].next != -1 ? bNodes[bNodeId].next >> 1 : -1;1774 } 1775 if (bNodes[b NodeId].next != -1) {1776 bNodes[bNodes[b NodeId].next >> 1].prev = bNodes[bNodeId].prev;1777 } 1778 bNodes[b NodeId].next = first_free_bnode;1779 first_free_bnode = b NodeId;1766 bNodes[bid].next != -1 ? bNodes[bid].next >> 1 : -1; 1767 } 1768 if (bNodes[bid].next != -1) { 1769 bNodes[bNodes[bid].next >> 1].prev = bNodes[bid].prev; 1770 } 1771 bNodes[bid].next = first_free_bnode; 1772 first_free_bnode = bid; 1780 1773 } 1781 1774 } … … 2052 2045 } 2053 2046 virtual void erase(const std::vector<Node>& nodes) { 2054 for (int i = 0; i < (int)nodes.size(); ++i) {2047 for (int i = 0; i < int(nodes.size()); ++i) { 2055 2048 snapshot.eraseNode(nodes[i]); 2056 2049 } 2057 2050 } 2058 2051 virtual void build() { 2059 NodeNotifier* _notifier = notifier();2060 2052 Node node; 2061 2053 std::vector<Node> nodes; 2062 for ( _notifier->first(node); node != INVALID;2063 _notifier->next(node)) {2054 for (notifier()->first(node); node != INVALID; 2055 notifier()->next(node)) { 2064 2056 nodes.push_back(node); 2065 2057 } … … 2069 2061 } 2070 2062 virtual void clear() { 2071 NodeNotifier* _notifier = notifier();2072 2063 Node node; 2073 for ( _notifier->first(node); node != INVALID;2074 _notifier->next(node)) {2064 for (notifier()->first(node); node != INVALID; 2065 notifier()->next(node)) { 2075 2066 snapshot.eraseNode(node); 2076 2067 } … … 2104 2095 } 2105 2096 virtual void erase(const std::vector<UEdge>& edges) { 2106 for (int i = 0; i < (int)edges.size(); ++i) {2097 for (int i = 0; i < int(edges.size()); ++i) { 2107 2098 snapshot.eraseUEdge(edges[i]); 2108 2099 } 2109 2100 } 2110 2101 virtual void build() { 2111 UEdgeNotifier* _notifier = notifier();2112 2102 UEdge edge; 2113 2103 std::vector<UEdge> edges; 2114 for ( _notifier->first(edge); edge != INVALID;2115 _notifier->next(edge)) {2104 for (notifier()->first(edge); edge != INVALID; 2105 notifier()->next(edge)) { 2116 2106 edges.push_back(edge); 2117 2107 } … … 2121 2111 } 2122 2112 virtual void clear() { 2123 UEdgeNotifier* _notifier = notifier();2124 2113 UEdge edge; 2125 for ( _notifier->first(edge); edge != INVALID;2126 _notifier->next(edge)) {2114 for (notifier()->first(edge); edge != INVALID; 2115 notifier()->next(edge)) { 2127 2116 snapshot.eraseUEdge(edge); 2128 2117 } -
lemon/lp_base.h
r2370 r2386 200 200 protected: 201 201 202 int _lpId(const Col& c ol) const {203 return cols.floatingId(id(c ol));204 } 205 206 int _lpId(const Row& r ow) const {207 return rows.floatingId(id(r ow));208 } 209 210 Col _item(int i d, Col) const {211 return Col(cols.fixId(i d));212 } 213 214 Row _item(int i d, Row) const {215 return Row(rows.fixId(i d));202 int _lpId(const Col& c) const { 203 return cols.floatingId(id(c)); 204 } 205 206 int _lpId(const Row& r) const { 207 return rows.floatingId(id(r)); 208 } 209 210 Col _item(int i, Col) const { 211 return Col(cols.fixId(i)); 212 } 213 214 Row _item(int i, Row) const { 215 return Row(rows.fixId(i)); 216 216 } 217 217 … … 892 892 ///function. It is 0 by default. 893 893 ///\return The created column. 894 Col addCol(const DualExpr &e, Value o bj=0) {894 Col addCol(const DualExpr &e, Value o = 0) { 895 895 Col c=addCol(); 896 896 col(c,e); 897 objCoeff(c,o bj);897 objCoeff(c,o); 898 898 return c; 899 899 } -
lemon/lp_glpk.cc
r2368 r2386 104 104 105 105 void LpGlpk::_eraseCol(int i) { 106 int c ols[2];107 c ols[1]=i;108 lpx_del_cols(lp, 1, c ols);106 int ca[2]; 107 ca[1]=i; 108 lpx_del_cols(lp, 1, ca); 109 109 } 110 110 111 111 void LpGlpk::_eraseRow(int i) { 112 int r ows[2];113 r ows[1]=i;114 lpx_del_rows(lp, 1, r ows);115 } 116 117 void LpGlpk::_getColName(int c ol, std::string & name) const118 { 119 120 char *n = lpx_get_col_name(lp,c ol);112 int ra[2]; 113 ra[1]=i; 114 lpx_del_rows(lp, 1, ra); 115 } 116 117 void LpGlpk::_getColName(int c, std::string & name) const 118 { 119 120 char *n = lpx_get_col_name(lp,c); 121 121 name = n?n:""; 122 122 } 123 123 124 124 125 void LpGlpk::_setColName(int c ol, const std::string & name)126 { 127 lpx_set_col_name(lp,c ol,const_cast<char*>(name.c_str()));125 void LpGlpk::_setColName(int c, const std::string & name) 126 { 127 lpx_set_col_name(lp,c,const_cast<char*>(name.c_str())); 128 128 129 129 } … … 152 152 } 153 153 154 void LpGlpk::_getRowCoeffs(int i , RowIterator b) const155 { 156 int length = lpx_get_mat_row(lp, i , 0, 0);154 void LpGlpk::_getRowCoeffs(int ix, RowIterator b) const 155 { 156 int length = lpx_get_mat_row(lp, ix, 0, 0); 157 157 158 158 std::vector<int> indices(length + 1); 159 159 std::vector<Value> values(length + 1); 160 160 161 lpx_get_mat_row(lp, i , &indices[0], &values[0]);161 lpx_get_mat_row(lp, ix, &indices[0], &values[0]); 162 162 163 163 for (int i = 1; i <= length; ++i) { … … 167 167 } 168 168 169 void LpGlpk::_setColCoeffs(int i , ConstColIterator b, ConstColIterator e) {169 void LpGlpk::_setColCoeffs(int ix, ConstColIterator b, ConstColIterator e) { 170 170 171 171 std::vector<int> indices; … … 180 180 } 181 181 182 lpx_set_mat_col(lp, i , values.size() - 1, &indices[0], &values[0]);183 } 184 185 void LpGlpk::_getColCoeffs(int i , ColIterator b) const186 { 187 int length = lpx_get_mat_col(lp, i , 0, 0);182 lpx_set_mat_col(lp, ix, values.size() - 1, &indices[0], &values[0]); 183 } 184 185 void LpGlpk::_getColCoeffs(int ix, ColIterator b) const 186 { 187 int length = lpx_get_mat_col(lp, ix, 0, 0); 188 188 189 189 std::vector<int> indices(length + 1); 190 190 std::vector<Value> values(length + 1); 191 191 192 lpx_get_mat_col(lp, i , &indices[0], &values[0]);192 lpx_get_mat_col(lp, ix, &indices[0], &values[0]); 193 193 194 194 for (int i = 1; i <= length; ++i) { … … 198 198 } 199 199 200 void LpGlpk::_setCoeff(int row, int col, Value value)200 void LpGlpk::_setCoeff(int ix, int jx, Value value) 201 201 { 202 202 203 203 if (lpx_get_num_cols(lp) < lpx_get_num_rows(lp)) { 204 204 205 int length=lpx_get_mat_row(lp, row, 0, 0);205 int length=lpx_get_mat_row(lp, ix, 0, 0); 206 206 207 207 std::vector<int> indices(length + 2); 208 208 std::vector<Value> values(length + 2); 209 209 210 lpx_get_mat_row(lp, row, &indices[0], &values[0]);210 lpx_get_mat_row(lp, ix, &indices[0], &values[0]); 211 211 212 212 //The following code does not suppose that the elements of the … … 214 214 bool found=false; 215 215 for (int i = 1; i <= length; ++i) { 216 if (indices[i]== col){216 if (indices[i]==jx){ 217 217 found=true; 218 218 values[i]=value; … … 222 222 if (!found){ 223 223 ++length; 224 indices[length]= col;224 indices[length]=jx; 225 225 values[length]=value; 226 226 } 227 227 228 lpx_set_mat_row(lp, row, length, &indices[0], &values[0]);228 lpx_set_mat_row(lp, ix, length, &indices[0], &values[0]); 229 229 230 230 } else { 231 231 232 int length=lpx_get_mat_col(lp, col, 0, 0);232 int length=lpx_get_mat_col(lp, jx, 0, 0); 233 233 234 234 std::vector<int> indices(length + 2); 235 235 std::vector<Value> values(length + 2); 236 236 237 lpx_get_mat_col(lp, col, &indices[0], &values[0]);237 lpx_get_mat_col(lp, jx, &indices[0], &values[0]); 238 238 239 239 //The following code does not suppose that the elements of the … … 241 241 bool found=false; 242 242 for (int i = 1; i <= length; ++i) { 243 if (indices[i]== col){243 if (indices[i]==jx){ 244 244 found=true; 245 245 values[i]=value; … … 249 249 if (!found){ 250 250 ++length; 251 indices[length]= row;251 indices[length]=ix; 252 252 values[length]=value; 253 253 } 254 254 255 lpx_set_mat_col(lp, col, length, &indices[0], &values[0]);256 } 257 } 258 259 LpGlpk::Value LpGlpk::_getCoeff(int row, int col) const260 { 261 262 int length=lpx_get_mat_row(lp, row, 0, 0);255 lpx_set_mat_col(lp, jx, length, &indices[0], &values[0]); 256 } 257 } 258 259 LpGlpk::Value LpGlpk::_getCoeff(int ix, int jx) const 260 { 261 262 int length=lpx_get_mat_row(lp, ix, 0, 0); 263 263 264 264 std::vector<int> indices(length + 1); 265 265 std::vector<Value> values(length + 1); 266 266 267 lpx_get_mat_row(lp, row, &indices[0], &values[0]);267 lpx_get_mat_row(lp, ix, &indices[0], &values[0]); 268 268 269 269 //The following code does not suppose that the elements of the 270 270 //array indices are sorted 271 271 for (int i = 1; i <= length; ++i) { 272 if (indices[i]== col){272 if (indices[i]==jx){ 273 273 return values[i]; 274 274 } -
lemon/lp_soplex.cc
r2368 r2386 45 45 LpSolverBase &LpSoplex::_copyLp() { 46 46 LpSoplex* newlp = new LpSoplex(); 47 ( (soplex::SPxLP&)*(newlp->soplex)) = *soplex;47 (*static_cast<soplex::SPxLP*>(newlp->soplex)) = *soplex; 48 48 return *newlp; 49 49 } 50 50 51 51 int LpSoplex::_addCol() { 52 soplex::LPCol c ol;53 c ol.setLower(-soplex::infinity);54 c ol.setUpper(soplex::infinity);55 soplex->addCol(c ol);52 soplex::LPCol c; 53 c.setLower(-soplex::infinity); 54 c.setUpper(soplex::infinity); 55 soplex->addCol(c); 56 56 57 57 colNames.push_back(std::string()); … … 63 63 64 64 int LpSoplex::_addRow() { 65 soplex::LPRow r ow;66 r ow.setLhs(-soplex::infinity);67 r ow.setRhs(soplex::infinity);68 soplex->addRow(r ow);65 soplex::LPRow r; 66 r.setLhs(-soplex::infinity); 67 r.setRhs(soplex::infinity); 68 soplex->addRow(r); 69 69 70 70 dual_value.push_back(0.0); … … 93 93 } 94 94 95 void LpSoplex::_getColName(int c ol, std::string &name) const {96 name = colNames[c ol];97 } 98 99 void LpSoplex::_setColName(int c ol, const std::string &name) {100 invColNames.erase(colNames[c ol]);101 colNames[c ol] = name;95 void LpSoplex::_getColName(int c, std::string &name) const { 96 name = colNames[c]; 97 } 98 99 void LpSoplex::_setColName(int c, const std::string &name) { 100 invColNames.erase(colNames[c]); 101 colNames[c] = name; 102 102 if (!name.empty()) { 103 invColNames.insert(std::make_pair(name, c ol));103 invColNames.insert(std::make_pair(name, c)); 104 104 } 105 105 } -
lemon/matrix_maps.h
r2384 r2386 350 350 351 351 virtual void add(const Key& key) { 352 if (size(Parent::notifier()->id(key) + 1) >= (int)values.size()) {352 if (size(Parent::notifier()->id(key) + 1) >= int(values.size())) { 353 353 values.resize(size(Parent::notifier()->id(key) + 1)); 354 354 } … … 357 357 virtual void add(const std::vector<Key>& keys) { 358 358 int new_size = 0; 359 for (int i = 0; i < (int)keys.size(); ++i) {359 for (int i = 0; i < int(keys.size()); ++i) { 360 360 if (size(Parent::notifier()->id(keys[i]) + 1) >= new_size) { 361 361 new_size = size(Parent::notifier()->id(keys[i]) + 1); 362 362 } 363 363 } 364 if (new_size > (int)values.size()) {364 if (new_size > int(values.size())) { 365 365 values.resize(new_size); 366 366 } … … 505 505 506 506 virtual void add(const Key& key) { 507 if (size(Parent::notifier()->id(key) + 1) >= (int)values.size()) {507 if (size(Parent::notifier()->id(key) + 1) >= int(values.size())) { 508 508 values.resize(size(Parent::notifier()->id(key) + 1)); 509 509 } … … 512 512 virtual void add(const std::vector<Key>& keys) { 513 513 int new_size = 0; 514 for (int i = 0; i < (int)keys.size(); ++i) {514 for (int i = 0; i < int(keys.size()); ++i) { 515 515 if (size(Parent::notifier()->id(keys[i]) + 1) >= new_size) { 516 516 new_size = size(Parent::notifier()->id(keys[i]) + 1); 517 517 } 518 518 } 519 if (new_size > (int)values.size()) {519 if (new_size > int(values.size())) { 520 520 values.resize(new_size); 521 521 } … … 916 916 ///class belongs to the FirstKey type. 917 917 void addFirstKey(const FirstKey& firstKey) { 918 int size = (int)values.size();918 int size = int(values.size()); 919 919 if( _first_key_proxy.notifier()->id(firstKey)+1 >= size ){ 920 920 values.resize(_first_key_proxy.notifier()->id(firstKey)+1); 921 if( (int)values[0].size() != 0 ){922 int innersize = (int)values[0].size();923 for(int i =size; i!=(int)values.size();++i){921 if( int(values[0].size()) != 0 ){ 922 int innersize = int(values[0].size()); 923 for(int i = size; i < int(values.size());++i){ 924 924 (values[i]).resize(innersize); 925 925 } 926 926 }else if(_second_key_proxy.notifier()->maxId() >= 0){ 927 927 int innersize = _second_key_proxy.notifier()->maxId(); 928 for(int i = 0; i != (int)values.size(); ++i){928 for(int i = 0; i < int(values.size()); ++i){ 929 929 values[0].resize(innersize); 930 930 } … … 939 939 void addFirstKeys(const std::vector<FirstKey>& firstKeys){ 940 940 int max = values.size() - 1; 941 for(int i =0; i != (int)firstKeys.size(); ++i){941 for(int i = 0; i < int(firstKeys.size()); ++i){ 942 942 int id = _first_key_proxy.notifier()->id(firstKeys[i]); 943 943 if(max < id){ … … 945 945 } 946 946 } 947 int size = (int)values.size();947 int size = int(values.size()); 948 948 if(max >= size){ 949 949 values.resize(max + 1); 950 if( (int)values[0].size() != 0){951 int innersize = (int)values[0].size();952 for(int i = size; i !=(max + 1); ++i){950 if( int(values[0].size()) != 0){ 951 int innersize = int(values[0].size()); 952 for(int i = size; i < (max + 1); ++i){ 953 953 values[i].resize(innersize); 954 954 } 955 955 }else if(_second_key_proxy.notifier()->maxId() >= 0){ 956 956 int innersize = _second_key_proxy.notifier()->maxId(); 957 for(int i = 0; i != (int)values.size(); ++i){957 for(int i = 0; i < int(values.size()); ++i){ 958 958 values[i].resize(innersize); 959 959 } … … 971 971 } 972 972 int id = _second_key_proxy.notifier()->id(secondKey); 973 if(id >= (int)values[0].size()){974 for(int i =0;i!=(int)values.size();++i){973 if(id >= int(values[0].size())){ 974 for(int i = 0; i < int(values.size());++i){ 975 975 values[i].resize(id+1); 976 976 } … … 987 987 } 988 988 int max = values[0].size(); 989 for(int i = 0; i != (int)secondKeys.size(); ++i){989 for(int i = 0; i < int(secondKeys.size()); ++i){ 990 990 int id = _second_key_proxy.notifier()->id(secondKeys[i]); 991 991 if(max < id){ … … 993 993 } 994 994 } 995 if(max > (int)values[0].size()){996 for(int i = 0; i != (int)values.size(); ++i){995 if(max > int(values[0].size())){ 996 for(int i = 0; i < int(values.size()); ++i){ 997 997 values[i].resize(max + 1); 998 998 } … … 1006 1006 void eraseFirstKey(const FirstKey& first) { 1007 1007 int id = _first_key_proxy.notifier()->id(first); 1008 for(int i = 0; i != (int)values[id].size(); ++i){1008 for(int i = 0; i < int(values[id].size()); ++i){ 1009 1009 values[id][i] = Value(); 1010 1010 } … … 1016 1016 ///class belongs to the FirstKey type. 1017 1017 void eraseFirstKeys(const std::vector<FirstKey>& firstKeys) { 1018 for(int j = 0; j != (int)firstKeys.size(); ++j){1018 for(int j = 0; j < int(firstKeys.size()); ++j){ 1019 1019 int id = _first_key_proxy.notifier()->id(firstKeys[j]); 1020 for(int i = 0; i != (int)values[id].size(); ++i){1020 for(int i = 0; i < int(values[id].size()); ++i){ 1021 1021 values[id][i] = Value(); 1022 1022 } … … 1033 1033 } 1034 1034 int id = _second_key_proxy.notifier()->id(second); 1035 for(int i = 0; i != (int)values.size(); ++i){1035 for(int i = 0; i < int(values.size()); ++i){ 1036 1036 values[i][id] = Value(); 1037 1037 } … … 1046 1046 return; 1047 1047 } 1048 for(int j = 0; j != (int)secondKeys.size(); ++j){1048 for(int j = 0; j < int(secondKeys.size()); ++j){ 1049 1049 int id = _second_key_proxy.notifier()->id(secondKeys[j]); 1050 for(int i = 0; i != (int)values.size(); ++i){1050 for(int i = 0; i < int(values.size()); ++i){ 1051 1051 values[i][id] = Value(); 1052 1052 } … … 1060 1060 void build() { 1061 1061 values.resize(_first_key_proxy.notifier()->maxId()); 1062 for(int i =0; i!=(int)values.size(); ++i){1062 for(int i = 0; i< int(values.size()); ++i){ 1063 1063 values[i].resize(_second_key_proxy.notifier()->maxId()); 1064 1064 } … … 1070 1070 ///belongs to the FirstKey or SecondKey type. 1071 1071 void clear() { 1072 for(int i =0; i!=(int)values.size(); ++i) {1072 for(int i = 0; i < int(values.size()); ++i) { 1073 1073 values[i].clear(); 1074 1074 } -
lemon/max_matching.h
r2308 r2386 356 356 template <typename Graph> 357 357 void MaxMatching<Graph>::lateShrink(Node v, typename Graph::template 358 NodeMap<Node>& ear, UFE& blossom, UFE& tree) { 358 NodeMap<Node>& ear, UFE& blossom, 359 UFE& tree) { 359 360 //We have one tree which we grow, and also shrink but only if it cannot be 360 361 //postponed. If we augment then we return to the "for" cycle of … … 373 374 //growOrAugment grows if y is covered by the matching and 374 375 //augments if not. In this latter case it returns 1. 375 if ( position[y]==C && growOrAugment(y, x, ear, blossom, tree, Q) ) return; 376 if ( position[y]==C && growOrAugment(y, x, ear, blossom, tree, Q) ) 377 return; 376 378 } 377 379 R.push(x); … … 390 392 391 393 while ( !Q.empty() ) { 392 Node x=Q.front();394 Node z=Q.front(); 393 395 Q.pop(); 394 for( IncEdgeIt e(g,x); e!= INVALID; ++e) {395 Node y=g.runningNode(e);396 for( IncEdgeIt f(g,z); f!= INVALID; ++f ) { 397 Node w=g.runningNode(f); 396 398 //growOrAugment grows if y is covered by the matching and 397 399 //augments if not. In this latter case it returns 1. 398 if ( position[y]==C && growOrAugment(y, x, ear, blossom, tree, Q) ) return; 400 if ( position[w]==C && growOrAugment(w, z, ear, blossom, tree, Q) ) 401 return; 399 402 } 400 R.push( x);403 R.push(z); 401 404 } 402 405 } //for e -
lemon/nagamochi_ibaraki.h
r2376 r2386 439 439 /// automatically allocated map, of course. 440 440 /// \return <tt> (*this) </tt> 441 MaxCardinalitySearch &heap(Heap& h eap, HeapCrossRef &crossRef) {441 MaxCardinalitySearch &heap(Heap& hp, HeapCrossRef &cr) { 442 442 if(local_heap_cross_ref) { 443 443 delete _heap_cross_ref; 444 444 local_heap_cross_ref = false; 445 445 } 446 _heap_cross_ref = &cr ossRef;446 _heap_cross_ref = &cr; 447 447 if(local_heap) { 448 448 delete _heap; 449 449 local_heap = false; 450 450 } 451 _heap = &h eap;451 _heap = &hp; 452 452 return *this; 453 453 } … … 1169 1169 /// automatically allocated heap and cross reference, of course. 1170 1170 /// \return <tt> (*this) </tt> 1171 NagamochiIbaraki &heap(Heap& h eap, HeapCrossRef &crossRef)1171 NagamochiIbaraki &heap(Heap& hp, HeapCrossRef &cr) 1172 1172 { 1173 1173 if (local_heap_cross_ref) { … … 1175 1175 local_heap_cross_ref=false; 1176 1176 } 1177 _heap_cross_ref = &cr ossRef;1177 _heap_cross_ref = &cr; 1178 1178 if (local_heap) { 1179 1179 delete _heap; 1180 1180 local_heap=false; 1181 1181 } 1182 _heap = &h eap;1182 _heap = &hp; 1183 1183 return *this; 1184 1184 } … … 1319 1319 } 1320 1320 1321 if ( (int)nodes.size() < _node_num) {1321 if (int(nodes.size()) < _node_num) { 1322 1322 _aux_graph->clear(); 1323 1323 _node_num = 1; 1324 1324 _cut.clear(); 1325 for (int i = 0; i < (int)nodes.size(); ++i) {1325 for (int i = 0; i < int(nodes.size()); ++i) { 1326 1326 typename Graph::Node n = (*_first)[nodes[i]]; 1327 1327 while (n != INVALID) { … … 1361 1361 } 1362 1362 1363 if (ufe.size((typename Ufe::ClassIt)(ufe)) == _node_num) { 1363 typedef typename Ufe::ClassIt UfeCIt; 1364 if (ufe.size(UfeCIt(ufe)) == _node_num) { 1364 1365 _aux_graph->clear(); 1365 1366 _node_num = 1; … … 1373 1374 if (ufe.size(c) == 1) continue; 1374 1375 for (typename Ufe::ItemIt r(ufe, c); r != INVALID; ++r) { 1375 if ( (Node)r == (Node)c) continue;1376 if (static_cast<Node>(r) == static_cast<Node>(c)) continue; 1376 1377 _next->set((*_last)[c], (*_first)[r]); 1377 1378 _last->set(c, (*_last)[r]); … … 1408 1409 } 1409 1410 1410 for (int i = 0; i < (int)remedges.size(); ++i) {1411 for (int i = 0; i < int(remedges.size()); ++i) { 1411 1412 _aux_graph->erase(remedges[i]); 1412 1413 } … … 1416 1417 { 1417 1418 int i = 0; 1418 while (i < (int)addedges.size()) {1419 while (i < int(addedges.size())) { 1419 1420 Node sn = addedges[i].source; 1420 1421 Node tn = addedges[i].target; 1421 1422 Value ec = addedges[i].capacity; 1422 1423 ++i; 1423 while (i < (int)addedges.size() &&1424 while (i < int(addedges.size()) && 1424 1425 sn == addedges[i].source && tn == addedges[i].target) { 1425 1426 ec += addedges[i].capacity; … … 1443 1444 } 1444 1445 1445 for (int i = 0; i < (int)remnodes.size(); ++i) {1446 for (int i = 0; i < int(remnodes.size()); ++i) { 1446 1447 _aux_graph->erase(remnodes[i]); 1447 1448 } … … 1501 1502 template <typename NodeMap> 1502 1503 Value quickMinCut(NodeMap& nodeMap) const { 1503 for (int i = 0; i < (int)_cut.size(); ++i) {1504 for (int i = 0; i < int(_cut.size()); ++i) { 1504 1505 nodeMap.set(_cut[i], true); 1505 1506 } -
lemon/path.h
r2357 r2386 141 141 /// \pre n is in the [0..length() - 1] range 142 142 const Edge& nth(int n) const { 143 return n < (int)head.size() ? *(head.rbegin() + n) :143 return n < int(head.size()) ? *(head.rbegin() + n) : 144 144 *(tail.begin() + (n - head.size())); 145 145 } -
lemon/polynomial.h
r2207 r2386 51 51 template<class U> Polynomial(const Polynomial<U> &u) : _coeff(u.deg()+1) 52 52 { 53 for(int i=0;i< (int)_coeff.size();i++) _coeff[i]=u[i];53 for(int i=0;i<int(_coeff.size());i++) _coeff[i]=u[i]; 54 54 } 55 55 ///Query the degree of the polynomial. … … 112 112 Polynomial &derivateMyself() 113 113 { 114 for(int i=1;i< (int)_coeff.size();i++) _coeff[i-1]=i*_coeff[i];114 for(int i=1;i<int(_coeff.size());i++) _coeff[i-1]=i*_coeff[i]; 115 115 _coeff.pop_back(); 116 116 return *this; … … 121 121 { 122 122 Polynomial tmp(deg()-1); 123 for(int i=1;i< (int)_coeff.size();i++) tmp[i-1]=i*_coeff[i];123 for(int i=1;i<int(_coeff.size());i++) tmp[i-1]=i*_coeff[i]; 124 124 return tmp; 125 125 } … … 139 139 Polynomial tmp(deg()+1); 140 140 tmp[0]=0; 141 for(int i=0;i< (int)_coeff.size();i++) tmp[i+1]=_coeff[i]/(i+1);141 for(int i=0;i<int(_coeff.size());i++) tmp[i+1]=_coeff[i]/(i+1); 142 142 return tmp; 143 143 } … … 148 148 { 149 149 if(p.deg()>deg()) _coeff.resize(p.deg()+1); 150 for(int i=0;i<= (int)std::min(deg(),p.deg());i++)150 for(int i=0;i<=int(std::min(deg(),p.deg()));i++) 151 151 _coeff[i]+=p[i]; 152 152 return *this; -
lemon/preflow.h
r2376 r2386 235 235 void phase1() 236 236 { 237 int heur0= (int)(H0*_node_num); //time while running 'bound decrease'238 int heur1= (int)(H1*_node_num); //time while running 'highest label'237 int heur0=int(H0*_node_num); //time while running 'bound decrease' 238 int heur1=int(H1*_node_num); //time while running 'highest label' 239 239 int heur=heur1; //starting time interval (#of relabels) 240 240 int numrelabel=0; -
lemon/radix_heap.h
r2263 r2386 151 151 private: 152 152 153 bool upper(int box, Prio pr io) {154 return pr io< boxes[box].min;155 } 156 157 bool lower(int box, Prio pr io) {158 return pr io>= boxes[box].min + boxes[box].size;153 bool upper(int box, Prio pr) { 154 return pr < boxes[box].min; 155 } 156 157 bool lower(int box, Prio pr) { 158 return pr >= boxes[box].min + boxes[box].size; 159 159 } 160 160 … … 188 188 void extend() { 189 189 int min = boxes.back().min + boxes.back().size; 190 int size= 2 * boxes.back().size;191 boxes.push_back(RadixBox(min, size));190 int bs = 2 * boxes.back().size; 191 boxes.push_back(RadixBox(min, bs)); 192 192 } 193 193 … … 201 201 202 202 /// \brief Find up the proper box for the item with the given prio. 203 int findUp(int start, int pr io) {204 while (lower(start, pr io)) {205 if (++start == (int)boxes.size()) {203 int findUp(int start, int pr) { 204 while (lower(start, pr)) { 205 if (++start == int(boxes.size())) { 206 206 extend(); 207 207 } … … 219 219 220 220 /// \brief Find up the proper box for the item with the given prio. 221 int findDown(int start, int pr io) {222 while (upper(start, pr io)) {221 int findDown(int start, int pr) { 222 while (upper(start, pr)) { 223 223 if (--start < 0) throw UnderFlowPriorityError(); 224 224 } … … 261 261 262 262 void relocate_last(int index) { 263 if (index != (int)data.size() - 1) {263 if (index != int(data.size()) - 1) { 264 264 data[index] = data.back(); 265 265 if (data[index].prev != -1) { -
lemon/radix_sort.h
r2084 r2386 265 265 int byte, Functor functor) { 266 266 const int size = 267 (unsigned int)std::numeric_limits<unsigned char>::max() + 1;267 unsigned(std::numeric_limits<unsigned char>::max()) + 1; 268 268 std::vector<int> counter(size); 269 269 for (int i = 0; i < size; ++i) { … … 291 291 int byte, Functor functor) { 292 292 const int size = 293 (unsigned int)std::numeric_limits<unsigned char>::max() + 1;293 unsigned(std::numeric_limits<unsigned char>::max()) + 1; 294 294 std::vector<int> counter(size); 295 295 for (int i = 0; i < size; ++i) { … … 331 331 bool dir = true; 332 332 std::copy(first, last, buffer); 333 for (int i = 0; i < (int)sizeof(Value) - 1; ++i) {333 for (int i = 0; i < int(sizeof(Value)) - 1; ++i) { 334 334 if (dir) { 335 335 counterIntroSort(buffer, buffer + length, buffer + length, … … 369 369 bool dir = true; 370 370 std::copy(first, last, buffer); 371 for (int i = 0; i < (int)sizeof(Value); ++i) {371 for (int i = 0; i < int(sizeof(Value)); ++i) { 372 372 if (dir) { 373 373 counterIntroSort(buffer, buffer + length, -
lemon/random.h
r2380 r2386 122 122 static const int shift = 156; 123 123 124 static const Word mul = (Word)0x5851F42Du << 32 | (Word)0x4C957F2Du;125 static const Word arrayInit = (Word)0x00000000u << 32 |(Word)0x012BD6AAu;126 static const Word arrayMul1 = (Word)0x369DEA0Fu << 32 |(Word)0x31A53F85u;127 static const Word arrayMul2 = (Word)0x27BB2EE6u << 32 |(Word)0x87B0B0FDu;128 129 static const Word mask = (Word)0xB5026F5Au << 32 | (Word)0xA96619E9u;130 static const Word loMask = ( (Word)1u<< 31) - 1;124 static const Word mul = Word(0x5851F42Du) << 32 | Word(0x4C957F2Du); 125 static const Word arrayInit = Word(0x00000000u) << 32 |Word(0x012BD6AAu); 126 static const Word arrayMul1 = Word(0x369DEA0Fu) << 32 |Word(0x31A53F85u); 127 static const Word arrayMul2 = Word(0x27BB2EE6u) << 32 |Word(0x87B0B0FDu); 128 129 static const Word mask = Word(0xB5026F5Au) << 32 | Word(0xA96619E9u); 130 static const Word loMask = (Word(1u) << 31) - 1; 131 131 static const Word hiMask = ~loMask; 132 132 133 133 static Word tempering(Word rnd) { 134 rnd ^= (rnd >> 29) & ( (Word)0x55555555u << 32 | (Word)0x55555555u);135 rnd ^= (rnd << 17) & ( (Word)0x71D67FFFu << 32 | (Word)0xEDA60000u);136 rnd ^= (rnd << 37) & ( (Word)0xFFF7EEE0u << 32 | (Word)0x00000000u);134 rnd ^= (rnd >> 29) & (Word(0x55555555u) << 32 | Word(0x55555555u)); 135 rnd ^= (rnd << 17) & (Word(0x71D67FFFu) << 32 | Word(0xEDA60000u)); 136 rnd ^= (rnd << 37) & (Word(0xFFF7EEE0u) << 32 | Word(0x00000000u)); 137 137 rnd ^= (rnd >> 43); 138 138 return rnd; … … 217 217 } 218 218 219 state[length - 1] = (Word)1<< (bits - 1);219 state[length - 1] = Word(1) << (bits - 1); 220 220 } 221 221 … … 274 274 static Result mask(const Result& result) { 275 275 return Masker<Result, (shift + 1) / 2>:: 276 mask( (Result)(result | (result >> shift)));276 mask(static_cast<Result>(result | (result >> shift))); 277 277 } 278 278 }; … … 281 281 struct Masker<Result, 1> { 282 282 static Result mask(const Result& result) { 283 return (Result)(result | (result >> 1));283 return static_cast<Result>(result | (result >> 1)); 284 284 } 285 285 }; … … 292 292 293 293 static Result convert(RandomCore<Word>& rnd) { 294 return (Result)(rnd() >> (bits - rest)) << shift;294 return static_cast<Result>(rnd() >> (bits - rest)) << shift; 295 295 } 296 296 … … 302 302 303 303 static Result convert(RandomCore<Word>& rnd) { 304 return ( (Result)rnd() << shift) |304 return (static_cast<Result>(rnd()) << shift) | 305 305 IntConversion<Result, Word, rest - bits, shift + bits>::convert(rnd); 306 306 } … … 313 313 struct Mapping { 314 314 static Result map(RandomCore<Word>& rnd, const Result& bound) { 315 Word max = (Word)(bound - 1);315 Word max = Word(bound - 1); 316 316 Result mask = Masker<Result>::mask(bound - 1); 317 317 Result num; … … 326 326 struct Mapping<Result, Word, false> { 327 327 static Result map(RandomCore<Word>& rnd, const Result& bound) { 328 Word max = (Word)(bound - 1);328 Word max = Word(bound - 1); 329 329 Word mask = Masker<Word, (std::numeric_limits<Result>::digits + 1) / 2> 330 330 ::mask(max); … … 342 342 Result res = ShiftMultiplier<Result, exp / 2>::multiplier(); 343 343 res *= res; 344 if ((exp & 1) == 1) res *= (Result)2.0;344 if ((exp & 1) == 1) res *= static_cast<Result>(2.0); 345 345 return res; 346 346 } … … 352 352 Result res = ShiftMultiplier<Result, exp / 2>::multiplier(); 353 353 res *= res; 354 if ((exp & 1) == 1) res *= (Result)0.5;354 if ((exp & 1) == 1) res *= static_cast<Result>(0.5); 355 355 return res; 356 356 } … … 360 360 struct ShiftMultiplier<Result, 0, true> { 361 361 static const Result multiplier() { 362 return (Result)1.0;362 return static_cast<Result>(1.0); 363 363 } 364 364 }; … … 367 367 struct ShiftMultiplier<Result, -20, true> { 368 368 static const Result multiplier() { 369 return (Result)(1.0/1048576.0);369 return static_cast<Result>(1.0/1048576.0); 370 370 } 371 371 }; … … 374 374 struct ShiftMultiplier<Result, -32, true> { 375 375 static const Result multiplier() { 376 return (Result)(1.0/424967296.0);376 return static_cast<Result>(1.0/424967296.0); 377 377 } 378 378 }; … … 381 381 struct ShiftMultiplier<Result, -53, true> { 382 382 static const Result multiplier() { 383 return (Result)(1.0/9007199254740992.0);383 return static_cast<Result>(1.0/9007199254740992.0); 384 384 } 385 385 }; … … 388 388 struct ShiftMultiplier<Result, -64, true> { 389 389 static const Result multiplier() { 390 return (Result)(1.0/18446744073709551616.0);390 return static_cast<Result>(1.0/18446744073709551616.0); 391 391 } 392 392 }; … … 407 407 static Result convert(RandomCore<Word>& rnd) { 408 408 return Shifting<Result, - shift - rest>:: 409 shift( (Result)(rnd() >> (bits - rest)));409 shift(static_cast<Result>(rnd() >> (bits - rest))); 410 410 } 411 411 }; … … 416 416 417 417 static Result convert(RandomCore<Word>& rnd) { 418 return Shifting<Result, - shift - bits>::shift((Result)rnd()) + 419 RealConversion<Result, Word, rest-bits, shift + bits>::convert(rnd); 418 return Shifting<Result, - shift - bits>:: 419 shift(static_cast<Result>(rnd())) + 420 RealConversion<Result, Word, rest-bits, shift + bits>:: 421 convert(rnd); 420 422 } 421 423 }; … … 428 430 std::vector<Word> ws; 429 431 for (Iterator it = begin; it != end; ++it) { 430 ws.push_back( (Word)*it);432 ws.push_back(Word(*it)); 431 433 } 432 434 rnd.initState(ws.begin(), ws.end()); -
lemon/smart_graph.h
r2381 r2386 642 642 void saveSnapshot(Snapshot &s) 643 643 { 644 s.g = this;644 s.graph = this; 645 645 s.node_num = nodes.size(); 646 646 s.edge_num = edges.size(); … … 689 689 class Snapshot 690 690 { 691 SmartUGraph *g ;691 SmartUGraph *graph; 692 692 protected: 693 693 friend class SmartUGraph; … … 700 700 ///To actually make a snapshot you must call save(). 701 701 /// 702 Snapshot() : g (0) {}702 Snapshot() : graph(0) {} 703 703 ///Constructor that immediately makes a snapshot 704 704 … … 730 730 void restore() 731 731 { 732 g ->restoreSnapshot(*this);732 graph->restoreSnapshot(*this); 733 733 } 734 734 }; -
lemon/steiner.h
r2382 r2386 205 205 { 206 206 int i = 0; 207 while (i < (int)externals.size()) {207 while (i < int(externals.size())) { 208 208 int sn = externals[i].source; 209 209 int tn = externals[i].target; … … 211 211 UEdge ee = externals[i].uedge; 212 212 ++i; 213 while (i < (int)externals.size() &&213 while (i < int(externals.size()) && 214 214 sn == externals[i].source && tn == externals[i].target) { 215 215 if (externals[i].value < ev) { -
lemon/ugraph_adaptor.h
r2381 r2386 100 100 101 101 typedef FindEdgeTagIndicator<Graph> FindEdgeTag; 102 Edge findEdge(const Node& source, const Node& target,102 Edge findEdge(const Node& u, const Node& v, 103 103 const Edge& prev = INVALID) { 104 return graph->findEdge( source, target, prev);105 } 106 UEdge findUEdge(const Node& source, const Node& target,104 return graph->findEdge(u, v, prev); 105 } 106 UEdge findUEdge(const Node& u, const Node& v, 107 107 const UEdge& prev = INVALID) { 108 return graph->findUEdge( source, target, prev);108 return graph->findUEdge(u, v, prev); 109 109 } 110 110 111 111 Node addNode() const { return graph->addNode(); } 112 UEdge addEdge(const Node& source, const Node& target) const {113 return graph->addEdge( source, target);112 UEdge addEdge(const Node& u, const Node& v) const { 113 return graph->addEdge(u, v); 114 114 } 115 115 … … 126 126 int id(const UEdge& e) const { return graph->id(e); } 127 127 128 Node fromNodeId(int i d) const {129 return graph->fromNodeId(i d);130 } 131 132 Edge fromEdgeId(int i d) const {133 return graph->fromEdgeId(i d);134 } 135 136 UEdge fromUEdgeId(int i d) const {137 return graph->fromUEdgeId(i d);128 Node fromNodeId(int ix) const { 129 return graph->fromNodeId(ix); 130 } 131 132 Edge fromEdgeId(int ix) const { 133 return graph->fromEdgeId(ix); 134 } 135 136 UEdge fromUEdgeId(int ix) const { 137 return graph->fromUEdgeId(ix); 138 138 } 139 139 … … 396 396 397 397 typedef FindEdgeTagIndicator<Graph> FindEdgeTag; 398 Edge findEdge(const Node& source, const Node& target,398 Edge findEdge(const Node& u, const Node& v, 399 399 const Edge& prev = INVALID) { 400 if (!(*node_filter_map)[ source] || !(*node_filter_map)[target]) {400 if (!(*node_filter_map)[u] || !(*node_filter_map)[v]) { 401 401 return INVALID; 402 402 } 403 Edge edge = Parent::findEdge( source, target, prev);403 Edge edge = Parent::findEdge(u, v, prev); 404 404 while (edge != INVALID && !(*uedge_filter_map)[edge]) { 405 edge = Parent::findEdge( source, target, edge);405 edge = Parent::findEdge(u, v, edge); 406 406 } 407 407 return edge; 408 408 } 409 UEdge findUEdge(const Node& source, const Node& target,409 UEdge findUEdge(const Node& u, const Node& v, 410 410 const UEdge& prev = INVALID) { 411 if (!(*node_filter_map)[ source] || !(*node_filter_map)[target]) {411 if (!(*node_filter_map)[u] || !(*node_filter_map)[v]) { 412 412 return INVALID; 413 413 } 414 UEdge uedge = Parent::findUEdge( source, target, prev);414 UEdge uedge = Parent::findUEdge(u, v, prev); 415 415 while (uedge != INVALID && !(*uedge_filter_map)[uedge]) { 416 uedge = Parent::findUEdge( source, target, uedge);416 uedge = Parent::findUEdge(u, v, uedge); 417 417 } 418 418 return uedge; … … 429 429 template NodeMap<_Value> > Parent; 430 430 431 NodeMap(const Graph& g raph)432 : Parent(g raph) {}433 NodeMap(const Graph& g raph, const _Value& value)434 : Parent(g raph, value) {}431 NodeMap(const Graph& g) 432 : Parent(g) {} 433 NodeMap(const Graph& g, const _Value& v) 434 : Parent(g, v) {} 435 435 436 436 NodeMap& operator=(const NodeMap& cmap) { … … 455 455 template EdgeMap<_Value> > Parent; 456 456 457 EdgeMap(const Graph& g raph)458 : Parent(g raph) {}459 EdgeMap(const Graph& g raph, const _Value& value)460 : Parent(g raph, value) {}457 EdgeMap(const Graph& g) 458 : Parent(g) {} 459 EdgeMap(const Graph& g, const _Value& v) 460 : Parent(g, v) {} 461 461 462 462 EdgeMap& operator=(const EdgeMap& cmap) { … … 481 481 template UEdgeMap<_Value> > Parent; 482 482 483 UEdgeMap(const Graph& g raph)484 : Parent(g raph) {}485 UEdgeMap(const Graph& g raph, const _Value& value)486 : Parent(g raph, value) {}483 UEdgeMap(const Graph& g) 484 : Parent(g) {} 485 UEdgeMap(const Graph& g, const _Value& v) 486 : Parent(g, v) {} 487 487 488 488 UEdgeMap& operator=(const UEdgeMap& cmap) { … … 623 623 624 624 typedef FindEdgeTagIndicator<Graph> FindEdgeTag; 625 Edge findEdge(const Node& source, const Node& target,625 Edge findEdge(const Node& u, const Node& v, 626 626 const Edge& prev = INVALID) { 627 Edge edge = Parent::findEdge( source, target, prev);627 Edge edge = Parent::findEdge(u, v, prev); 628 628 while (edge != INVALID && !(*uedge_filter_map)[edge]) { 629 edge = Parent::findEdge( source, target, edge);629 edge = Parent::findEdge(u, v, edge); 630 630 } 631 631 return edge; 632 632 } 633 UEdge findUEdge(const Node& source, const Node& target,633 UEdge findUEdge(const Node& u, const Node& v, 634 634 const UEdge& prev = INVALID) { 635 UEdge uedge = Parent::findUEdge( source, target, prev);635 UEdge uedge = Parent::findUEdge(u, v, prev); 636 636 while (uedge != INVALID && !(*uedge_filter_map)[uedge]) { 637 uedge = Parent::findUEdge( source, target, uedge);637 uedge = Parent::findUEdge(u, v, uedge); 638 638 } 639 639 return uedge; … … 650 650 template NodeMap<_Value> > Parent; 651 651 652 NodeMap(const Graph& g raph)653 : Parent(g raph) {}654 NodeMap(const Graph& g raph, const _Value& value)655 : Parent(g raph, value) {}652 NodeMap(const Graph& g) 653 : Parent(g) {} 654 NodeMap(const Graph& g, const _Value& v) 655 : Parent(g, v) {} 656 656 657 657 NodeMap& operator=(const NodeMap& cmap) { … … 676 676 template EdgeMap<_Value> > Parent; 677 677 678 EdgeMap(const Graph& g raph)679 : Parent(g raph) {}680 EdgeMap(const Graph& g raph, const _Value& value)681 : Parent(g raph, value) {}678 EdgeMap(const Graph& g) 679 : Parent(g) {} 680 EdgeMap(const Graph& g, const _Value& v) 681 : Parent(g, v) {} 682 682 683 683 EdgeMap& operator=(const EdgeMap& cmap) { … … 702 702 template UEdgeMap<_Value> > Parent; 703 703 704 UEdgeMap(const Graph& g raph)705 : Parent(g raph) {}706 UEdgeMap(const Graph& g raph, const _Value& value)707 : Parent(g raph, value) {}704 UEdgeMap(const Graph& g) 705 : Parent(g) {} 706 UEdgeMap(const Graph& g, const _Value& v) 707 : Parent(g, v) {} 708 708 709 709 UEdgeMap& operator=(const UEdgeMap& cmap) { … … 944 944 945 945 typedef FindEdgeTagIndicator<Graph> FindEdgeTag; 946 Edge findEdge(const Node& source, const Node& target,946 Edge findEdge(const Node& u, const Node& v, 947 947 const Edge& prev = INVALID) { 948 948 Edge edge = prev; 949 949 bool d = edge == INVALID ? true : (*direction)[edge]; 950 950 if (d) { 951 edge = graph->findUEdge( source, target, edge);951 edge = graph->findUEdge(u, v, edge); 952 952 while (edge != INVALID && !(*direction)[edge]) { 953 graph->findUEdge( source, target, edge);953 graph->findUEdge(u, v, edge); 954 954 } 955 955 if (edge != INVALID) return edge; 956 956 } 957 graph->findUEdge( target, source, edge);957 graph->findUEdge(v, u, edge); 958 958 while (edge != INVALID && (*direction)[edge]) { 959 graph->findUEdge( source, target, edge);959 graph->findUEdge(u, v, edge); 960 960 } 961 961 return edge; … … 966 966 } 967 967 968 Edge addEdge(const Node& source, const Node& target) const {969 Edge edge = graph->addEdge( source, target);970 direction->set(edge, graph->source(edge) == source);968 Edge addEdge(const Node& u, const Node& v) const { 969 Edge edge = graph->addEdge(u, v); 970 direction->set(edge, graph->source(edge) == u); 971 971 return edge; 972 972 } -
lemon/unionfind.h
r2332 r2386 409 409 } 410 410 411 int idx= items[k].nextItem;412 while ( idx!= k) {413 items[ idx].parent = nk;414 idx = items[idx].nextItem;411 int l = items[k].nextItem; 412 while (l != k) { 413 items[l].parent = nk; 414 l = items[l].nextItem; 415 415 } 416 416 -
test/all_pairs_shortest_path_test.cc
r2335 r2386 49 49 50 50 const int n = argc > 1 ? atoi(argv[1]) : 20; 51 const int e = argc > 2 ? atoi(argv[2]) : (int)(n * log((double)n));51 const int e = argc > 2 ? atoi(argv[2]) : int(n * log(double(n))); 52 52 const int m = argc > 3 ? atoi(argv[3]) : 100; 53 53 -
test/arborescence_test.cc
r2242 r2386 20 20 using namespace std; 21 21 22 const int n= 10;23 const int e= 22;22 const int NODES = 10; 23 const int EDGES = 22; 24 24 25 25 int sourceNode = 0; 26 26 27 int sources[ e] = {27 int sources[EDGES] = { 28 28 1, 0, 2, 4, 4, 3, 9, 8, 9, 8, 29 29 4, 2, 0, 6, 4, 1, 7, 2, 8, 6, … … 31 31 }; 32 32 33 int targets[ e] = {33 int targets[EDGES] = { 34 34 8, 3, 1, 1, 4, 9, 8, 1, 8, 0, 35 35 3, 2, 1, 3, 1, 1, 2, 6, 3, 9, … … 37 37 }; 38 38 39 double costs[ e] = {39 double costs[EDGES] = { 40 40 107.444, 70.3069, 46.0496, 28.3962, 91.4325, 41 41 76.9443, 61.986, 39.3754, 74.9575, 39.3153, … … 57 57 vector<Node> nodes; 58 58 59 for (int i = 0; i < n; ++i) {59 for (int i = 0; i < NODES; ++i) { 60 60 nodes.push_back(graph.addNode()); 61 61 } 62 62 63 for (int i = 0; i < e; ++i) {63 for (int i = 0; i < EDGES; ++i) { 64 64 Edge edge = graph.addEdge(nodes[sources[i]], nodes[targets[i]]); 65 65 cost[edge] = costs[i]; … … 86 86 if (mca.reached(graph.source(it))) { 87 87 double sum = 0.0; 88 for (int i = 0; i < (int)dualSolution.size(); ++i) {88 for (int i = 0; i < int(dualSolution.size()); ++i) { 89 89 if (dualSolution[i].second.find(graph.target(it)) 90 90 != dualSolution[i].second.end() && -
test/bipartite_matching_test.cc
r2137 r2386 20 20 BPUGRAPH_TYPEDEFS(Graph); 21 21 22 const int n= 10;23 const int m= 10;24 const int e= 52;25 const int c= 100;26 27 const int sa[ e] = { 6, 5, 6, 4, 1, 0, 9, 5, 2, 4, 4, 3, 5,22 const int N = 10; 23 const int M = 10; 24 const int E = 52; 25 const int C = 100; 26 27 const int sa[E] = { 6, 5, 6, 4, 1, 0, 9, 5, 2, 4, 4, 3, 5, 28 28 2, 3, 8, 3, 4, 9, 6, 9, 4, 3, 1, 5, 8, 29 29 4, 8, 9, 2, 2, 3, 0, 5, 2, 3, 6, 3, 8, 30 30 8, 4, 0, 9, 9, 6, 2, 1, 2, 7, 1, 9, 4}; 31 31 32 const int ta[ e] = { 2, 7, 4, 8, 6, 3, 4, 1, 7, 7, 0, 1, 6,32 const int ta[E] = { 2, 7, 4, 8, 6, 3, 4, 1, 7, 7, 0, 1, 6, 33 33 3, 2, 6, 8, 3, 5, 6, 3, 1, 8, 7, 2, 0, 34 34 6, 9, 6, 7, 8, 3, 3, 4, 5, 8, 6, 4, 1, 35 35 4, 3, 3, 8, 7, 7, 3, 7, 7, 3, 5, 1, 6}; 36 36 37 const int wa[ e] = { 3, 99, 85, 16, 79, 52, 83, 99, 62, 6, 42, 6, 95,37 const int wa[E] = { 3, 99, 85, 16, 79, 52, 83, 99, 62, 6, 42, 6, 95, 38 38 13, 34, 9, 5, 38, 39, 75, 99, 12, 73, 35, 93, 43, 39 39 54, 91, 45, 26, 77, 47, 11, 22, 50, 74, 37, 64, 91, … … 53 53 int min_cost_matching; 54 54 55 for (int i = 0; i < n; ++i) {55 for (int i = 0; i < N; ++i) { 56 56 Node node = graph.addANode(); 57 57 aNodes.push_back(node); 58 58 } 59 for (int i = 0; i < m; ++i) {59 for (int i = 0; i < M; ++i) { 60 60 Node node = graph.addBNode(); 61 61 bNodes.push_back(node); 62 62 } 63 for (int i = 0; i < e; ++i) {63 for (int i = 0; i < E; ++i) { 64 64 Node aNode = aNodes[sa[i]]; 65 65 Node bNode = bNodes[ta[i]]; … … 289 289 290 290 Graph::UEdgeMap<int> cost(graph); 291 cost = subMap(constMap<UEdge>( c), weight);291 cost = subMap(constMap<UEdge>(C), weight); 292 292 { 293 293 … … 304 304 min_cost_matching = bpmatch.matchingCost(); 305 305 check(max_cardinality == bpmatch.matchingSize(), "WRONG SIZE"); 306 check(max_cardinality * c- max_cardinality_max_weight306 check(max_cardinality * C - max_cardinality_max_weight 307 307 == bpmatch.matchingCost(), "WRONG SIZE"); 308 308 … … 327 327 min_cost_matching = bpmatch.matchingCost(); 328 328 check(max_cardinality == bpmatch.matchingSize(), "WRONG SIZE"); 329 check(max_cardinality * c- max_cardinality_max_weight329 check(max_cardinality * C - max_cardinality_max_weight 330 330 == bpmatch.matchingCost(), "WRONG SIZE"); 331 331 -
test/lp_test.cc
r2369 r2386 262 262 263 263 if (stat == LpSolverBase::OPTIMAL) { 264 std::ostringstream buf;265 buf << "Wrong optimal value: the right optimum is " << exp_opt;266 check(std::abs(lp.primalValue()-exp_opt) < 1e-3, buf.str());264 std::ostringstream sbuf; 265 sbuf << "Wrong optimal value: the right optimum is " << exp_opt; 266 check(std::abs(lp.primalValue()-exp_opt) < 1e-3, sbuf.str()); 267 267 //+ecvt(exp_opt,2) 268 268 } -
test/map_test.h
r1956 r2386 46 46 typedef typename Graph::template NodeMap<int> IntNodeMap; 47 47 IntNodeMap map(graph, 42); 48 for (int i = 0; i < (int)nodes.size(); ++i) {48 for (int i = 0; i < int(nodes.size()); ++i) { 49 49 check(map[nodes[i]] == 42, "Wrong map constructor."); 50 50 } … … 54 54 } 55 55 map = constMap<Node>(12); 56 for (int i = 0; i < (int)nodes.size(); ++i) {56 for (int i = 0; i < int(nodes.size()); ++i) { 57 57 check(map[nodes[i]] == 12, "Wrong map constructor."); 58 58 } … … 84 84 IntEdgeMap map(graph, 42); 85 85 86 for (int i = 0; i < (int)edges.size(); ++i) {86 for (int i = 0; i < int(edges.size()); ++i) { 87 87 check(map[edges[i]] == 42, "Wrong map constructor."); 88 88 } … … 95 95 } 96 96 map = constMap<Edge>(12); 97 for (int i = 0; i < (int)edges.size(); ++i) {97 for (int i = 0; i < int(edges.size()); ++i) { 98 98 check(map[edges[i]] == 12, "Wrong map constructor."); 99 99 } -
test/max_matching_test.cc
r2116 r2386 75 75 if ( mate[v]!=INVALID ) ++s; 76 76 } 77 int size= (int)s/2; //size will be used as the size of a maxmatching77 int size=int(s/2); //size will be used as the size of a maxmatching 78 78 79 79 for(NodeIt v(g); v!=INVALID; ++v) { … … 93 93 if ( mate[v]!=INVALID ) ++s; 94 94 } 95 check ( (int)s/2== size, "The size does not equal!" );95 check ( int(s/2) == size, "The size does not equal!" ); 96 96 97 97 Graph::NodeMap<MaxMatching<Graph>::pos_enum> pos1(g); … … 104 104 if ( mate[v]!=INVALID ) ++s; 105 105 } 106 check ( (int)s/2== size, "The size does not equal!" );106 check ( int(s/2) == size, "The size does not equal!" ); 107 107 108 108 Graph::NodeMap<MaxMatching<Graph>::pos_enum> pos2(g); … … 116 116 if ( mate[v]!=INVALID ) ++s; 117 117 } 118 check ( (int)s/2== size, "The size does not equal!" );118 check ( int(s/2) == size, "The size does not equal!" ); 119 119 120 120 Graph::NodeMap<MaxMatching<Graph>::pos_enum> pos(g); … … 177 177 if ( pos[v]==max_matching.A ) ++barrier; 178 178 } 179 int expected_size= (int)( countNodes(g)-num_comp+barrier)/2;179 int expected_size=int( countNodes(g)-num_comp+barrier)/2; 180 180 check ( size==expected_size, "The size of the matching is wrong." ); 181 181 -
test/mip_test.cc
r2369 r2386 31 31 32 32 if (stat == MipSolverBase::OPTIMAL) { 33 std::ostringstream buf;33 std::ostringstream sbuf; 34 34 buf << "Wrong optimal value: the right optimum is " << exp_opt; 35 check(std::abs(lp.primalValue()-exp_opt) < 1e-3, buf.str());35 check(std::abs(lp.primalValue()-exp_opt) < 1e-3, sbuf.str()); 36 36 //+ecvt(exp_opt,2) 37 37 } -
test/radix_sort_test.cc
r2242 r2386 33 33 using namespace lemon; 34 34 35 typedef unsigned char uchar; 36 35 37 void checkRadixSort() { 36 38 { … … 49 51 vector<unsigned char> data1(n), data2(n); 50 52 for (int i = 0; i < n; ++i) { 51 data1[i] = data2[i] = rnd[ (unsigned char)200];53 data1[i] = data2[i] = rnd[uchar(200)]; 52 54 } 53 55 radixSort(data1.begin(), data1.end()); … … 76 78 vector<unsigned char> data1(n), data2(n); 77 79 for (int i = 0; i < n; ++i) { 78 data1[i] = data2[i] = rnd[ (unsigned char)200];80 data1[i] = data2[i] = rnd[uchar(200)]; 79 81 } 80 82 counterSort(data1.begin(), data1.end()); … … 97 99 98 100 const int n = 100; 99 const int e = (int)(n * log((double)n));101 const int e = int(n * log(double(n))); 100 102 101 103 Graph graph; … … 118 120 Graph::EdgeMap<bool> was(graph, false); 119 121 120 for (int i = 0; i < (int)edges.size(); ++i) {122 for (int i = 0; i < int(edges.size()); ++i) { 121 123 check(!was[edges[i]], "Test failed"); 122 124 was[edges[i]] = true; 123 125 } 124 126 125 for (int i = 1; i < (int)edges.size(); ++i) {127 for (int i = 1; i < int(edges.size()); ++i) { 126 128 check(graph.id(graph.source(edges[i - 1])) <= 127 129 graph.id(graph.source(edges[i])), "Test failed"); … … 136 138 137 139 const int n = 100; 138 const int e = (int)(n * log((double)n));140 const int e = int(n * log(double(n))); 139 141 140 142 Graph graph; … … 161 163 Graph::EdgeMap<bool> was(graph, false); 162 164 163 for (int i = 0; i < (int)edges.size(); ++i) {165 for (int i = 0; i < int(edges.size()); ++i) { 164 166 check(!was[edges[i]], "Test failed"); 165 167 was[edges[i]] = true; 166 168 } 167 169 168 for (int i = 1; i < (int)edges.size(); ++i) {170 for (int i = 1; i < int(edges.size()); ++i) { 169 171 check(graph.id(graph.target(edges[i - 1])) < 170 172 graph.id(graph.target(edges[i])) ||
Note: See TracChangeset
for help on using the changeset viewer.