diff -r 096d83158d41 -r 81b47fc5c444 lemon/bellman_ford.h --- a/lemon/bellman_ford.h Fri Mar 02 17:56:22 2007 +0000 +++ b/lemon/bellman_ford.h Fri Mar 02 18:04:28 2007 +0000 @@ -436,15 +436,15 @@ /// \return %True when the algorithm have not found more shorter /// paths. bool processNextRound() { - for (int i = 0; i < (int)_process.size(); ++i) { + for (int i = 0; i < int(_process.size()); ++i) { _mask->set(_process[i], false); } std::vector nextProcess; std::vector values(_process.size()); - for (int i = 0; i < (int)_process.size(); ++i) { + for (int i = 0; i < int(_process.size()); ++i) { values[i] = (*_dist)[_process[i]]; } - for (int i = 0; i < (int)_process.size(); ++i) { + for (int i = 0; i < int(_process.size()); ++i) { for (OutEdgeIt it(*graph, _process[i]); it != INVALID; ++it) { Node target = graph->target(it); Value relaxed = OperationTraits::plus(values[i], (*length)[it]); @@ -472,11 +472,11 @@ /// called just weak round. /// \return %True when the algorithm have not found more shorter paths. bool processNextWeakRound() { - for (int i = 0; i < (int)_process.size(); ++i) { + for (int i = 0; i < int(_process.size()); ++i) { _mask->set(_process[i], false); } std::vector nextProcess; - for (int i = 0; i < (int)_process.size(); ++i) { + for (int i = 0; i < int(_process.size()); ++i) { for (OutEdgeIt it(*graph, _process[i]); it != INVALID; ++it) { Node target = graph->target(it); Value relaxed = @@ -645,13 +645,13 @@ } bool operator==(const ActiveIt& it) const { - return (Node)(*this) == (Node)it; + return static_cast(*this) == static_cast(it); } bool operator!=(const ActiveIt& it) const { - return (Node)(*this) != (Node)it; + return static_cast(*this) != static_cast(it); } bool operator<(const ActiveIt& it) const { - return (Node)(*this) < (Node)it; + return static_cast(*this) < static_cast(it); } private: @@ -865,8 +865,9 @@ BellmanFordWizardBase(const _Graph& graph, const _LengthMap& length, Node source = INVALID) : - _graph((void *)&graph), _length((void *)&length), _pred(0), - _dist(0), _source(source) {} + _graph(reinterpret_cast(const_cast<_Graph*>(&graph))), + _length(reinterpret_cast(const_cast<_LengthMap*>(&length))), + _pred(0), _dist(0), _source(source) {} }; @@ -923,8 +924,8 @@ /// Constructor that requires parameters. /// These parameters will be the default values for the traits class. BellmanFordWizard(const Graph& graph, const LengthMap& length, - Node source = INVALID) - : _Traits(graph, length, source) {} + Node src = INVALID) + : _Traits(graph, length, src) {} /// \brief Copy constructor BellmanFordWizard(const _Traits &b) : _Traits(b) {} @@ -938,9 +939,10 @@ void run() { if(Base::_source == INVALID) throw UninitializedParameter(); BellmanFord - bf(*(Graph*)Base::_graph, *(LengthMap*)Base::_length); - if (Base::_pred) bf.predMap(*(PredMap*)Base::_pred); - if (Base::_dist) bf.distMap(*(DistMap*)Base::_dist); + bf(*reinterpret_cast(Base::_graph), + *reinterpret_cast(Base::_length)); + if (Base::_pred) bf.predMap(*reinterpret_cast(Base::_pred)); + if (Base::_dist) bf.distMap(*reinterpret_cast(Base::_dist)); bf.run(Base::_source); } @@ -948,8 +950,8 @@ /// /// Runs BellmanFord algorithm from the given node. /// \param source is the given source. - void run(Node source) { - Base::_source = source; + void run(Node src) { + Base::_source = src; run(); } @@ -969,7 +971,7 @@ template BellmanFordWizard > predMap(const T &t) { - Base::_pred=(void *)&t; + Base::_pred=reinterpret_cast(const_cast(&t)); return BellmanFordWizard >(*this); } @@ -988,7 +990,7 @@ /// template BellmanFordWizard > distMap(const T &t) { - Base::_dist=(void *)&t; + Base::_dist=reinterpret_cast(const_cast(&t)); return BellmanFordWizard >(*this); } @@ -1013,8 +1015,8 @@ /// /// Sets the source node, from which the BellmanFord algorithm runs. /// \param source is the source node. - BellmanFordWizard<_Traits>& source(Node source) { - Base::_source = source; + BellmanFordWizard<_Traits>& source(Node src) { + Base::_source = src; return *this; }