From 2dc24fa4d844ed46e91e7c66cf372bc28ba39500 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Tue, 19 Feb 2013 09:18:00 +0100 Subject: [PATCH] Substituted for-loop deploying std::transform and lambda function. --- .../PiecewiseLinearInterpolation.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp index 9c2284de6c9..4099dda882f 100644 --- a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp +++ b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp @@ -45,9 +45,10 @@ PiecewiseLinearInterpolation::PiecewiseLinearInterpolation(const std::vector<dou _values_at_supp_pnts); } - values_at_interpol_pnts.clear(); - for (std::size_t k(0); k < points_to_interpolate.size(); k++) - values_at_interpol_pnts.push_back(this->getValue(points_to_interpolate[k])); + values_at_interpol_pnts.resize(points_to_interpolate.size()); + std::transform(points_to_interpolate.begin(), points_to_interpolate.end(), + values_at_interpol_pnts.begin(), + [&](double const& p) { return this->getValue(p); } ); } PiecewiseLinearInterpolation::~PiecewiseLinearInterpolation() -- GitLab