From fc2ebae00efacf4ce6e47f5627073641fb26c142 Mon Sep 17 00:00:00 2001 From: bugmaster Date: Wed, 11 Nov 2015 16:13:30 +0300 Subject: [PATCH] Fix problem with StlIterator on old compiler --- src/math/math_PSOParticlesPool.cxx | 34 +++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/math/math_PSOParticlesPool.cxx b/src/math/math_PSOParticlesPool.cxx index 80a7dd72f2..81c7f362e5 100644 --- a/src/math/math_PSOParticlesPool.cxx +++ b/src/math/math_PSOParticlesPool.cxx @@ -66,7 +66,21 @@ PSO_Particle* math_PSOParticlesPool::GetParticle(const Standard_Integer theIdx) //======================================================================= PSO_Particle* math_PSOParticlesPool::GetBestParticle() { - return &*std::min_element(myParticlesPool.begin(), myParticlesPool.end()); + //return &*std::min_element(myParticlesPool.begin(), myParticlesPool.end()); + Standard_Real aMinValue = myParticlesPool.First().Distance; + Standard_Integer aMinIdx = myParticlesPool.Lower(); + for(Standard_Integer i = myParticlesPool.Lower(); + i <= myParticlesPool.Upper(); + i++) + { + if (myParticlesPool(i).Distance < aMinValue) + { + aMinIdx = i; + aMinValue = myParticlesPool(i).Distance; + } + } + + return &myParticlesPool(aMinIdx); } //======================================================================= @@ -75,5 +89,19 @@ PSO_Particle* math_PSOParticlesPool::GetBestParticle() //======================================================================= PSO_Particle* math_PSOParticlesPool::GetWorstParticle() { - return &*std::max_element(myParticlesPool.begin(), myParticlesPool.end()); -} + //return &*std::max_element(myParticlesPool.begin(), myParticlesPool.end()); + Standard_Real aMaxValue = myParticlesPool.First().Distance; + Standard_Integer aMaxIdx = myParticlesPool.Lower(); + for(Standard_Integer i = myParticlesPool.Lower(); + i <= myParticlesPool.Upper(); + i++) + { + if (myParticlesPool(i).Distance > aMaxValue) + { + aMaxIdx = i; + aMaxValue = myParticlesPool(i).Distance; + } + } + + return &myParticlesPool(aMaxIdx); +} \ No newline at end of file -- 2.39.5