]> OCCT Git - occt-copy.git/commitdiff
Fix problem with StlIterator on old compiler
authorbugmaster <bugmaster@opencascade.com>
Wed, 11 Nov 2015 13:13:30 +0000 (16:13 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 11 Nov 2015 13:13:30 +0000 (16:13 +0300)
src/math/math_PSOParticlesPool.cxx

index 80a7dd72f2a94f1df3f55aad44832e14c324f4c4..81c7f362e5a38aa868c4e5e73e6ab02441d457f5 100644 (file)
@@ -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