From 1e6af932de79efcc3e5be0ea503e02b4f111aee4 Mon Sep 17 00:00:00 2001 From: Steven Hahn <hahnse@ornl.gov> Date: Fri, 15 Jan 2016 16:10:08 -0500 Subject: [PATCH] Refs #14988. Ran modernize-loop-convert on Algorithms and CurveFitting --- .../Algorithms/src/AbsorptionCorrection.cpp | 5 +- Framework/Algorithms/src/AddLogDerivative.cpp | 4 +- Framework/Algorithms/src/AlignDetectors.cpp | 12 ++--- Framework/Algorithms/src/ChangeTimeZero.cpp | 8 +-- Framework/Algorithms/src/ChopData.cpp | 4 +- .../src/ClearInstrumentParameters.cpp | 11 ++-- .../Algorithms/src/CompareWorkspaces.cpp | 3 +- .../Algorithms/src/ConvertEmptyToTof.cpp | 27 +++++----- Framework/Algorithms/src/CopyLogs.cpp | 14 +++--- .../Algorithms/src/CorelliCrossCorrelate.cpp | 4 +- .../Algorithms/src/CreateCalFileByNames.cpp | 12 ++--- .../Algorithms/src/CreateDummyCalFile.cpp | 6 +-- .../src/CreateGroupingWorkspace.cpp | 6 +-- .../Algorithms/src/CreateLogPropertyTable.cpp | 50 ++++++++----------- .../src/CreateLogTimeCorrection.cpp | 6 +-- .../Algorithms/src/CreatePSDBleedMask.cpp | 4 +- .../Algorithms/src/CreateSampleWorkspace.cpp | 5 +- .../Algorithms/src/DetectorDiagnostic.cpp | 10 ++-- .../Algorithms/src/DiffractionFocussing2.cpp | 16 +++--- Framework/Algorithms/src/FilterEvents.cpp | 14 ++---- Framework/Algorithms/src/FitPeak.cpp | 22 ++++---- .../Algorithms/src/FixGSASInstrumentFile.cpp | 3 +- .../Algorithms/src/GenerateEventsFilter.cpp | 9 ++-- Framework/Algorithms/src/GeneratePeaks.cpp | 12 ++--- Framework/Algorithms/src/GetAllEi.cpp | 16 +++--- .../src/GetDetOffsetsMultiPeaks.cpp | 4 +- .../src/GetTimeSeriesLogInformation.cpp | 13 +++-- Framework/Algorithms/src/GroupWorkspaces.cpp | 4 +- .../Algorithms/src/IntegrateByComponent.cpp | 23 ++++----- Framework/Algorithms/src/MaskBins.cpp | 7 ++- Framework/Algorithms/src/MaskDetectorsIf.cpp | 4 +- Framework/Algorithms/src/MaxEnt.cpp | 8 +-- .../Algorithms/src/MedianDetectorTest.cpp | 10 ++-- Framework/Algorithms/src/MergeRuns.cpp | 13 +++-- Framework/Algorithms/src/ModeratorTzero.cpp | 32 ++++++------ .../Algorithms/src/MonteCarloAbsorption.cpp | 13 +++-- .../Algorithms/src/MuonGroupDetectors.cpp | 8 +-- .../Algorithms/src/NormaliseByDetector.cpp | 4 +- .../src/PDDetermineCharacterizations.cpp | 29 +++++------ .../Algorithms/src/PerformIndexOperations.cpp | 8 +-- .../src/PlotAsymmetryByLogValue.cpp | 46 ++++++++--------- .../src/PointByPointVCorrection.cpp | 6 +-- .../Algorithms/src/PolarizationCorrection.cpp | 9 ++-- Framework/Algorithms/src/Q1DWeighted.cpp | 4 +- Framework/Algorithms/src/Qxy.cpp | 4 +- .../Algorithms/src/ReadGroupsFromFile.cpp | 4 +- .../Algorithms/src/RecordPythonScript.cpp | 6 +-- .../src/ReflectometryReductionOne.cpp | 4 +- .../src/ReflectometryReductionOneAuto.cpp | 8 +-- Framework/Algorithms/src/RemoveBackground.cpp | 8 +-- Framework/Algorithms/src/RemoveLowResTOF.cpp | 4 +- .../Algorithms/src/RemovePromptPulse.cpp | 12 ++--- Framework/Algorithms/src/ResetNegatives.cpp | 12 ++--- .../Algorithms/src/SetInstrumentParameter.cpp | 8 +-- Framework/Algorithms/src/SmoothNeighbours.cpp | 18 +++---- .../Algorithms/src/SofQWNormalisedPolygon.cpp | 4 +- Framework/Algorithms/src/SpatialGrouping.cpp | 30 +++++------ .../src/SpecularReflectionAlgorithm.cpp | 6 +-- .../src/SpecularReflectionPositionCorrect.cpp | 4 +- Framework/Algorithms/src/Stitch1D.cpp | 16 +++--- Framework/Algorithms/src/Stitch1DMany.cpp | 33 ++++++------ .../Algorithms/src/SumEventsByLogValue.cpp | 34 ++++++------- Framework/Algorithms/src/SumSpectra.cpp | 6 +-- Framework/Algorithms/src/UnwrapMonitor.cpp | 6 +-- .../Algorithms/src/UpdateScriptRepository.cpp | 4 +- .../src/Algorithms/CalculateChiSquared.cpp | 16 +++--- .../src/Algorithms/CalculateMSVesuvio.cpp | 18 +++---- .../src/Algorithms/ConvertToYSpace.cpp | 4 +- Framework/CurveFitting/src/Algorithms/Fit.cpp | 14 +++--- .../src/Algorithms/FitPowderDiffPeaks.cpp | 40 ++++++--------- .../CurveFitting/src/Algorithms/LeBailFit.cpp | 37 ++++++-------- .../src/Algorithms/LeBailFunction.cpp | 15 +++--- .../src/Algorithms/PlotPeakByLogValue.cpp | 23 ++++----- .../RefinePowderInstrumentParameters.cpp | 38 +++++++------- .../RefinePowderInstrumentParameters3.cpp | 13 ++--- .../src/Algorithms/SplineBackground.cpp | 4 +- .../src/Functions/ChebfunBase.cpp | 12 ++--- .../Functions/ComptonScatteringCountRate.cpp | 4 +- .../src/Functions/Convolution.cpp | 3 +- .../CurveFitting/src/Functions/DiffSphere.cpp | 6 +-- .../src/Functions/PawleyFunction.cpp | 4 +- .../src/Functions/ProcessBackground.cpp | 10 ++-- .../src/Functions/TabulatedFunction.cpp | 6 +-- Framework/CurveFitting/src/GSLVector.cpp | 4 +- .../CurveFitting/src/IFittingAlgorithm.cpp | 8 +-- .../CurveFitting/src/MultiDomainCreator.cpp | 6 +-- Framework/CurveFitting/src/SeqDomain.cpp | 4 +- 87 files changed, 491 insertions(+), 557 deletions(-) diff --git a/Framework/Algorithms/src/AbsorptionCorrection.cpp b/Framework/Algorithms/src/AbsorptionCorrection.cpp index 4a3a74820a6..ae46c66372f 100644 --- a/Framework/Algorithms/src/AbsorptionCorrection.cpp +++ b/Framework/Algorithms/src/AbsorptionCorrection.cpp @@ -135,9 +135,8 @@ void AbsorptionCorrection::exec() { // If sample not at origin, shift cached positions. const V3D samplePos = m_inputWS->getInstrument()->getSample()->getPos(); if (samplePos != V3D(0, 0, 0)) { - for (auto it = m_elementPositions.begin(); it != m_elementPositions.end(); - ++it) { - (*it) += samplePos; + for (auto &m_elementPosition : m_elementPositions) { + m_elementPosition += samplePos; } } diff --git a/Framework/Algorithms/src/AddLogDerivative.cpp b/Framework/Algorithms/src/AddLogDerivative.cpp index ef618c8dc7b..fa43de6d7e0 100644 --- a/Framework/Algorithms/src/AddLogDerivative.cpp +++ b/Framework/Algorithms/src/AddLogDerivative.cpp @@ -103,8 +103,8 @@ Mantid::Kernel::TimeSeriesProperty<double> *AddLogDerivative::makeDerivative( DateAndTime start = input->nthTime(0); std::vector<DateAndTime> timeFull; timeFull.reserve(times.size()); - for (size_t i = 0; i < times.size(); i++) - timeFull.push_back(start + times[i]); + for (double time : times) + timeFull.push_back(start + time); // Create the TSP out of it auto out = new TimeSeriesProperty<double>(name); diff --git a/Framework/Algorithms/src/AlignDetectors.cpp b/Framework/Algorithms/src/AlignDetectors.cpp index f1a04f8758f..44b55390c3c 100644 --- a/Framework/Algorithms/src/AlignDetectors.cpp +++ b/Framework/Algorithms/src/AlignDetectors.cpp @@ -91,10 +91,10 @@ public: double difc = 0.; double difa = 0.; double tzero = 0.; - for (auto row = rows.begin(); row != rows.end(); ++row) { - difc += m_difcCol->toDouble(*row); - difa += m_difaCol->toDouble(*row); - tzero += m_tzeroCol->toDouble(*row); + for (value_type row : rows) { + difc += m_difcCol->toDouble(row); + difa += m_difaCol->toDouble(row); + tzero += m_tzeroCol->toDouble(row); } if (rows.size() > 1) { double norm = 1. / static_cast<double>(rows.size()); @@ -125,8 +125,8 @@ private: std::set<size_t> getRow(const std::set<detid_t> &detIds) { std::set<size_t> rows; - for (auto detId = detIds.begin(); detId != detIds.end(); ++detId) { - auto rowIter = m_detidToRow.find(*detId); + for (value_type detId : detIds) { + auto rowIter = m_detidToRow.find(detId); if (rowIter != m_detidToRow.end()) { // skip if not found rows.insert(rowIter->second); } diff --git a/Framework/Algorithms/src/ChangeTimeZero.cpp b/Framework/Algorithms/src/ChangeTimeZero.cpp index 78a8651b507..aeb38e230b9 100644 --- a/Framework/Algorithms/src/ChangeTimeZero.cpp +++ b/Framework/Algorithms/src/ChangeTimeZero.cpp @@ -171,12 +171,12 @@ void ChangeTimeZero::shiftTimeOfLogs(Mantid::API::MatrixWorkspace_sptr ws, // 2. string properties: here we change the values if they are ISO8601 times auto logs = ws->mutableRun().getLogData(); Progress prog(this, startProgress, stopProgress, logs.size()); - for (auto iter = logs.begin(); iter != logs.end(); ++iter) { - if (isTimeSeries(*iter)) { - shiftTimeInLogForTimeSeries(ws, *iter, timeShift); + for (auto &log : logs) { + if (isTimeSeries(log)) { + shiftTimeInLogForTimeSeries(ws, log, timeShift); } else if (auto stringProperty = - dynamic_cast<PropertyWithValue<std::string> *>(*iter)) { + dynamic_cast<PropertyWithValue<std::string> *>(log)) { shiftTimeOfLogForStringProperty(stringProperty, timeShift); } diff --git a/Framework/Algorithms/src/ChopData.cpp b/Framework/Algorithms/src/ChopData.cpp index e071d2db176..258a33f2448 100644 --- a/Framework/Algorithms/src/ChopData.cpp +++ b/Framework/Algorithms/src/ChopData.cpp @@ -163,8 +163,8 @@ void ChopData::exec() { // Create workspace group that holds output workspaces WorkspaceGroup_sptr wsgroup = WorkspaceGroup_sptr(new WorkspaceGroup()); - for (auto it = workspaces.begin(); it != workspaces.end(); ++it) { - wsgroup->addWorkspace(*it); + for (auto &workspace : workspaces) { + wsgroup->addWorkspace(workspace); } // set the output property setProperty("OutputWorkspace", wsgroup); diff --git a/Framework/Algorithms/src/ClearInstrumentParameters.cpp b/Framework/Algorithms/src/ClearInstrumentParameters.cpp index 3d906b174ae..e82b0d117d4 100644 --- a/Framework/Algorithms/src/ClearInstrumentParameters.cpp +++ b/Framework/Algorithms/src/ClearInstrumentParameters.cpp @@ -74,15 +74,15 @@ void ClearInstrumentParameters::exec() { ParameterMap::pmap paramsToKeep; // Go through all the parameters, keep a hold of any we don't want to clear. - for (auto paramIt = params->begin(); paramIt != params->end(); ++paramIt) { + for (auto ¶mIt : *params) { // Are we keeping the location parameters? - const std::string pName = (*paramIt).second->name(); + const std::string pName = paramIt.second->name(); if (!clearLocationParams && (pName == "x" || pName == "y" || pName == "z" || pName == "r-position" || pName == "t-position" || pName == "p-position" || pName == "rotx" || pName == "roty" || pName == "rotz")) { - paramsToKeep.insert(*paramIt); + paramsToKeep.insert(paramIt); } } @@ -90,9 +90,8 @@ void ClearInstrumentParameters::exec() { params->clear(); // Add any parameters we're keeping back into the parameter map. - for (auto paramIt = paramsToKeep.begin(); paramIt != paramsToKeep.end(); - ++paramIt) { - params->add((*paramIt).first, (*paramIt).second); + for (auto ¶mIt : paramsToKeep) { + params->add(paramIt.first, paramIt.second); } } diff --git a/Framework/Algorithms/src/CompareWorkspaces.cpp b/Framework/Algorithms/src/CompareWorkspaces.cpp index 1d3cfad7606..04fcd9ea055 100644 --- a/Framework/Algorithms/src/CompareWorkspaces.cpp +++ b/Framework/Algorithms/src/CompareWorkspaces.cpp @@ -216,8 +216,7 @@ void CompareWorkspaces::processGroups( const std::vector<Property *> &allProps = this->getProperties(); std::vector<Property *> nonDefaultProps; nonDefaultProps.reserve(allProps.size()); - for (size_t i = 0; i < allProps.size(); ++i) { - Property *p = allProps[i]; + for (auto p : allProps) { const std::string &propName = p->name(); // Skip those not set and the input workspaces if (p->isDefault() || propName == "Workspace1" || propName == "Workspace2") diff --git a/Framework/Algorithms/src/ConvertEmptyToTof.cpp b/Framework/Algorithms/src/ConvertEmptyToTof.cpp index 1203672e158..576ae9cbe4f 100644 --- a/Framework/Algorithms/src/ConvertEmptyToTof.cpp +++ b/Framework/Algorithms/src/ConvertEmptyToTof.cpp @@ -131,8 +131,8 @@ void ConvertEmptyToTof::exec() { std::map<int, int> eppMap = findElasticPeakPositions(spectraIndices, channelIndices); - for (auto it = eppMap.begin(); it != eppMap.end(); ++it) { - g_log.debug() << "Spectra idx =" << it->first << ", epp=" << it->second + for (auto &it : eppMap) { + g_log.debug() << "Spectra idx =" << it.first << ", epp=" << it.second << std::endl; } @@ -168,10 +168,10 @@ void ConvertEmptyToTof::validateSpectraIndices(std::vector<int> &v) { for (unsigned int i = 0; i < nHist; ++i) v[i] = i; } else { - for (auto it = v.begin(); it != v.end(); ++it) { - if (*it < 0 || static_cast<size_t>(*it) >= nHist) { + for (int &it : v) { + if (it < 0 || static_cast<size_t>(it) >= nHist) { throw std::runtime_error("Spectra index out of limits: " + - boost::lexical_cast<std::string>(*it)); + boost::lexical_cast<std::string>(it)); } } } @@ -193,10 +193,10 @@ void ConvertEmptyToTof::validateChannelIndices(std::vector<int> &v) { for (unsigned int i = 0; i < blockSize; ++i) v[i] = i; } else { - for (auto it = v.begin(); it != v.end(); ++it) { - if (*it < 0 || static_cast<size_t>(*it) >= blockSize) { + for (int &it : v) { + if (it < 0 || static_cast<size_t>(it) >= blockSize) { throw std::runtime_error("Channel index out of limits: " + - boost::lexical_cast<std::string>(*it)); + boost::lexical_cast<std::string>(it)); } } } @@ -219,9 +219,8 @@ std::map<int, int> ConvertEmptyToTof::findElasticPeakPositions( g_log.information() << "Peak detection, search for peak " << std::endl; - for (auto it = spectraIndices.begin(); it != spectraIndices.end(); ++it) { + for (int spectrumIndex : spectraIndices) { - int spectrumIndex = *it; const Mantid::MantidVec &thisSpecY = m_inputWS->dataY(spectrumIndex); int minChannelIndex = *(channelIndices.begin()); @@ -399,9 +398,9 @@ ConvertEmptyToTof::findAverageEppAndEpTof(const std::map<int, int> &eppMap) { std::vector<int> eppList; double firstL2 = getL2(m_inputWS, eppMap.begin()->first); - for (auto it = eppMap.begin(); it != eppMap.end(); ++it) { + for (const auto &it : eppMap) { - double l2 = getL2(m_inputWS, it->first); + double l2 = getL2(m_inputWS, it.first); if (!areEqual(l2, firstL2, 0.0001)) { g_log.error() << "firstL2=" << firstL2 << " , " << "l2=" << l2 << std::endl; @@ -414,9 +413,9 @@ ConvertEmptyToTof::findAverageEppAndEpTof(const std::map<int, int> &eppMap) { epTofList.push_back( (calculateTOF(l1, wavelength) + calculateTOF(l2, wavelength)) * 1e6); // microsecs - eppList.push_back(it->first); + eppList.push_back(it.first); - g_log.debug() << "WS index = " << it->first << ", l1 = " << l1 + g_log.debug() << "WS index = " << it.first << ", l1 = " << l1 << ", l2 = " << l2 << ", TOF(l1+l2) = " << *(epTofList.end() - 1) << std::endl; } diff --git a/Framework/Algorithms/src/CopyLogs.cpp b/Framework/Algorithms/src/CopyLogs.cpp index 4a9481821ff..053ef18ec6a 100644 --- a/Framework/Algorithms/src/CopyLogs.cpp +++ b/Framework/Algorithms/src/CopyLogs.cpp @@ -91,8 +91,7 @@ void CopyLogs::exec() { */ void CopyLogs::mergeReplaceExisting( const std::vector<Kernel::Property *> &inputLogs, Run &outputRun) { - for (auto iter = inputLogs.begin(); iter != inputLogs.end(); ++iter) { - Kernel::Property *prop = *iter; + for (auto prop : inputLogs) { // if the log exists, remove and replace it if (outputRun.hasProperty(prop->name())) { outputRun.removeLogData(prop->name()); @@ -107,8 +106,7 @@ void CopyLogs::mergeReplaceExisting( */ void CopyLogs::mergeKeepExisting( const std::vector<Kernel::Property *> &inputLogs, Run &outputRun) { - for (auto iter = inputLogs.begin(); iter != inputLogs.end(); ++iter) { - Kernel::Property *prop = *iter; + for (auto prop : inputLogs) { // add the log only if it doesn't already exist if (!outputRun.hasProperty(prop->name())) { outputRun.addLogData(prop->clone()); @@ -125,13 +123,13 @@ void CopyLogs::wipeExisting(const std::vector<Kernel::Property *> &inputLogs, auto outputLogs = outputRun.getLogData(); // remove each of the logs from the second workspace - for (auto iter = outputLogs.begin(); iter != outputLogs.end(); ++iter) { - outputRun.removeLogData((*iter)->name()); + for (auto &outputLog : outputLogs) { + outputRun.removeLogData(outputLog->name()); } // add all the logs from the new workspace - for (auto iter = inputLogs.begin(); iter != inputLogs.end(); ++iter) { - outputRun.addLogData((*iter)->clone()); + for (auto inputLog : inputLogs) { + outputRun.addLogData(inputLog->clone()); } } diff --git a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp index 75bfd012191..027fcd3a7d7 100644 --- a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp +++ b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp @@ -164,8 +164,8 @@ void CorelliCrossCorrelate::exec() { int offset_int = getProperty("TimingOffset"); const int64_t offset = static_cast<int64_t>(offset_int); - for (unsigned long i = 0; i < tdc.size(); ++i) - tdc[i] += offset; + for (auto &i : tdc) + i += offset; // Determine period from chopper frequency. auto motorSpeed = dynamic_cast<TimeSeriesProperty<double> *>( diff --git a/Framework/Algorithms/src/CreateCalFileByNames.cpp b/Framework/Algorithms/src/CreateCalFileByNames.cpp index 22d22acffdf..1d0bc867388 100644 --- a/Framework/Algorithms/src/CreateCalFileByNames.cpp +++ b/Framework/Algorithms/src/CreateCalFileByNames.cpp @@ -80,9 +80,9 @@ void CreateCalFileByNames::exec() { // Assign incremental number to each group std::map<std::string, int> group_map; int index = 0; - for (auto it = vgroups.begin(); it != vgroups.end(); ++it) { - boost::trim(*it); - group_map[(*it)] = ++index; + for (auto &vgroup : vgroups) { + boost::trim(vgroup); + group_map[vgroup] = ++index; } // Not needed anymore @@ -221,9 +221,9 @@ void CreateCalFileByNames::saveGroupingFile(const std::string &filename, } } else // { - for (auto it = instrcalib.cbegin(); it != instrcalib.cend(); ++it) - writeCalEntry(outfile, (*it).first, ((*it).second).first, 0.0, 1, - ((*it).second).second); + for (const auto &it : instrcalib) + writeCalEntry(outfile, it.first, (it.second).first, 0.0, 1, + (it.second).second); } // Closing diff --git a/Framework/Algorithms/src/CreateDummyCalFile.cpp b/Framework/Algorithms/src/CreateDummyCalFile.cpp index 578bfaf5854..0992b3c478b 100644 --- a/Framework/Algorithms/src/CreateDummyCalFile.cpp +++ b/Framework/Algorithms/src/CreateDummyCalFile.cpp @@ -223,9 +223,9 @@ void CreateDummyCalFile::saveGroupingFile(const std::string &filename, } } else // { - for (auto it = instrcalib.cbegin(); it != instrcalib.cend(); ++it) - writeCalEntry(outfile, (*it).first, ((*it).second).first, 0.0, 1, - ((*it).second).second); + for (const auto &it : instrcalib) + writeCalEntry(outfile, it.first, (it.second).first, 0.0, 1, + (it.second).second); } // Closing diff --git a/Framework/Algorithms/src/CreateGroupingWorkspace.cpp b/Framework/Algorithms/src/CreateGroupingWorkspace.cpp index 0397f29252e..e57fb145b70 100644 --- a/Framework/Algorithms/src/CreateGroupingWorkspace.cpp +++ b/Framework/Algorithms/src/CreateGroupingWorkspace.cpp @@ -246,9 +246,9 @@ void makeGroupingByNames(std::string GroupNames, Instrument_const_sptr inst, // Trim and assign incremental number to each group std::map<std::string, int> group_map; int index = 0; - for (auto it = vgroups.begin(); it != vgroups.end(); ++it) { - boost::trim(*it); - group_map[(*it)] = ++index; + for (auto &vgroup : vgroups) { + boost::trim(vgroup); + group_map[vgroup] = ++index; } // Find Detectors that belong to groups diff --git a/Framework/Algorithms/src/CreateLogPropertyTable.cpp b/Framework/Algorithms/src/CreateLogPropertyTable.cpp index ca716941326..deb6cc0112d 100644 --- a/Framework/Algorithms/src/CreateLogPropertyTable.cpp +++ b/Framework/Algorithms/src/CreateLogPropertyTable.cpp @@ -93,27 +93,24 @@ void CreateLogPropertyTable::exec() { this->getProperty("LogPropertyNames"); // Make sure all workspaces contain the properties. - for (auto matrixWs = matrixWsList.begin(); matrixWs != matrixWsList.end(); - ++matrixWs) { - const Run &run = matrixWs->get()->run(); - const std::string wsName = matrixWs->get()->getName(); + for (const auto &matrixWs : matrixWsList) { + const Run &run = matrixWs.get()->run(); + const std::string wsName = matrixWs.get()->getName(); // Throw if a run does not have a property. - for (auto propName = propNames.begin(); propName != propNames.end(); - ++propName) - if (!run.hasProperty(*propName)) + for (const auto &propName : propNames) + if (!run.hasProperty(propName)) throw std::runtime_error("\"" + wsName + "\" does not have a run property of \"" + - *propName + "\"."); + propName + "\"."); } // Set up output table. boost::shared_ptr<ITableWorkspace> outputTable = WorkspaceFactory::Instance().createTable(); // One column for each property. - for (auto propName = propNames.begin(); propName != propNames.end(); - ++propName) - outputTable->addColumn("str", *propName); + for (const auto &propName : propNames) + outputTable->addColumn("str", propName); // One row for each workspace. for (size_t i = 0; i < matrixWsList.size(); ++i) outputTable->appendRow(); @@ -132,13 +129,12 @@ void CreateLogPropertyTable::exec() { TableRow row = outputTable->getRow(i); MatrixWorkspace_sptr matrixWs = matrixWsList[i]; - for (auto propName = propNames.begin(); propName != propNames.end(); - ++propName) { - Property *prop = matrixWs->run().getProperty(*propName); + for (const auto &propName : propNames) { + Property *prop = matrixWs->run().getProperty(propName); std::stringstream propValue; if (prop->type().find("TimeValue") != std::string::npos) { - propValue << matrixWs->run().getLogAsSingleValue(*propName, + propValue << matrixWs->run().getLogAsSingleValue(propName, timeSeriesStat); } else { propValue << prop->value(); @@ -174,12 +170,12 @@ retrieveMatrixWsList(const std::vector<std::string> &wsNames, std::vector<MatrixWorkspace_sptr> matrixWsList; // Get all the workspaces which are to be inspected for log proeprties. - for (auto wsName = wsNames.begin(); wsName != wsNames.end(); ++wsName) { + for (const auto &wsName : wsNames) { WorkspaceGroup_sptr wsGroup = boost::dynamic_pointer_cast<WorkspaceGroup>( - AnalysisDataService::Instance().retrieve(*wsName)); + AnalysisDataService::Instance().retrieve(wsName)); MatrixWorkspace_sptr matrixWs = boost::dynamic_pointer_cast<MatrixWorkspace>( - AnalysisDataService::Instance().retrieve(*wsName)); + AnalysisDataService::Instance().retrieve(wsName)); if (wsGroup) { const std::vector<std::string> childNames = wsGroup->getNames(); @@ -191,20 +187,18 @@ retrieveMatrixWsList(const std::vector<std::string> &wsNames, // Retrieve pointers to all the child workspaces. std::vector<MatrixWorkspace_sptr> childWsList; - for (auto childName = childNames.begin(); childName != childNames.end(); - ++childName) { + for (const auto &childName : childNames) { childWsList.push_back( AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( - *childName)); + childName)); } // Deal with child workspaces according to policy. switch (groupPolicy) { case ALL: { // Append all the children to the list. - for (auto childWs = childWsList.begin(); childWs != childWsList.end(); - ++childWs) - matrixWsList.push_back(*childWs); + for (auto &childWs : childWsList) + matrixWsList.push_back(childWs); break; } case FIRST: @@ -275,8 +269,8 @@ std::set<std::string> getAllGroupPolicyNames() { const std::map<std::string, GroupPolicy> &map = getGroupPolicyMap(); std::set<std::string> groupPolicyNames; - for (auto policy = map.begin(); policy != map.end(); ++policy) - groupPolicyNames.insert(policy->first); + for (const auto &policy : map) + groupPolicyNames.insert(policy.first); return groupPolicyNames; } @@ -330,8 +324,8 @@ std::set<std::string> getAllStatisticTypeNames() { const std::map<std::string, Math::StatisticType> &map = getStatisticTypeMap(); std::set<std::string> statisticTypeNames; - for (auto policy = map.begin(); policy != map.end(); ++policy) - statisticTypeNames.insert(policy->first); + for (const auto &policy : map) + statisticTypeNames.insert(policy.first); return statisticTypeNames; } diff --git a/Framework/Algorithms/src/CreateLogTimeCorrection.cpp b/Framework/Algorithms/src/CreateLogTimeCorrection.cpp index 4652655b238..0c56f1c4a7e 100644 --- a/Framework/Algorithms/src/CreateLogTimeCorrection.cpp +++ b/Framework/Algorithms/src/CreateLogTimeCorrection.cpp @@ -108,11 +108,11 @@ void CreateLogTimeCorrection::getInstrumentSetup() { // 2. Get detector IDs std::vector<detid_t> detids = m_instrument->getDetectorIDs(true); - for (size_t i = 0; i < detids.size(); ++i) { - IDetector_const_sptr detector = m_instrument->getDetector(detids[i]); + for (int &detid : detids) { + IDetector_const_sptr detector = m_instrument->getDetector(detid); V3D detpos = detector->getPos(); double l2 = detpos.distance(samplepos); - m_l2map.insert(make_pair(detids[i], l2)); + m_l2map.insert(make_pair(detid, l2)); } // 3. Output information diff --git a/Framework/Algorithms/src/CreatePSDBleedMask.cpp b/Framework/Algorithms/src/CreatePSDBleedMask.cpp index c2c563d3968..3941d860cb7 100644 --- a/Framework/Algorithms/src/CreatePSDBleedMask.cpp +++ b/Framework/Algorithms/src/CreatePSDBleedMask.cpp @@ -269,8 +269,8 @@ bool CreatePSDBleedMask::performBleedTest( void CreatePSDBleedMask::maskTube(const std::vector<int> &tubeIndices, API::MatrixWorkspace_sptr workspace) { const double deadValue(1.0); // delete the data - for (auto citr = tubeIndices.cbegin(); citr != tubeIndices.cend(); ++citr) { - workspace->dataY(*citr)[0] = deadValue; + for (int tubeIndice : tubeIndices) { + workspace->dataY(tubeIndice)[0] = deadValue; } } } diff --git a/Framework/Algorithms/src/CreateSampleWorkspace.cpp b/Framework/Algorithms/src/CreateSampleWorkspace.cpp index caf599fbcf3..679f7f22a31 100644 --- a/Framework/Algorithms/src/CreateSampleWorkspace.cpp +++ b/Framework/Algorithms/src/CreateSampleWorkspace.cpp @@ -109,9 +109,8 @@ void CreateSampleWorkspace::init() { m_preDefinedFunctionmap.insert( std::pair<std::string, std::string>("User Defined", "")); std::vector<std::string> functionOptions; - for (auto iterator = m_preDefinedFunctionmap.begin(); - iterator != m_preDefinedFunctionmap.end(); iterator++) { - functionOptions.push_back(iterator->first); + for (auto &iterator : m_preDefinedFunctionmap) { + functionOptions.push_back(iterator.first); } declareProperty("Function", "One Peak", boost::make_shared<StringListValidator>(functionOptions), diff --git a/Framework/Algorithms/src/DetectorDiagnostic.cpp b/Framework/Algorithms/src/DetectorDiagnostic.cpp index 35dafe442d1..6fff79a4214 100644 --- a/Framework/Algorithms/src/DetectorDiagnostic.cpp +++ b/Framework/Algorithms/src/DetectorDiagnostic.cpp @@ -619,10 +619,8 @@ DetectorDiagnostic::calculateMedian(const API::MatrixWorkspace_sptr input, std::vector<double> medianvec; g_log.debug("Calculating the median count rate of the spectra"); - for (size_t j = 0; j < indexmap.size(); ++j) { + for (auto hists : indexmap) { std::vector<double> medianInput; - std::vector<size_t> hists = indexmap.at(j); - const int nhists = static_cast<int>(hists.size()); // The maximum possible length is that of workspace length medianInput.reserve(nhists); @@ -635,19 +633,19 @@ DetectorDiagnostic::calculateMedian(const API::MatrixWorkspace_sptr input, } PARALLEL_FOR1(input) - for (int i = 0; i < static_cast<int>(hists.size()); ++i) { + for (unsigned long hist : hists) { PARALLEL_START_INTERUPT_REGION if (checkForMask) { const std::set<detid_t> &detids = - input->getSpectrum(hists[i])->getDetectorIDs(); + input->getSpectrum(hist)->getDetectorIDs(); if (instrument->isDetectorMasked(detids)) continue; if (instrument->isMonitor(detids)) continue; } - const double yValue = input->readY(hists[i])[0]; + const double yValue = input->readY(hist)[0]; if (yValue < 0.0) { throw std::out_of_range("Negative number of counts found, could be " "corrupted raw counts or solid angle data"); diff --git a/Framework/Algorithms/src/DiffractionFocussing2.cpp b/Framework/Algorithms/src/DiffractionFocussing2.cpp index 8ba970a8d09..05e80f13502 100644 --- a/Framework/Algorithms/src/DiffractionFocussing2.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing2.cpp @@ -245,8 +245,8 @@ void DiffractionFocussing2::exec() { m_matrixInputW->maskedBins(i); // Now iterate over the list, adjusting the weights for the affected // bins - for (auto it = mask.cbegin(); it != mask.cend(); ++it) { - const double currentX = Xin[(*it).first]; + for (const auto &it : mask) { + const double currentX = Xin[it.first]; // Add an intermediate bin with full weight if masked bins aren't // consecutive if (weight_bins.back() != currentX) { @@ -255,8 +255,8 @@ void DiffractionFocussing2::exec() { } // The weight for this masked bin is 1 - the degree to which this bin // is masked - weights.push_back(1.0 - (*it).second); - weight_bins.push_back(Xin[(*it).first + 1]); + weights.push_back(1.0 - it.second); + weight_bins.push_back(Xin[it.first + 1]); } // Add on a final bin with full weight if masking doesn't go up to the // end @@ -368,8 +368,8 @@ void DiffractionFocussing2::execEvent() { const vector<size_t> &indices = this->m_wsIndices[group]; totalHistProcess += static_cast<int>(indices.size()); - for (auto index = indices.cbegin(); index != indices.cend(); ++index) { - size_required[iGroup] += m_eventW->getEventList(*index).getNumberEvents(); + for (unsigned long indice : indices) { + size_required[iGroup] += m_eventW->getEventList(indice).getNumberEvents(); } prog->report(1, "Pre-counting"); } @@ -454,9 +454,7 @@ void DiffractionFocussing2::execEvent() { PARALLEL_START_INTERUPT_REGION const int group = this->m_validGroups[iGroup]; const std::vector<size_t> &indices = this->m_wsIndices[group]; - for (size_t i = 0; i < indices.size(); i++) { - size_t wi = indices[i]; - + for (unsigned long wi : indices) { // In workspace index iGroup, put what was in the OLD workspace index wi out->getOrAddEventList(iGroup) += m_eventW->getEventList(wi); diff --git a/Framework/Algorithms/src/FilterEvents.cpp b/Framework/Algorithms/src/FilterEvents.cpp index a05080ed6ea..7ba9707408f 100644 --- a/Framework/Algorithms/src/FilterEvents.cpp +++ b/Framework/Algorithms/src/FilterEvents.cpp @@ -515,9 +515,7 @@ void FilterEvents::createOutputWorkspaces() { // Determine the minimum group index number int minwsgroup = INT_MAX; - for (auto groupit = m_workGroupIndexes.begin(); - groupit != m_workGroupIndexes.end(); ++groupit) { - int wsgroup = *groupit; + for (value_type wsgroup : m_workGroupIndexes) { if (wsgroup < minwsgroup && wsgroup >= 0) minwsgroup = wsgroup; } @@ -1035,8 +1033,7 @@ void FilterEvents::filterEventsByVectorSplitters(double progressamount) { void FilterEvents::generateSplitters(int wsindex, Kernel::TimeSplitterType &splitters) { splitters.clear(); - for (size_t isp = 0; isp < m_splitters.size(); ++isp) { - Kernel::SplittingInterval splitter = m_splitters[isp]; + for (auto splitter : m_splitters) { int index = splitter.index(); if (index == wsindex) { splitters.push_back(splitter); @@ -1060,8 +1057,7 @@ void FilterEvents::splitLog(EventWorkspace_sptr eventws, std::string logname, << std::endl; return; } else { - for (size_t i = 0; i < splitters.size(); ++i) { - SplittingInterval split = splitters[i]; + for (auto split : splitters) { g_log.debug() << "[FilterEvents DB1226] Going to filter workspace " << eventws->name() << ": " << "log name = " << logname @@ -1083,9 +1079,9 @@ void FilterEvents::getTimeSeriesLogNames(std::vector<std::string> &lognames) { const std::vector<Kernel::Property *> allprop = m_eventWS->mutableRun().getProperties(); - for (size_t ip = 0; ip < allprop.size(); ++ip) { + for (auto ip : allprop) { Kernel::TimeSeriesProperty<double> *timeprop = - dynamic_cast<Kernel::TimeSeriesProperty<double> *>(allprop[ip]); + dynamic_cast<Kernel::TimeSeriesProperty<double> *>(ip); if (timeprop) { std::string pname = timeprop->name(); lognames.push_back(pname); diff --git a/Framework/Algorithms/src/FitPeak.cpp b/Framework/Algorithms/src/FitPeak.cpp index 0e7e377b2d5..d9edf301ece 100644 --- a/Framework/Algorithms/src/FitPeak.cpp +++ b/Framework/Algorithms/src/FitPeak.cpp @@ -1275,16 +1275,16 @@ std::vector<std::string> FitPeak::addFunctionParameterNames(std::vector<std::string> funcnames) { vector<string> vec_funcparnames; - for (size_t i = 0; i < funcnames.size(); ++i) { + for (auto &funcname : funcnames) { // Add original name in - vec_funcparnames.push_back(funcnames[i]); + vec_funcparnames.push_back(funcname); // Add a full function name and parameter names in IFunction_sptr tempfunc = - FunctionFactory::Instance().createFunction(funcnames[i]); + FunctionFactory::Instance().createFunction(funcname); stringstream parnamess; - parnamess << funcnames[i] << " ("; + parnamess << funcname << " ("; vector<string> funcpars = tempfunc->getParameterNames(); for (size_t j = 0; j < funcpars.size(); ++j) { parnamess << funcpars[j]; @@ -1593,8 +1593,8 @@ void FitPeak::setupOutput( // Parameter vector vector<double> vec_fitpeak; - for (size_t i = 0; i < m_peakParameterNames.size(); ++i) { - double value = m_peakFunc->getParameter(m_peakParameterNames[i]); + for (auto &m_peakParameterName : m_peakParameterNames) { + double value = m_peakFunc->getParameter(m_peakParameterName); vec_fitpeak.push_back(value); } @@ -1602,8 +1602,8 @@ void FitPeak::setupOutput( // Background vector<double> vec_fitbkgd; - for (size_t i = 0; i < m_bkgdParameterNames.size(); ++i) { - double value = m_bkgdFunc->getParameter(m_bkgdParameterNames[i]); + for (auto &m_bkgdParameterName : m_bkgdParameterNames) { + double value = m_bkgdFunc->getParameter(m_bkgdParameterName); vec_fitbkgd.push_back(value); } @@ -1684,8 +1684,7 @@ TableWorkspace_sptr FitPeak::genOutputTableWS( if (m_outputRawParams) { vector<string> peakparnames = peakfunc->getParameterNames(); - for (size_t i = 0; i < peakparnames.size(); ++i) { - string &parname = peakparnames[i]; + for (auto &parname : peakparnames) { double parvalue = peakfunc->getParameter(parname); double error = peakerrormap[parname]; newrow = outtablews->appendRow(); @@ -1708,8 +1707,7 @@ TableWorkspace_sptr FitPeak::genOutputTableWS( if (m_outputRawParams) { vector<string> bkgdparnames = bkgdfunc->getParameterNames(); - for (size_t i = 0; i < bkgdparnames.size(); ++i) { - string &parname = bkgdparnames[i]; + for (auto &parname : bkgdparnames) { double parvalue = bkgdfunc->getParameter(parname); double error = bkgderrormap[parname]; newrow = outtablews->appendRow(); diff --git a/Framework/Algorithms/src/FixGSASInstrumentFile.cpp b/Framework/Algorithms/src/FixGSASInstrumentFile.cpp index 17d9a1014cd..efa3963cef0 100644 --- a/Framework/Algorithms/src/FixGSASInstrumentFile.cpp +++ b/Framework/Algorithms/src/FixGSASInstrumentFile.cpp @@ -98,8 +98,7 @@ void FixGSASInstrumentFile::exec() { throw runtime_error(errss.str()); } - for (size_t i = 0; i < vec_line.size(); ++i) { - string &line = vec_line[i]; + for (auto &line : vec_line) { ofile << line; for (size_t j = line.size(); j < LINESIZE; ++j) ofile << " "; diff --git a/Framework/Algorithms/src/GenerateEventsFilter.cpp b/Framework/Algorithms/src/GenerateEventsFilter.cpp index 5c1d9a29caf..ee751811f54 100644 --- a/Framework/Algorithms/src/GenerateEventsFilter.cpp +++ b/Framework/Algorithms/src/GenerateEventsFilter.cpp @@ -759,11 +759,10 @@ void GenerateEventsFilter::processMultipleValueFilters(double minvalue, // Debug print stringstream dbsplitss; dbsplitss << "Index map size = " << indexwsindexmap.size() << "\n"; - for (auto mit = indexwsindexmap.begin(); mit != indexwsindexmap.end(); - ++mit) { - dbsplitss << "Index " << mit->first << ": WS-group = " << mit->second - << ". Log value range: [" << logvalueranges[mit->first * 2] - << ", " << logvalueranges[mit->first * 2 + 1] << ").\n"; + for (auto &mit : indexwsindexmap) { + dbsplitss << "Index " << mit.first << ": WS-group = " << mit.second + << ". Log value range: [" << logvalueranges[mit.first * 2] << ", " + << logvalueranges[mit.first * 2 + 1] << ").\n"; } g_log.information(dbsplitss.str()); diff --git a/Framework/Algorithms/src/GeneratePeaks.cpp b/Framework/Algorithms/src/GeneratePeaks.cpp index 467bc87d061..e5e9f2b80c1 100644 --- a/Framework/Algorithms/src/GeneratePeaks.cpp +++ b/Framework/Algorithms/src/GeneratePeaks.cpp @@ -577,8 +577,8 @@ void GeneratePeaks::processTableColumnNames() { << " does not have paramter " << m_funcParameterNames[i] << "\n" << "Allowed function parameters are "; std::vector<std::string> parnames = m_peakFunction->getParameterNames(); - for (size_t k = 0; k < parnames.size(); ++k) - errss << parnames[k] << ", "; + for (auto &parname : parnames) + errss << parname << ", "; throw std::runtime_error(errss.str()); } } @@ -820,16 +820,16 @@ std::vector<std::string> GeneratePeaks::addFunctionParameterNames(std::vector<std::string> funcnames) { std::vector<std::string> vec_funcparnames; - for (size_t i = 0; i < funcnames.size(); ++i) { + for (auto &funcname : funcnames) { // Add original name in - vec_funcparnames.push_back(funcnames[i]); + vec_funcparnames.push_back(funcname); // Add a full function name and parameter names in IFunction_sptr tempfunc = - FunctionFactory::Instance().createFunction(funcnames[i]); + FunctionFactory::Instance().createFunction(funcname); std::stringstream parnamess; - parnamess << funcnames[i] << " ("; + parnamess << funcname << " ("; std::vector<std::string> funcpars = tempfunc->getParameterNames(); for (size_t j = 0; j < funcpars.size(); ++j) { parnamess << funcpars[j]; diff --git a/Framework/Algorithms/src/GetAllEi.cpp b/Framework/Algorithms/src/GetAllEi.cpp index 5e6974ff5ec..3198f40b3f3 100644 --- a/Framework/Algorithms/src/GetAllEi.cpp +++ b/Framework/Algorithms/src/GetAllEi.cpp @@ -272,8 +272,8 @@ void GetAllEi::exec() { destUnit->initialize(mon1Distance, 0., 0., static_cast<int>(Kernel::DeltaEMode::Elastic), 0., unused); - for (size_t i = 0; i < guess_opening.size(); i++) { - double eGuess = destUnit->singleFromTOF(guess_opening[i]); + for (double i : guess_opening) { + double eGuess = destUnit->singleFromTOF(i); if (eGuess > eMin && eGuess < eMax) { guess_ei.push_back(eGuess); } @@ -282,8 +282,8 @@ void GetAllEi::exec() { boost::lexical_cast<std::string>(guess_ei.size()) + " fell within both monitor's recording energy range\n"; g_log.debug() << " Guess Energies are:\n"; - for (size_t i = 0; i < guess_ei.size(); i++) { - g_log.debug() << boost::str(boost::format(" %8.2f; ") % guess_ei[i]); + for (double &i : guess_ei) { + g_log.debug() << boost::str(boost::format(" %8.2f; ") % i); } g_log.debug() << std::endl; @@ -399,13 +399,13 @@ void GetAllEi::printDebugModeInfo(const std::vector<double> &guess_opening, << " chopper prospective opening within time frame: " << TOF_range.first << " to: " << TOF_range.second << std::endl; g_log.debug() << " Timings are:\n"; - for (size_t i = 0; i < guess_opening.size(); i++) { - g_log.debug() << boost::str(boost::format(" %8.2f; ") % guess_opening[i]); + for (double i : guess_opening) { + g_log.debug() << boost::str(boost::format(" %8.2f; ") % i); } g_log.debug() << std::endl; g_log.debug() << " Corresponding to energies:\n"; - for (size_t i = 0; i < guess_opening.size(); i++) { - double ei = destUnit->singleFromTOF(guess_opening[i]); + for (double i : guess_opening) { + double ei = destUnit->singleFromTOF(i); g_log.debug() << boost::str(boost::format(" %8.2f; ") % ei); } g_log.debug() << std::endl; diff --git a/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp b/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp index ed6fedd46ee..3a6b40fa35b 100644 --- a/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp +++ b/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp @@ -1153,9 +1153,9 @@ void GetDetOffsetsMultiPeaks::createInformationWorkspaces() { // set up columns m_peakOffsetTableWS->addColumn("int", "WorkspaceIndex"); - for (size_t i = 0; i < m_peakPositions.size(); ++i) { + for (double m_peakPosition : m_peakPositions) { std::stringstream namess; - namess << "@" << std::setprecision(5) << m_peakPositions[i]; + namess << "@" << std::setprecision(5) << m_peakPosition; m_peakOffsetTableWS->addColumn("str", namess.str()); } m_peakOffsetTableWS->addColumn("double", "OffsetDeviation"); diff --git a/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp b/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp index 8c078c51d93..49582813bfa 100644 --- a/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp +++ b/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp @@ -277,10 +277,9 @@ TableWorkspace_sptr GetTimeSeriesLogInformation::generateStatisticTable() { tablews->addColumn("double", "Value"); // 1. Integer part - for (auto intmapiter = m_intInfoMap.begin(); intmapiter != m_intInfoMap.end(); - ++intmapiter) { - string name = intmapiter->first; - size_t value = intmapiter->second; + for (auto &intmapiter : m_intInfoMap) { + string name = intmapiter.first; + size_t value = intmapiter.second; TableRow newrow = tablews->appendRow(); newrow << name << static_cast<double>(value); @@ -407,8 +406,8 @@ Workspace2D_sptr GetTimeSeriesLogInformation::calDistributions( vecCount[i] = 0; // 3. Count - for (size_t i = 0; i < vecdt.size(); ++i) { - double dt = vecdt[i]; + for (double i : vecdt) { + double dt = i; int index; if (dt < 0 && m_ignoreNegativeTime) { index = 0; @@ -419,7 +418,7 @@ Workspace2D_sptr GetTimeSeriesLogInformation::calDistributions( // Out of upper boundary g_log.error() << "Find index = " << index << " > vecX.size = " << vecDeltaT.size() << ".\n"; - } else if (vecdt[i] < vecDeltaT[index]) { + } else if (i < vecDeltaT[index]) { --index; } diff --git a/Framework/Algorithms/src/GroupWorkspaces.cpp b/Framework/Algorithms/src/GroupWorkspaces.cpp index 66f81de9bb9..df14cce79ce 100644 --- a/Framework/Algorithms/src/GroupWorkspaces.cpp +++ b/Framework/Algorithms/src/GroupWorkspaces.cpp @@ -51,8 +51,8 @@ void GroupWorkspaces::exec() { void GroupWorkspaces::addToGroup(const std::vector<std::string> &names) { AnalysisDataServiceImpl &ads = AnalysisDataService::Instance(); - for (auto citr = names.cbegin(); citr != names.cend(); ++citr) { - auto workspace = ads.retrieve(*citr); + for (const auto &name : names) { + auto workspace = ads.retrieve(name); addToGroup(workspace); } } diff --git a/Framework/Algorithms/src/IntegrateByComponent.cpp b/Framework/Algorithms/src/IntegrateByComponent.cpp index 104713732b2..d1f3d629e57 100644 --- a/Framework/Algorithms/src/IntegrateByComponent.cpp +++ b/Framework/Algorithms/src/IntegrateByComponent.cpp @@ -78,27 +78,26 @@ void IntegrateByComponent::exec() { std::vector<std::vector<size_t>> specmap = makeMap(integratedWS, parents); API::Progress prog(this, 0.3, 1.0, specmap.size()); // calculate averages - for (size_t j = 0; j < specmap.size(); ++j) { + for (auto hists : specmap) { prog.report(); - std::vector<size_t> hists = specmap.at(j); std::vector<double> averageYInput, averageEInput; Geometry::Instrument_const_sptr instrument = integratedWS->getInstrument(); PARALLEL_FOR1(integratedWS) - for (int i = 0; i < static_cast<int>(hists.size()); ++i) { + for (unsigned long hist : hists) { PARALLEL_START_INTERUPT_REGION const std::set<detid_t> &detids = - integratedWS->getSpectrum(hists[i]) + integratedWS->getSpectrum(hist) ->getDetectorIDs(); // should be only one detector per spectrum if (instrument->isDetectorMasked(detids)) continue; if (instrument->isMonitor(detids)) continue; - const double yValue = integratedWS->readY(hists[i])[0]; - const double eValue = integratedWS->readE(hists[i])[0]; + const double yValue = integratedWS->readY(hist)[0]; + const double eValue = integratedWS->readE(hist)[0]; if (boost::math::isnan(yValue) || boost::math::isinf(yValue) || boost::math::isnan(eValue) || @@ -128,18 +127,18 @@ void IntegrateByComponent::exec() { } PARALLEL_FOR1(integratedWS) - for (int i = 0; i < static_cast<int>(hists.size()); ++i) { + for (unsigned long hist : hists) { PARALLEL_START_INTERUPT_REGION const std::set<detid_t> &detids = - integratedWS->getSpectrum(hists[i]) + integratedWS->getSpectrum(hist) ->getDetectorIDs(); // should be only one detector per spectrum if (instrument->isDetectorMasked(detids)) continue; if (instrument->isMonitor(detids)) continue; - const double yValue = integratedWS->readY(hists[i])[0]; - const double eValue = integratedWS->readE(hists[i])[0]; + const double yValue = integratedWS->readY(hist)[0]; + const double eValue = integratedWS->readE(hist)[0]; if (boost::math::isnan(yValue) || boost::math::isinf(yValue) || boost::math::isnan(eValue) || boost::math::isinf(eValue)) // NaNs/Infs @@ -147,8 +146,8 @@ void IntegrateByComponent::exec() { // Now we have a good value PARALLEL_CRITICAL(IntegrateByComponent_setaverage) { - integratedWS->dataY(hists[i])[0] = averageY; - integratedWS->dataE(hists[i])[0] = averageE; + integratedWS->dataY(hist)[0] = averageY; + integratedWS->dataE(hist)[0] = averageE; } PARALLEL_END_INTERUPT_REGION diff --git a/Framework/Algorithms/src/MaskBins.cpp b/Framework/Algorithms/src/MaskBins.cpp index 4596c5ef455..c1f3bc54fd6 100644 --- a/Framework/Algorithms/src/MaskBins.cpp +++ b/Framework/Algorithms/src/MaskBins.cpp @@ -78,8 +78,7 @@ void MaskBins::exec() { if (this->spectra_list.size() > 0) { const int numHist = static_cast<int>(inputWS->getNumberHistograms()); //--- Validate spectra list --- - for (size_t i = 0; i < this->spectra_list.size(); ++i) { - int wi = this->spectra_list[i]; + for (int wi : this->spectra_list) { if ((wi < 0) || (wi >= numHist)) { std::ostringstream oss; oss << "One of the workspace indices specified, " << wi @@ -205,9 +204,9 @@ void MaskBins::execEvent() { if (this->spectra_list.size() > 0) { // Specific spectra were specified PARALLEL_FOR1(outputWS) - for (int i = 0; i < static_cast<int>(this->spectra_list.size()); ++i) { + for (int i : this->spectra_list) { PARALLEL_START_INTERUPT_REGION - outputWS->getEventList(this->spectra_list[i]).maskTof(m_startX, m_endX); + outputWS->getEventList(i).maskTof(m_startX, m_endX); progress.report(); PARALLEL_END_INTERUPT_REGION } diff --git a/Framework/Algorithms/src/MaskDetectorsIf.cpp b/Framework/Algorithms/src/MaskDetectorsIf.cpp index 5c32c363428..812280753ca 100644 --- a/Framework/Algorithms/src/MaskDetectorsIf.cpp +++ b/Framework/Algorithms/src/MaskDetectorsIf.cpp @@ -78,8 +78,8 @@ void MaskDetectorsIf::exec() { else { double val = inputW->readY(i)[0]; if (compar_f(val, value)) { - for (auto it = dets.cbegin(); it != dets.cend(); ++it) - umap.insert(std::make_pair(*it, select_on)); + for (value_type det : dets) + umap.insert(std::make_pair(det, select_on)); } } double p = static_cast<double>(i) / static_cast<double>(nspec); diff --git a/Framework/Algorithms/src/MaxEnt.cpp b/Framework/Algorithms/src/MaxEnt.cpp index 9d47b34759d..8f4b967a184 100644 --- a/Framework/Algorithms/src/MaxEnt.cpp +++ b/Framework/Algorithms/src/MaxEnt.cpp @@ -206,13 +206,13 @@ void MaxEnt::exec() { // Apply distance penalty (SB eq. 33) double sum = 0.; - for (size_t i = 0; i < image.size(); i++) - sum += fabs(image[i]); + for (double i : image) + sum += fabs(i); double dist = distance(dirs.s2, beta); if (dist > distEps * sum / background) { - for (size_t k = 0; k < beta.size(); k++) { - beta[k] *= sqrt(sum / dist / background); + for (double &k : beta) { + k *= sqrt(sum / dist / background); } } diff --git a/Framework/Algorithms/src/MedianDetectorTest.cpp b/Framework/Algorithms/src/MedianDetectorTest.cpp index c79c0eb1e07..ccf8339d2bd 100644 --- a/Framework/Algorithms/src/MedianDetectorTest.cpp +++ b/Framework/Algorithms/src/MedianDetectorTest.cpp @@ -250,21 +250,21 @@ int MedianDetectorTest::maskOutliers( double median = medianvec.at(i); PARALLEL_FOR1(countsWS) - for (int j = 0; j < static_cast<int>(hists.size()); ++j) { - const double value = countsWS->readY(hists.at(j))[0]; + for (unsigned long hist : hists) { + const double value = countsWS->readY(hist)[0]; if ((value == 0.) && checkForMask) { const std::set<detid_t> &detids = - countsWS->getSpectrum(hists.at(j))->getDetectorIDs(); + countsWS->getSpectrum(hist)->getDetectorIDs(); if (instrument->isDetectorMasked(detids)) { numFailed -= 1; // it was already masked } } if ((value < out_lo * median) && (value > 0.0)) { - countsWS->maskWorkspaceIndex(hists.at(j)); + countsWS->maskWorkspaceIndex(hist); PARALLEL_ATOMIC ++numFailed; } else if (value > out_hi * median) { - countsWS->maskWorkspaceIndex(hists.at(j)); + countsWS->maskWorkspaceIndex(hist); PARALLEL_ATOMIC ++numFailed; } diff --git a/Framework/Algorithms/src/MergeRuns.cpp b/Framework/Algorithms/src/MergeRuns.cpp index 7c60a8f00e8..449667cb189 100644 --- a/Framework/Algorithms/src/MergeRuns.cpp +++ b/Framework/Algorithms/src/MergeRuns.cpp @@ -64,16 +64,15 @@ void MergeRuns::exec() { // This will hold the inputs, with the groups separated off std::vector<std::string> inputs; - for (size_t i = 0; i < inputs_orig.size(); i++) { + for (const auto &i : inputs_orig) { WorkspaceGroup_sptr wsgroup = - AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( - inputs_orig[i]); + AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(i); if (wsgroup) { // Workspace group std::vector<std::string> group = wsgroup->getNames(); inputs.insert(inputs.end(), group.begin(), group.end()); } else { // Single workspace - inputs.push_back(inputs_orig[i]); + inputs.push_back(i); } } @@ -283,9 +282,9 @@ void MergeRuns::execEvent() { boost::shared_ptr<AdditionTable> table = m_tables[workspaceNum - 1]; // Add all the event lists together as the table says to do - for (auto it = table->begin(); it != table->end(); ++it) { - int64_t inWI = it->first; - int64_t outWI = it->second; + for (auto &it : *table) { + int64_t inWI = it.first; + int64_t outWI = it.second; if (outWI >= 0) { outWS->getEventList(outWI) += addee->getEventList(inWI); } else { diff --git a/Framework/Algorithms/src/ModeratorTzero.cpp b/Framework/Algorithms/src/ModeratorTzero.cpp index 9e8fcbf851f..a9edb39f0ab 100644 --- a/Framework/Algorithms/src/ModeratorTzero.cpp +++ b/Framework/Algorithms/src/ModeratorTzero.cpp @@ -348,23 +348,23 @@ void ModeratorTzero::execEvent(const std::string &emode) { double tof; // fix the histogram bins MantidVec &x = evlist.dataX(); - for (auto iter = x.begin(); iter != x.end(); ++iter) { - tof = *iter; + for (double &iter : x) { + tof = iter; if (tof < m_t1min + t2) tof -= min_t0_next; else tof -= CalculateT0indirect(tof, L1, t2, E1, parser); - *iter = tof; + iter = tof; } MantidVec tofs = evlist.getTofs(); - for (unsigned int itof = 0; itof < tofs.size(); itof++) { - tof = tofs[itof]; + for (double &itof : tofs) { + tof = itof; if (tof < m_t1min + t2) tof -= min_t0_next; else tof -= CalculateT0indirect(tof, L1, t2, E1, parser); - tofs[itof] = tof; + itof = tof; } evlist.setTofs(tofs); evlist.setSortOrder(Mantid::DataObjects::EventSortType::UNSORTED); @@ -374,25 +374,25 @@ void ModeratorTzero::execEvent(const std::string &emode) { double tof; // Apply t0 correction to histogram bins MantidVec &x = evlist.dataX(); - for (auto iter = x.begin(); iter != x.end(); ++iter) { - tof = *iter; + for (double &iter : x) { + tof = iter; if (tof < m_t1min * (L1 + L2) / L1) tof -= min_t0_next; else tof -= CalculateT0elastic(tof, L1 + L2, E1, parser); - *iter = tof; + iter = tof; } MantidVec tofs = evlist.getTofs(); - for (unsigned int itof = 0; itof < tofs.size(); itof++) { + for (double &itof : tofs) { // add a [-0.1,0.1] microsecond noise to avoid artifacts // resulting from original tof data - tof = tofs[itof]; + tof = itof; if (tof < m_t1min * (L1 + L2) / L1) tof -= min_t0_next; else tof -= CalculateT0elastic(tof, L1 + L2, E1, parser); - tofs[itof] = tof; + itof = tof; } evlist.setTofs(tofs); evlist.setSortOrder(Mantid::DataObjects::EventSortType::UNSORTED); @@ -403,13 +403,13 @@ void ModeratorTzero::execEvent(const std::string &emode) { else if (emode == "Direct") { // fix the histogram bins MantidVec &x = evlist.dataX(); - for (auto iter = x.begin(); iter != x.end(); ++iter) { - *iter -= t0_direct; + for (double &iter : x) { + iter -= t0_direct; } MantidVec tofs = evlist.getTofs(); - for (unsigned int itof = 0; itof < tofs.size(); itof++) { - tofs[itof] -= t0_direct; + for (double &tof : tofs) { + tof -= t0_direct; } evlist.setTofs(tofs); evlist.setSortOrder(Mantid::DataObjects::EventSortType::UNSORTED); diff --git a/Framework/Algorithms/src/MonteCarloAbsorption.cpp b/Framework/Algorithms/src/MonteCarloAbsorption.cpp index e482d090fbe..ad438721cf0 100644 --- a/Framework/Algorithms/src/MonteCarloAbsorption.cpp +++ b/Framework/Algorithms/src/MonteCarloAbsorption.cpp @@ -296,10 +296,9 @@ bool MonteCarloAbsorption::attenuationFactor(const V3D &startPos, m_container->interceptSurfaces(beforeScatter); } // Attenuation factor is product of factor for each material - for (auto citr = beforeScatter.cbegin(); citr != beforeScatter.cend(); - ++citr) { - length = citr->distInsideObject; - factor *= attenuation(length, citr->object->material(), lambda); + for (const auto &citr : beforeScatter) { + length = citr.distInsideObject; + factor *= attenuation(length, citr.object->material(), lambda); } length = afterScatter.cbegin()->distInsideObject; @@ -310,9 +309,9 @@ bool MonteCarloAbsorption::attenuationFactor(const V3D &startPos, m_container->interceptSurfaces(afterScatter); } // Attenuation factor is product of factor for each material - for (auto citr = afterScatter.cbegin(); citr != afterScatter.cend(); ++citr) { - length = citr->distInsideObject; - factor *= attenuation(length, citr->object->material(), lambda); + for (const auto &citr : afterScatter) { + length = citr.distInsideObject; + factor *= attenuation(length, citr.object->material(), lambda); } return true; diff --git a/Framework/Algorithms/src/MuonGroupDetectors.cpp b/Framework/Algorithms/src/MuonGroupDetectors.cpp index 105188cee04..02410fb8df3 100644 --- a/Framework/Algorithms/src/MuonGroupDetectors.cpp +++ b/Framework/Algorithms/src/MuonGroupDetectors.cpp @@ -106,20 +106,20 @@ void MuonGroupDetectors::exec() { // We will be setting them anew outWS->getSpectrum(groupIndex)->clearDetectorIDs(); - for (auto detIt = wsIndices.begin(); detIt != wsIndices.end(); detIt++) { + for (unsigned long &wsIndice : wsIndices) { for (size_t i = 0; i < inWS->blocksize(); ++i) { // Sum the y values - outWS->dataY(groupIndex)[i] += inWS->dataY(*detIt)[i]; + outWS->dataY(groupIndex)[i] += inWS->dataY(wsIndice)[i]; // Sum the errors in quadrature outWS->dataE(groupIndex)[i] = sqrt(pow(outWS->dataE(groupIndex)[i], 2) + - pow(inWS->dataE(*detIt)[i], 2)); + pow(inWS->dataE(wsIndice)[i], 2)); } // Detectors list of the group should contain all the detectors of it's // elements outWS->getSpectrum(groupIndex) - ->addDetectorIDs(inWS->getSpectrum(*detIt)->getDetectorIDs()); + ->addDetectorIDs(inWS->getSpectrum(wsIndice)->getDetectorIDs()); } // Using the first detector X values diff --git a/Framework/Algorithms/src/NormaliseByDetector.cpp b/Framework/Algorithms/src/NormaliseByDetector.cpp index 888e50ba6c0..c4b7dc5f043 100644 --- a/Framework/Algorithms/src/NormaliseByDetector.cpp +++ b/Framework/Algorithms/src/NormaliseByDetector.cpp @@ -116,9 +116,9 @@ void NormaliseByDetector::processHistogram(size_t wsIndex, ParamNames allParamNames = function->getParameterNames(); // Lookup each parameter name. - for (auto it = allParamNames.begin(); it != allParamNames.end(); ++it) { + for (auto &allParamName : allParamNames) { Geometry::Parameter_sptr param = - paramMap.getRecursive(&(*det), (*it), type); + paramMap.getRecursive(&(*det), allParamName, type); const Geometry::FitParameter &fitParam = tryParseFunctionParameter(param, det); diff --git a/Framework/Algorithms/src/PDDetermineCharacterizations.cpp b/Framework/Algorithms/src/PDDetermineCharacterizations.cpp index cfe72202b66..e9c22e5e824 100644 --- a/Framework/Algorithms/src/PDDetermineCharacterizations.cpp +++ b/Framework/Algorithms/src/PDDetermineCharacterizations.cpp @@ -90,10 +90,10 @@ PDDetermineCharacterizations::validateInputs() { << expectedNames.size(); result[CHAR_PROP_NAME] = msg.str(); } else { - for (auto it = expectedNames.begin(); it != expectedNames.end(); ++it) { - if (std::find(names.begin(), names.end(), *it) == names.end()) { + for (auto &expectedName : expectedNames) { + if (std::find(names.begin(), names.end(), expectedName) == names.end()) { std::stringstream msg; - msg << "Failed to find column named " << (*it); + msg << "Failed to find column named " << expectedName; result[CHAR_PROP_NAME] = msg.str(); } } @@ -230,26 +230,26 @@ double PDDetermineCharacterizations::getLogValue(API::Run &run, validUnits.insert("Hz"); } - for (auto name = names.begin(); name != names.end(); ++name) { - if (run.hasProperty(*name)) { - const std::string units = run.getProperty(*name)->units(); + for (auto &name : names) { + if (run.hasProperty(name)) { + const std::string units = run.getProperty(name)->units(); if (validUnits.find(units) != validUnits.end()) { - double value = run.getLogAsSingleValue(*name); + double value = run.getLogAsSingleValue(name); if (value == 0.) { std::stringstream msg; - msg << "'" << *name << "' has a mean value of zero " << units; + msg << "'" << name << "' has a mean value of zero " << units; g_log.information(msg.str()); } else { std::stringstream msg; - msg << "Found " << label << " in log '" << *name + msg << "Found " << label << " in log '" << name << "' with mean value " << value << " " << units; g_log.information(msg.str()); return value; } } else { std::stringstream msg; - msg << "When looking at " << *name + msg << "When looking at " << name << " log encountered unknown units for " << label << ":" << units; g_log.warning(msg.str()); } @@ -352,12 +352,13 @@ void PDDetermineCharacterizations::exec() { overrideRunNumProperty("NormBackRun", "empty"); std::vector<std::string> expectedNames = getColumnNames(); - for (auto it = expectedNames.begin(); it != expectedNames.end(); ++it) { - if (m_propertyManager->existsProperty(*it)) { - g_log.debug() << (*it) << ":" << m_propertyManager->getPropertyValue(*it) + for (auto &expectedName : expectedNames) { + if (m_propertyManager->existsProperty(expectedName)) { + g_log.debug() << expectedName << ":" + << m_propertyManager->getPropertyValue(expectedName) << "\n"; } else { - g_log.warning() << (*it) << " DOES NOT EXIST\n"; + g_log.warning() << expectedName << " DOES NOT EXIST\n"; } } } diff --git a/Framework/Algorithms/src/PerformIndexOperations.cpp b/Framework/Algorithms/src/PerformIndexOperations.cpp index b8bdb32c058..d8df6486947 100644 --- a/Framework/Algorithms/src/PerformIndexOperations.cpp +++ b/Framework/Algorithms/src/PerformIndexOperations.cpp @@ -318,13 +318,9 @@ VecCommands interpret(const std::string &processingInstructions) { commandParsers.push_back(boost::make_shared<AdditionParser>()); VecCommands commands; - for (auto it = processingInstructionsSplit.begin(); - it != processingInstructionsSplit.end(); ++it) { - const std::string candidate = *it; + for (auto candidate : processingInstructionsSplit) { bool parserFound = false; - for (auto parserIt = commandParsers.begin(); - parserIt != commandParsers.end(); ++parserIt) { - auto commandParser = *parserIt; + for (auto commandParser : commandParsers) { Command *command = commandParser->interpret(candidate); boost::shared_ptr<Command> commandSptr(command); if (commandSptr->isValid()) // Do not record invalid commands. diff --git a/Framework/Algorithms/src/PlotAsymmetryByLogValue.cpp b/Framework/Algorithms/src/PlotAsymmetryByLogValue.cpp index d3a84a50436..48ed2974bbb 100644 --- a/Framework/Algorithms/src/PlotAsymmetryByLogValue.cpp +++ b/Framework/Algorithms/src/PlotAsymmetryByLogValue.cpp @@ -387,29 +387,29 @@ void PlotAsymmetryByLogValue::populateOutputWorkspace( auto tAxis = new TextAxis(nplots); if (nplots == 1) { size_t i = 0; - for (auto it = m_logValue.begin(); it != m_logValue.end(); ++it) { - outWS->dataX(0)[i] = it->second; - outWS->dataY(0)[i] = m_redY[it->first]; - outWS->dataE(0)[i] = m_redE[it->first]; + for (auto &it : m_logValue) { + outWS->dataX(0)[i] = it.second; + outWS->dataY(0)[i] = m_redY[it.first]; + outWS->dataE(0)[i] = m_redE[it.first]; i++; } tAxis->setLabel(0, "Asymmetry"); } else { size_t i = 0; - for (auto it = m_logValue.begin(); it != m_logValue.end(); ++it) { - outWS->dataX(0)[i] = it->second; - outWS->dataY(0)[i] = m_diffY[it->first]; - outWS->dataE(0)[i] = m_diffE[it->first]; - outWS->dataX(1)[i] = it->second; - outWS->dataY(1)[i] = m_redY[it->first]; - outWS->dataE(1)[i] = m_redE[it->first]; - outWS->dataX(2)[i] = it->second; - outWS->dataY(2)[i] = m_greenY[it->first]; - outWS->dataE(2)[i] = m_greenE[it->first]; - outWS->dataX(3)[i] = it->second; - outWS->dataY(3)[i] = m_sumY[it->first]; - outWS->dataE(3)[i] = m_sumE[it->first]; + for (auto &it : m_logValue) { + outWS->dataX(0)[i] = it.second; + outWS->dataY(0)[i] = m_diffY[it.first]; + outWS->dataE(0)[i] = m_diffE[it.first]; + outWS->dataX(1)[i] = it.second; + outWS->dataY(1)[i] = m_redY[it.first]; + outWS->dataE(1)[i] = m_redE[it.first]; + outWS->dataX(2)[i] = it.second; + outWS->dataY(2)[i] = m_greenY[it.first]; + outWS->dataE(2)[i] = m_greenE[it.first]; + outWS->dataX(3)[i] = it.second; + outWS->dataY(3)[i] = m_sumY[it.first]; + outWS->dataE(3)[i] = m_sumE[it.first]; i++; } tAxis->setLabel(0, "Red-Green"); @@ -431,20 +431,20 @@ void PlotAsymmetryByLogValue::saveResultsToADS(MatrixWorkspace_sptr &outWS, if (nplots == 2) { size_t i = 0; - for (auto it = m_logValue.begin(); it != m_logValue.end(); ++it) { - size_t run = it->first; + for (auto &it : m_logValue) { + size_t run = it.first; outWS->dataX(0)[i] = static_cast<double>(run); // run number - outWS->dataY(0)[i] = it->second; // log value + outWS->dataY(0)[i] = it.second; // log value outWS->dataY(1)[i] = m_redY[run]; // redY outWS->dataE(1)[i] = m_redE[run]; // redE i++; } } else { size_t i = 0; - for (auto it = m_logValue.begin(); it != m_logValue.end(); ++it) { - size_t run = it->first; + for (auto &it : m_logValue) { + size_t run = it.first; outWS->dataX(0)[i] = static_cast<double>(run); // run number - outWS->dataY(0)[i] = it->second; // log value + outWS->dataY(0)[i] = it.second; // log value outWS->dataY(1)[i] = m_diffY[run]; // diffY outWS->dataE(1)[i] = m_diffE[run]; // diffE outWS->dataY(2)[i] = m_redY[run]; // redY diff --git a/Framework/Algorithms/src/PointByPointVCorrection.cpp b/Framework/Algorithms/src/PointByPointVCorrection.cpp index 19bddb05cf7..243d7c7f24b 100644 --- a/Framework/Algorithms/src/PointByPointVCorrection.cpp +++ b/Framework/Algorithms/src/PointByPointVCorrection.cpp @@ -110,9 +110,9 @@ void PointByPointVCorrection::exec() { // builds which caused the unit tests // to sometimes fail. Maybe this is some compiler bug to do with // using bind2nd within the parrallel macros. - for (auto rY = resultY.begin(); rY != resultY.end(); ++rY) { - *rY *= factor; // Now result is s_i/v_i*Dlam_i*(sum_i s_i)/(sum_i - // S_i/v_i*Dlam_i) + for (double &rY : resultY) { + rY *= factor; // Now result is s_i/v_i*Dlam_i*(sum_i s_i)/(sum_i + // S_i/v_i*Dlam_i) } // Finally get the normalized errors diff --git a/Framework/Algorithms/src/PolarizationCorrection.cpp b/Framework/Algorithms/src/PolarizationCorrection.cpp index 8e6c8e57b0f..7ca478559d0 100644 --- a/Framework/Algorithms/src/PolarizationCorrection.cpp +++ b/Framework/Algorithms/src/PolarizationCorrection.cpp @@ -399,18 +399,17 @@ void PolarizationCorrection::exec() { loadableProperties[cAlphaLabel()] = "calpha"; } - for (auto propName = loadableProperties.begin(); - propName != loadableProperties.end(); ++propName) { - Property *prop = getProperty(propName->first); + for (auto &loadablePropertie : loadableProperties) { + Property *prop = getProperty(loadablePropertie.first); if (!prop) continue; if (prop->isDefault()) { - auto vals = instrument->getStringParameter(propName->second); + auto vals = instrument->getStringParameter(loadablePropertie.second); if (vals.empty()) throw std::runtime_error( - "Cannot find value for " + propName->first + + "Cannot find value for " + loadablePropertie.first + " in parameter file. Please specify this property manually."); prop->setValue(vals[0]); } diff --git a/Framework/Algorithms/src/Q1DWeighted.cpp b/Framework/Algorithms/src/Q1DWeighted.cpp index 806211eb597..8c2c1068bd0 100644 --- a/Framework/Algorithms/src/Q1DWeighted.cpp +++ b/Framework/Algorithms/src/Q1DWeighted.cpp @@ -331,8 +331,8 @@ void Q1DWeighted::exec() { // Create workspace group that holds output workspaces WorkspaceGroup_sptr wsgroup = WorkspaceGroup_sptr(new WorkspaceGroup()); - for (auto it = wedgeWorkspaces.begin(); it != wedgeWorkspaces.end(); ++it) { - wsgroup->addWorkspace(*it); + for (auto &wedgeWorkspace : wedgeWorkspaces) { + wsgroup->addWorkspace(wedgeWorkspace); } // set the output property std::string outputWSGroupName = getPropertyValue("WedgeWorkspace"); diff --git a/Framework/Algorithms/src/Qxy.cpp b/Framework/Algorithms/src/Qxy.cpp index b791d857ac1..91432132ff8 100644 --- a/Framework/Algorithms/src/Qxy.cpp +++ b/Framework/Algorithms/src/Qxy.cpp @@ -297,8 +297,8 @@ void Qxy::exec() { // left to be executed here for computational efficiency size_t numHist = weights->getNumberHistograms(); for (size_t i = 0; i < numHist; i++) { - for (size_t j = 0; j < weights->dataE(i).size(); j++) { - weights->dataE(i)[j] = sqrt(weights->dataE(i)[j]); + for (double &j : weights->dataE(i)) { + j = sqrt(j); } } diff --git a/Framework/Algorithms/src/ReadGroupsFromFile.cpp b/Framework/Algorithms/src/ReadGroupsFromFile.cpp index 7d577056aa5..448ab818b52 100644 --- a/Framework/Algorithms/src/ReadGroupsFromFile.cpp +++ b/Framework/Algorithms/src/ReadGroupsFromFile.cpp @@ -225,11 +225,11 @@ void ReadGroupsFromFile::readXMLGroupingFile(const std::string &filename) { Poco::StringTokenizer data(ids, ",", Poco::StringTokenizer::TOK_TRIM); if (data.begin() != data.end()) { - for (auto it = data.begin(); it != data.end(); ++it) { + for (const auto &it : data) { // cast the string to an int int detID; try { - detID = boost::lexical_cast<int>(*it); + detID = boost::lexical_cast<int>(it); } catch (boost::bad_lexical_cast &) { throw Mantid::Kernel::Exception::FileError( "Could cast string to integer in input XML file", filename); diff --git a/Framework/Algorithms/src/RecordPythonScript.cpp b/Framework/Algorithms/src/RecordPythonScript.cpp index 0469964d4cb..4edce938b15 100644 --- a/Framework/Algorithms/src/RecordPythonScript.cpp +++ b/Framework/Algorithms/src/RecordPythonScript.cpp @@ -74,13 +74,13 @@ void RecordPythonScript::startingHandle(API::IAlgorithm_sptr alg) { auto props = alg->getProperties(); std::string algString; - for (auto p = props.begin(); p != props.end(); ++p) { + for (auto &prop : props) { std::string opener = "='"; - if ((**p).value().find('\\') != std::string::npos) { + if ((*prop).value().find('\\') != std::string::npos) { opener = "=r'"; } - std::string paramString = (**p).name() + opener + (**p).value() + "'"; + std::string paramString = (*prop).name() + opener + (*prop).value() + "'"; // Miss out parameters that are empty. if (paramString.length() != 0) { diff --git a/Framework/Algorithms/src/ReflectometryReductionOne.cpp b/Framework/Algorithms/src/ReflectometryReductionOne.cpp index 9640658dc1d..da6c000882f 100644 --- a/Framework/Algorithms/src/ReflectometryReductionOne.cpp +++ b/Framework/Algorithms/src/ReflectometryReductionOne.cpp @@ -288,9 +288,9 @@ ReflectometryReductionOne::correctPosition(API::MatrixWorkspace_sptr &toCorrect, } else { auto specNumbers = getSpectrumNumbers(toCorrect); correctPosAlg->setProperty("SpectrumNumbersOfDetectors", specNumbers); - for (size_t t = 0; t < specNumbers.size(); ++t) { + for (int specNumber : specNumbers) { std::stringstream buffer; - buffer << "Writing out: " << specNumbers[t]; + buffer << "Writing out: " << specNumber; g_log.notice(buffer.str()); } } diff --git a/Framework/Algorithms/src/ReflectometryReductionOneAuto.cpp b/Framework/Algorithms/src/ReflectometryReductionOneAuto.cpp index 14bfa03542a..4368d810f07 100644 --- a/Framework/Algorithms/src/ReflectometryReductionOneAuto.cpp +++ b/Framework/Algorithms/src/ReflectometryReductionOneAuto.cpp @@ -583,11 +583,11 @@ bool ReflectometryReductionOneAuto::processGroups() { // Copy all the non-workspace properties over std::vector<Property *> props = this->getProperties(); - for (auto prop = props.begin(); prop != props.end(); ++prop) { - if (*prop) { - IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(*prop); + for (auto &prop : props) { + if (prop) { + IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(prop); if (!wsProp) - alg->setPropertyValue((*prop)->name(), (*prop)->value()); + alg->setPropertyValue(prop->name(), prop->value()); } } diff --git a/Framework/Algorithms/src/RemoveBackground.cpp b/Framework/Algorithms/src/RemoveBackground.cpp index 54df033197e..8aca197a4de 100644 --- a/Framework/Algorithms/src/RemoveBackground.cpp +++ b/Framework/Algorithms/src/RemoveBackground.cpp @@ -168,10 +168,10 @@ BackgroundHelper::~BackgroundHelper() { this->deleteUnitsConverters(); } /** The method deletes all units converter allocated*/ void BackgroundHelper::deleteUnitsConverters() { - for (size_t i = 0; i < m_WSUnit.size(); i++) { - if (m_WSUnit[i]) { - delete m_WSUnit[i]; - m_WSUnit[i] = NULL; + for (auto &i : m_WSUnit) { + if (i) { + delete i; + i = NULL; } } } diff --git a/Framework/Algorithms/src/RemoveLowResTOF.cpp b/Framework/Algorithms/src/RemoveLowResTOF.cpp index c56d99b7c4f..928d69ea755 100644 --- a/Framework/Algorithms/src/RemoveLowResTOF.cpp +++ b/Framework/Algorithms/src/RemoveLowResTOF.cpp @@ -308,8 +308,8 @@ double RemoveLowResTOF::calcTofMin(const std::size_t workspaceIndex) { } } else { double l2 = 0; - for (auto it = detSet.cbegin(); it != detSet.cend(); ++it) { - l2 += m_instrument->getDetector(*it)->getDistance(*m_sample); + for (value_type it : detSet) { + l2 += m_instrument->getDetector(it)->getDistance(*m_sample); } l2 /= static_cast<double>(detSet.size()); diff --git a/Framework/Algorithms/src/RemovePromptPulse.cpp b/Framework/Algorithms/src/RemovePromptPulse.cpp index ae43e1db8db..a4e52853fe7 100644 --- a/Framework/Algorithms/src/RemovePromptPulse.cpp +++ b/Framework/Algorithms/src/RemovePromptPulse.cpp @@ -122,15 +122,15 @@ void RemovePromptPulse::exec() { return; } g_log.information() << "Calculated prompt pulses at "; - for (size_t i = 0; i < pulseTimes.size(); ++i) - g_log.information() << pulseTimes[i] << " "; + for (double pulseTime : pulseTimes) + g_log.information() << pulseTime << " "; g_log.information() << " microseconds\n"; MatrixWorkspace_sptr outputWS; - for (auto left = pulseTimes.begin(); left != pulseTimes.end(); ++left) { - double right = (*left) + width; + for (double &pulseTime : pulseTimes) { + double right = pulseTime + width; - g_log.notice() << "Filtering tmin=" << *left << ", tmax=" << right + g_log.notice() << "Filtering tmin=" << pulseTime << ", tmax=" << right << " microseconds\n"; // run maskbins to do the work on the first prompt pulse @@ -147,7 +147,7 @@ void RemovePromptPulse::exec() { } // always write to correct output workspace algo->setProperty<MatrixWorkspace_sptr>("OutputWorkspace", outputWS); - algo->setProperty<double>("XMin", *left); + algo->setProperty<double>("XMin", pulseTime); algo->setProperty<double>("XMax", right); algo->executeAsChildAlg(); diff --git a/Framework/Algorithms/src/ResetNegatives.cpp b/Framework/Algorithms/src/ResetNegatives.cpp index 8e3d93ed905..1438acffb84 100644 --- a/Framework/Algorithms/src/ResetNegatives.cpp +++ b/Framework/Algorithms/src/ResetNegatives.cpp @@ -153,8 +153,8 @@ void ResetNegatives::pushMinimum(MatrixWorkspace_const_sptr minWS, if (minValue <= 0) { minValue *= -1.; MantidVec &y = wksp->dataY(i); - for (auto it = y.begin(); it != y.end(); ++it) { - *it = fixZero(*it + minValue); + for (double &it : y) { + it = fixZero(it + minValue); } } prog.report(); @@ -184,11 +184,11 @@ void ResetNegatives::changeNegatives(MatrixWorkspace_const_sptr minWS, 0.) // quick check to see if there is a reason to bother { MantidVec &y = wksp->dataY(i); - for (auto it = y.begin(); it != y.end(); ++it) { - if (*it < 0.) { - *it = value; + for (double &it : y) { + if (it < 0.) { + it = value; } else - *it = fixZero(*it); + it = fixZero(it); } } prog.report(); diff --git a/Framework/Algorithms/src/SetInstrumentParameter.cpp b/Framework/Algorithms/src/SetInstrumentParameter.cpp index 63a006dedbe..22fc1fb55bb 100644 --- a/Framework/Algorithms/src/SetInstrumentParameter.cpp +++ b/Framework/Algorithms/src/SetInstrumentParameter.cpp @@ -103,13 +103,13 @@ void SetInstrumentParameter::exec() { auto ¶mMap = ws->instrumentParameters(); if (!dets.empty()) { - for (auto it = dets.begin(); it != dets.end(); ++it) { - addParameter(paramMap, (*it).get(), paramName, paramType, paramValue); + for (auto &det : dets) { + addParameter(paramMap, det.get(), paramName, paramType, paramValue); } } else { if (cmptList.size() > 0) { - for (auto it = cmptList.begin(); it != cmptList.end(); ++it) { - addParameter(paramMap, it->get(), paramName, paramType, paramValue); + for (auto &it : cmptList) { + addParameter(paramMap, it.get(), paramName, paramType, paramValue); } } else { g_log.warning("Could not find the component requested."); diff --git a/Framework/Algorithms/src/SmoothNeighbours.cpp b/Framework/Algorithms/src/SmoothNeighbours.cpp index 63d82f54b68..3273390e09e 100644 --- a/Framework/Algorithms/src/SmoothNeighbours.cpp +++ b/Framework/Algorithms/src/SmoothNeighbours.cpp @@ -299,8 +299,8 @@ void SmoothNeighbours::findNeighboursRectangular() { // Adjust the weights of each neighbour to normalize to unity if (!sum || expandSumAllPixels) - for (size_t q = 0; q < neighbours.size(); q++) - neighbours[q].second /= totalWeight; + for (auto &neighbour : neighbours) + neighbour.second /= totalWeight; // Save the list of neighbours for this output workspace index. m_neighbours[outWI] = neighbours; @@ -399,11 +399,11 @@ void SmoothNeighbours::findNeighboursUbiqutious() { std::vector<weightedNeighbour> neighbours; // Convert from spectrum numbers to workspace indices - for (auto it = neighbSpectra.begin(); it != neighbSpectra.end(); ++it) { - specid_t spec = it->first; + for (auto &it : neighbSpectra) { + specid_t spec = it.first; // Use the weighting strategy to calculate the weight. - double weight = WeightedSum->weightAt(it->second); + double weight = WeightedSum->weightAt(it.second); if (weight > 0) { // Find the corresponding workspace index @@ -433,8 +433,8 @@ void SmoothNeighbours::findNeighboursUbiqutious() { // Adjust the weights of each neighbour to normalize to unity if (sum == 1) - for (size_t q = 0; q < neighbours.size(); q++) - neighbours[q].second /= totalWeight; + for (auto &neighbour : neighbours) + neighbour.second /= totalWeight; // Save the list of neighbours for this output workspace index. m_neighbours[outWI] = neighbours; @@ -542,8 +542,8 @@ Check whether the properties provided are all in their default state. */ bool areAllDefault(ConstVecProperties &properties) { bool areAllDefault = false; - for (auto it = properties.cbegin(); it != properties.cend(); ++it) { - if (!(*it)->isDefault()) { + for (auto propertie : properties) { + if (!propertie->isDefault()) { return areAllDefault; } } diff --git a/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp b/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp index 098707270cd..dd2623c9601 100644 --- a/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp +++ b/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp @@ -338,8 +338,8 @@ void SofQWNormalisedPolygon::initAngularCachesPSD( specid_t deltaPlusT = inSpec + this->m_detNeighbourOffset; specid_t deltaMinusT = inSpec - this->m_detNeighbourOffset; - for (auto it = neighbours.begin(); it != neighbours.end(); ++it) { - specid_t spec = it->first; + for (auto &neighbour : neighbours) { + specid_t spec = neighbour.first; g_log.debug() << "Neighbor ID: " << spec << std::endl; if (spec == deltaPlus1 || spec == deltaMinus1 || spec == deltaPlusT || spec == deltaMinusT) { diff --git a/Framework/Algorithms/src/SpatialGrouping.cpp b/Framework/Algorithms/src/SpatialGrouping.cpp index 64129a296ec..26fda5f20d9 100644 --- a/Framework/Algorithms/src/SpatialGrouping.cpp +++ b/Framework/Algorithms/src/SpatialGrouping.cpp @@ -82,13 +82,13 @@ void SpatialGrouping::exec() { Mantid::API::Progress prog(this, 0.0, 1.0, m_detectors.size()); - for (auto detIt = m_detectors.begin(); detIt != m_detectors.end(); ++detIt) { + for (auto &m_detector : m_detectors) { prog.report(); // The detector - Mantid::Geometry::IDetector_const_sptr det = detIt->second; + Mantid::Geometry::IDetector_const_sptr det = m_detector.second; // The spectrum number of the detector - specid_t specNo = detIt->first; + specid_t specNo = m_detector.first; // We are not interested in Monitors and we don't want them to be included // in @@ -174,8 +174,8 @@ void SpatialGrouping::exec() { inputWorkspace->getIndexFromSpectrumNumber((*grpIt)[i]); const std::set<detid_t> &detIds = inputWorkspace->getSpectrum(workspaceIndex)->getDetectorIDs(); - for (auto it = detIds.cbegin(); it != detIds.cend(); ++it) { - xml << "," << (*it); + for (value_type detId : detIds) { + xml << "," << detId; } } xml << "\"/></group>\n"; @@ -212,45 +212,45 @@ bool SpatialGrouping::expandNet( if (incoming == 0) { potentials = inputWorkspace->getNeighbours(det.get()); } else { - for (auto nrsIt = nearest.begin(); nrsIt != nearest.end(); ++nrsIt) { + for (auto &nrsIt : nearest) { std::map<specid_t, Mantid::Kernel::V3D> results; - results = inputWorkspace->getNeighbours(m_detectors[nrsIt->first].get()); - for (auto resIt = results.begin(); resIt != results.end(); ++resIt) { - potentials[resIt->first] = resIt->second; + results = inputWorkspace->getNeighbours(m_detectors[nrsIt.first].get()); + for (auto &result : results) { + potentials[result.first] = result.second; } } } - for (auto potIt = potentials.begin(); potIt != potentials.end(); ++potIt) { + for (auto &potential : potentials) { // We do not want to include the detector in it's own list of nearest // neighbours - if (potIt->first == spec) { + if (potential.first == spec) { continue; } // Or detectors that are already in the nearest list passed into this // function - auto nrsIt = nearest.find(potIt->first); + auto nrsIt = nearest.find(potential.first); if (nrsIt != nearest.end()) { continue; } // We should not include detectors already included in a group (or monitors // for that matter) - auto inclIt = m_included.find(potIt->first); + auto inclIt = m_included.find(potential.first); if (inclIt != m_included.end()) { continue; } // If we get this far, we need to determine if the detector is of a suitable // distance - Mantid::Kernel::V3D pos = m_detectors[potIt->first]->getPos(); + Mantid::Kernel::V3D pos = m_detectors[potential.first]->getPos(); if (!bbox.isPointInside(pos)) { continue; } // Elsewise, it's all good. - nearest[potIt->first] = potIt->second; + nearest[potential.first] = potential.second; } if (nearest.size() == incoming) { diff --git a/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp b/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp index dde76efc181..9477361b64a 100644 --- a/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp +++ b/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp @@ -165,9 +165,9 @@ SpecularReflectionAlgorithm::getDetectorComponent( auto specToWorkspaceIndex = workspace->getSpectrumToWorkspaceIndexMap(); DetectorGroup_sptr allDetectors = boost::make_shared<DetectorGroup>(); bool warnIfMasked = true; - for (size_t i = 0; i < spectrumNumbers.size(); ++i) { - const size_t &spectrumNumber = spectrumNumbers[i]; - auto it = specToWorkspaceIndex.find(spectrumNumbers[i]); + for (int i : spectrumNumbers) { + const size_t &spectrumNumber = i; + auto it = specToWorkspaceIndex.find(i); if (it == specToWorkspaceIndex.end()) { std::stringstream message; message << "Spectrum number " << spectrumNumber diff --git a/Framework/Algorithms/src/SpecularReflectionPositionCorrect.cpp b/Framework/Algorithms/src/SpecularReflectionPositionCorrect.cpp index 4568bc47655..f4815b2314e 100644 --- a/Framework/Algorithms/src/SpecularReflectionPositionCorrect.cpp +++ b/Framework/Algorithms/src/SpecularReflectionPositionCorrect.cpp @@ -163,8 +163,8 @@ void SpecularReflectionPositionCorrect::moveDetectors( /* * We have to move individual components. */ - for (size_t i = 0; i < detectors.size(); ++i) { - moveDetectors(toCorrect, detectors[i], sample, upOffset, acrossOffset, + for (const auto &detector : detectors) { + moveDetectors(toCorrect, detector, sample, upOffset, acrossOffset, detectorPosition); // Recursive call } } diff --git a/Framework/Algorithms/src/Stitch1D.cpp b/Framework/Algorithms/src/Stitch1D.cpp index 6ee41612d24..aa26f4c4175 100644 --- a/Framework/Algorithms/src/Stitch1D.cpp +++ b/Framework/Algorithms/src/Stitch1D.cpp @@ -638,20 +638,20 @@ void Stitch1D::reinsertSpecialValues(MatrixWorkspace_sptr ws) { // Copy over the data MantidVec &sourceY = ws->dataY(i); - for (size_t j = 0; j < m_nanYIndexes[i].size(); ++j) { - sourceY[m_nanYIndexes[i][j]] = std::numeric_limits<double>::quiet_NaN(); + for (unsigned long j : m_nanYIndexes[i]) { + sourceY[j] = std::numeric_limits<double>::quiet_NaN(); } - for (size_t j = 0; j < m_infYIndexes[i].size(); ++j) { - sourceY[m_infYIndexes[i][j]] = std::numeric_limits<double>::infinity(); + for (unsigned long j : m_infYIndexes[i]) { + sourceY[j] = std::numeric_limits<double>::infinity(); } - for (size_t j = 0; j < m_nanEIndexes[i].size(); ++j) { - sourceY[m_nanEIndexes[i][j]] = std::numeric_limits<double>::quiet_NaN(); + for (unsigned long j : m_nanEIndexes[i]) { + sourceY[j] = std::numeric_limits<double>::quiet_NaN(); } - for (size_t j = 0; j < m_infEIndexes[i].size(); ++j) { - sourceY[m_infEIndexes[i][j]] = std::numeric_limits<double>::infinity(); + for (unsigned long j : m_infEIndexes[i]) { + sourceY[j] = std::numeric_limits<double>::infinity(); } PARALLEL_END_INTERUPT_REGION diff --git a/Framework/Algorithms/src/Stitch1DMany.cpp b/Framework/Algorithms/src/Stitch1DMany.cpp index da43501fa7b..c362e4585eb 100644 --- a/Framework/Algorithms/src/Stitch1DMany.cpp +++ b/Framework/Algorithms/src/Stitch1DMany.cpp @@ -71,13 +71,12 @@ std::map<std::string, std::string> Stitch1DMany::validateInputs() { if (inputWorkspacesStr.size() < 2) errors["InputWorkspaces"] = "At least 2 input workspaces required."; - for (auto ws = inputWorkspacesStr.begin(); ws != inputWorkspacesStr.end(); - ++ws) { - if (AnalysisDataService::Instance().doesExist(*ws)) { + for (const auto &ws : inputWorkspacesStr) { + if (AnalysisDataService::Instance().doesExist(ws)) { m_inputWorkspaces.push_back( - AnalysisDataService::Instance().retrieveWS<Workspace>(*ws)); + AnalysisDataService::Instance().retrieveWS<Workspace>(ws)); } else { - errors["InputWorkspaces"] = *ws + " is not a valid workspace."; + errors["InputWorkspaces"] = ws + " is not a valid workspace."; break; } } @@ -85,9 +84,8 @@ std::map<std::string, std::string> Stitch1DMany::validateInputs() { // Check that all the workspaces are of the same type if (m_inputWorkspaces.size() > 0) { const std::string id = m_inputWorkspaces[0]->id(); - for (auto it = m_inputWorkspaces.begin(); it != m_inputWorkspaces.end(); - ++it) { - if ((*it)->id() != id) { + for (auto &m_inputWorkspace : m_inputWorkspaces) { + if (m_inputWorkspace->id() != id) { errors["InputWorkspaces"] = "All workspaces must be the same type."; break; } @@ -98,10 +96,9 @@ std::map<std::string, std::string> Stitch1DMany::validateInputs() { boost::dynamic_pointer_cast<WorkspaceGroup>(m_inputWorkspaces[0]); if (firstGroup) { size_t groupSize = firstGroup->size(); - for (auto it = m_inputWorkspaces.begin(); it != m_inputWorkspaces.end(); - ++it) { + for (auto &m_inputWorkspace : m_inputWorkspaces) { WorkspaceGroup_sptr group = - boost::dynamic_pointer_cast<WorkspaceGroup>(*it); + boost::dynamic_pointer_cast<WorkspaceGroup>(m_inputWorkspace); if (group->size() != groupSize) { errors["InputWorkspaces"] = "All group workspaces must be the same size."; @@ -183,9 +180,8 @@ void Stitch1DMany::exec() { if (!isChild()) { // Copy each input workspace's history into our output workspace's history - for (auto inWS = m_inputWorkspaces.begin(); - inWS != m_inputWorkspaces.end(); ++inWS) - lhsWS->history().addHistory((*inWS)->getHistory()); + for (auto &m_inputWorkspace : m_inputWorkspaces) + lhsWS->history().addHistory(m_inputWorkspace->getHistory()); } // We're a child algorithm, but we're recording history anyway else if (isRecordingHistoryForChild() && m_parentHistory) { @@ -197,10 +193,9 @@ void Stitch1DMany::exec() { // We're dealing with group workspaces else { std::vector<WorkspaceGroup_sptr> groupWorkspaces; - for (auto it = m_inputWorkspaces.begin(); it != m_inputWorkspaces.end(); - ++it) + for (auto &m_inputWorkspace : m_inputWorkspaces) groupWorkspaces.push_back( - boost::dynamic_pointer_cast<WorkspaceGroup>(*it)); + boost::dynamic_pointer_cast<WorkspaceGroup>(m_inputWorkspace)); // List of workspaces to be grouped std::vector<std::string> toGroup; @@ -215,8 +210,8 @@ void Stitch1DMany::exec() { // The name of the resulting workspace std::string outName = groupName; - for (size_t j = 0; j < groupWorkspaces.size(); ++j) { - const std::string wsName = groupWorkspaces[j]->getItem(i)->name(); + for (auto &groupWorkspace : groupWorkspaces) { + const std::string wsName = groupWorkspace->getItem(i)->name(); toProcess.push_back(wsName); outName += "_" + wsName; } diff --git a/Framework/Algorithms/src/SumEventsByLogValue.cpp b/Framework/Algorithms/src/SumEventsByLogValue.cpp index 48f47cff4a6..8e2abbfda47 100644 --- a/Framework/Algorithms/src/SumEventsByLogValue.cpp +++ b/Framework/Algorithms/src/SumEventsByLogValue.cpp @@ -204,8 +204,8 @@ void SumEventsByLogValue::createTableOutput( // Get a list of the other time-series logs in the input workspace auto otherLogs = getNumberSeriesLogs(); // Add a column for each of these 'other' logs - for (auto it = otherLogs.begin(); it != otherLogs.end(); ++it) { - auto newColumn = outputWorkspace->addColumn("double", it->first); + for (auto &otherLog : otherLogs) { + auto newColumn = outputWorkspace->addColumn("double", otherLog.first); // For the benefit of MantidPlot, set these columns to be containing X // values newColumn->setPlotType(1); @@ -229,8 +229,8 @@ void SumEventsByLogValue::createTableOutput( // Calculate the time covered by this log value and add it to the table double duration = 0.0; - for (auto it = filter.begin(); it != filter.end(); ++it) { - duration += it->duration(); + for (auto &it : filter) { + duration += it.duration(); } timeCol->cell<double>(row) = duration; @@ -241,13 +241,13 @@ void SumEventsByLogValue::createTableOutput( sumProtonCharge(protonChargeLog, filter); interruption_point(); - for (auto log = otherLogs.begin(); log != otherLogs.end(); ++log) { + for (auto &otherLog : otherLogs) { // Calculate the average value of each 'other' log for the current value // of the main log // Have to (maybe inefficiently) fetch back column by name - move outside // loop if too slow - outputWorkspace->getColumn(log->first)->cell<double>(row) = - log->second->averageValueInFilter(filter); + outputWorkspace->getColumn(otherLog.first)->cell<double>(row) = + otherLog.second->averageValueInFilter(filter); } prog.report(); } @@ -273,15 +273,14 @@ void SumEventsByLogValue::filterEventList( return; const auto pulseTimes = eventList.getPulseTimes(); - for (std::size_t eventIndex = 0; eventIndex < pulseTimes.size(); - ++eventIndex) { + for (auto pulseTime : pulseTimes) { // Find the value of the log at the time of this event // This algorithm is really concerned with 'slow' logs so we don't care // about // the time of the event within the pulse. // NB: If the pulse time is before the first log entry, we get the first // value. - const int logValue = log->getSingleValue(pulseTimes[eventIndex]); + const int logValue = log->getSingleValue(pulseTime); if (logValue >= minVal && logValue <= maxVal) { // In this scenario it's easy to know what bin to increment @@ -345,8 +344,8 @@ SumEventsByLogValue::getNumberSeriesLogs() { std::vector<std::pair<std::string, const Kernel::ITimeSeriesProperty *>> numberSeriesProps; const auto &logs = m_inputWorkspace->run().getLogData(); - for (auto log = logs.begin(); log != logs.end(); ++log) { - const std::string logName = (*log)->name(); + for (auto log : logs) { + const std::string logName = log->name(); // Don't add the log that's the one being summed against if (logName == m_logName) continue; @@ -355,7 +354,7 @@ SumEventsByLogValue::getNumberSeriesLogs() { if (logName == "proton_charge") continue; // Try to cast to an ITimeSeriesProperty - auto tsp = dynamic_cast<const ITimeSeriesProperty *>(*log); + auto tsp = dynamic_cast<const ITimeSeriesProperty *>(log); // Move on to the next one if this is not a TSP if (tsp == NULL) continue; @@ -363,8 +362,8 @@ SumEventsByLogValue::getNumberSeriesLogs() { // if ( tsp->realSize() < 2 ) continue; // Now make sure it's either an int or double tsp, and if so add log to the // list - if (dynamic_cast<TimeSeriesProperty<double> *>(*log) || - dynamic_cast<TimeSeriesProperty<int> *>(*log)) { + if (dynamic_cast<TimeSeriesProperty<double> *>(log) || + dynamic_cast<TimeSeriesProperty<int> *>(log)) { numberSeriesProps.push_back(std::make_pair(logName, tsp)); } } @@ -425,10 +424,9 @@ void SumEventsByLogValue::createBinnedOutput( PARALLEL_START_INTERUPT_REGION const IEventList &eventList = m_inputWorkspace->getEventList(spec); const auto pulseTimes = eventList.getPulseTimes(); - for (std::size_t eventIndex = 0; eventIndex < pulseTimes.size(); - ++eventIndex) { + for (auto pulseTime : pulseTimes) { // Find the value of the log at the time of this event - const double logValue = log->getSingleValue(pulseTimes[eventIndex]); + const double logValue = log->getSingleValue(pulseTime); if (logValue >= XValues.front() && logValue < XValues.back()) { PARALLEL_ATOMIC ++Y[VectorHelper::getBinIndex(XValues, logValue)]; diff --git a/Framework/Algorithms/src/SumSpectra.cpp b/Framework/Algorithms/src/SumSpectra.cpp index 612141dab3f..4c789c9ee60 100644 --- a/Framework/Algorithms/src/SumSpectra.cpp +++ b/Framework/Algorithms/src/SumSpectra.cpp @@ -196,9 +196,9 @@ SumSpectra::getOutputSpecId(MatrixWorkspace_const_sptr localworkspace) { int totalSpec = static_cast<int>(localworkspace->getNumberHistograms()); specid_t temp; - for (auto it = this->m_indices.begin(); it != this->m_indices.end(); ++it) { - if (*(it) < totalSpec) { - temp = localworkspace->getSpectrum(*(it))->getSpectrumNo(); + for (value_type m_indice : this->m_indices) { + if (m_indice < totalSpec) { + temp = localworkspace->getSpectrum(m_indice)->getSpectrumNo(); if (temp < specId) specId = temp; } diff --git a/Framework/Algorithms/src/UnwrapMonitor.cpp b/Framework/Algorithms/src/UnwrapMonitor.cpp index 75f157e303c..e6baa8d0ac5 100644 --- a/Framework/Algorithms/src/UnwrapMonitor.cpp +++ b/Framework/Algorithms/src/UnwrapMonitor.cpp @@ -378,11 +378,11 @@ void UnwrapMonitor::unwrapYandE(const API::MatrixWorkspace_sptr &tempWS, if (m_inputWS->hasMaskedBins(spectrum)) { const MatrixWorkspace::MaskList &inputMasks = m_inputWS->maskedBins(spectrum); - for (auto it = inputMasks.cbegin(); it != inputMasks.cend(); ++it) { - const int maskIndex = static_cast<int>((*it).first); + for (const auto &inputMask : inputMasks) { + const int maskIndex = static_cast<int>(inputMask.first); if (maskIndex >= rangeBounds[0] && maskIndex < rangeBounds[1]) tempWS->flagMasked(spectrum, maskIndex - rangeBounds[0], - (*it).second); + inputMask.second); } } } diff --git a/Framework/Algorithms/src/UpdateScriptRepository.cpp b/Framework/Algorithms/src/UpdateScriptRepository.cpp index a0a8e10eb47..678e1d3b431 100644 --- a/Framework/Algorithms/src/UpdateScriptRepository.cpp +++ b/Framework/Algorithms/src/UpdateScriptRepository.cpp @@ -58,8 +58,8 @@ void UpdateScriptRepository::exec() { std::stringstream info; info << "Information about ScriptRepository:\n" << " A more recent version of the following files was installed:\n"; - for (unsigned short i = 0; i < f_list.size(); i++) { - info << " * " << f_list[i] << "\n"; + for (auto &i : f_list) { + info << " * " << i << "\n"; } info << "Please check these files before using them. " << "Note: These files were configured for AutoUpdate."; diff --git a/Framework/CurveFitting/src/Algorithms/CalculateChiSquared.cpp b/Framework/CurveFitting/src/Algorithms/CalculateChiSquared.cpp index 3d3c2c6a528..61169c6623e 100644 --- a/Framework/CurveFitting/src/Algorithms/CalculateChiSquared.cpp +++ b/Framework/CurveFitting/src/Algorithms/CalculateChiSquared.cpp @@ -467,14 +467,14 @@ void CalculateChiSquared::estimateErrors() { // If there are more than 1, find the one with the smallest chi^2. double chiMin = std::numeric_limits<double>::max(); double parMin = par0; - for (size_t i = 0; i < minima.size(); ++i) { - double value = base->eval(minima[i], P); + for (double i : minima) { + double value = base->eval(i, P); if (g_log.is(Kernel::Logger::Priority::PRIO_DEBUG)) { - g_log.debug() << minima[i] << " (" << value << ") "; + g_log.debug() << i << " (" << value << ") "; } if (value < chiMin) { chiMin = value; - parMin = minima[i]; + parMin = i; } } if (g_log.is(Kernel::Logger::Priority::PRIO_DEBUG)) { @@ -514,8 +514,8 @@ void CalculateChiSquared::estimateErrors() { if (g_log.is(Kernel::Logger::Priority::PRIO_DEBUG)) { g_log.debug() << "Roots: "; - for (size_t i = 0; i < roots.size(); ++i) { - g_log.debug() << roots[i] << ' '; + for (double root : roots) { + g_log.debug() << root << ' '; } g_log.debug() << std::endl; } @@ -668,8 +668,8 @@ void CalculateChiSquared::unfixParameters() { /// Restore the "fixed" status of previously unfixed paramters. void CalculateChiSquared::refixParameters() { - for (auto i = m_fixedParameters.begin(); i != m_fixedParameters.end(); ++i) { - m_function->fix(*i); + for (unsigned long &m_fixedParameter : m_fixedParameters) { + m_function->fix(m_fixedParameter); } } diff --git a/Framework/CurveFitting/src/Algorithms/CalculateMSVesuvio.cpp b/Framework/CurveFitting/src/Algorithms/CalculateMSVesuvio.cpp index fe23d129f2d..06c11099d62 100644 --- a/Framework/CurveFitting/src/Algorithms/CalculateMSVesuvio.cpp +++ b/Framework/CurveFitting/src/Algorithms/CalculateMSVesuvio.cpp @@ -651,8 +651,8 @@ CalculateMSVesuvio::calculateE1Range(const double theta, double e1min(1e10), e1max(-1e10); // large so that anything else is smaller const auto &atoms = m_sampleProps->atoms; - for (size_t i = 0; i < atoms.size(); ++i) { - const double mass = atoms[i].mass; + for (const auto &atom : atoms) { + const double mass = atom.mass; const double fraction = (cth + sqrt(mass * mass - sth * sth)) / (1.0 + mass); @@ -661,7 +661,7 @@ CalculateMSVesuvio::calculateE1Range(const double theta, const double qr = sqrt(k0 * k0 + k1 * k1 - 2.0 * k0 * k1 * cth); const double wr = en0 - en1; const double width = PhysicalConstants::E_mev_toNeutronWavenumberSq * - atoms[i].profile * qr / mass; + atom.profile * qr / mass; const double e1a = en0 - wr - 10.0 * width; const double e1b = en0 - wr + 10.0 * width; if (e1a < e1min) @@ -694,20 +694,20 @@ double CalculateMSVesuvio::partialDiffXSec(const double en0, const double en1, const auto &atoms = m_sampleProps->atoms; if (q > 0.0) // avoid continuous checking in loop { - for (size_t i = 0; i < atoms.size(); ++i) { - const double jstddev = atoms[i].profile; - const double mass = atoms[i].mass; + for (const auto &atom : atoms) { + const double jstddev = atom.profile; + const double mass = atom.mass; const double y = mass * w / (4.18036 * q) - 0.5 * q; const double jy = exp(-0.5 * y * y / (jstddev * jstddev)) / (jstddev * rt2pi); const double sqw = mass * jy / (4.18036 * q); - const double sclength = atoms[i].sclength; + const double sclength = atom.sclength; pdcs += sclength * sclength * (k1 / k0) * sqw; } } else { - for (size_t i = 0; i < atoms.size(); ++i) { - const double sclength = atoms[i].sclength; + for (const auto &atom : atoms) { + const double sclength = atom.sclength; pdcs += sclength * sclength; } } diff --git a/Framework/CurveFitting/src/Algorithms/ConvertToYSpace.cpp b/Framework/CurveFitting/src/Algorithms/ConvertToYSpace.cpp index 1f2ba6bfb14..5e27a466007 100644 --- a/Framework/CurveFitting/src/Algorithms/ConvertToYSpace.cpp +++ b/Framework/CurveFitting/src/Algorithms/ConvertToYSpace.cpp @@ -101,8 +101,8 @@ double ConvertToYSpace::getComponentParameter( boost::dynamic_pointer_cast<const Geometry::DetectorGroup>(comp)) { const auto dets = group->getDetectors(); double avg(0.0); - for (auto it = dets.begin(); it != dets.end(); ++it) { - auto param = pmap.getRecursive((*it)->getComponentID(), name); + for (const auto &det : dets) { + auto param = pmap.getRecursive(det->getComponentID(), name); if (param) avg += param->value<double>(); else diff --git a/Framework/CurveFitting/src/Algorithms/Fit.cpp b/Framework/CurveFitting/src/Algorithms/Fit.cpp index b10b66a8a91..156d262f4eb 100644 --- a/Framework/CurveFitting/src/Algorithms/Fit.cpp +++ b/Framework/CurveFitting/src/Algorithms/Fit.cpp @@ -63,11 +63,11 @@ void Fit::initConcrete() { std::vector<std::string> costFuncOptions = API::CostFunctionFactory::Instance().getKeys(); // select only CostFuncFitting variety - for (auto it = costFuncOptions.begin(); it != costFuncOptions.end(); ++it) { + for (auto &costFuncOption : costFuncOptions) { auto costFunc = boost::dynamic_pointer_cast<CostFunctions::CostFuncFitting>( - API::CostFunctionFactory::Instance().create(*it)); + API::CostFunctionFactory::Instance().create(costFuncOption)); if (!costFunc) { - *it = ""; + costFuncOption = ""; } } declareProperty( @@ -109,10 +109,10 @@ void Fit::initConcrete() { */ void Fit::copyMinimizerOutput(const API::IFuncMinimizer &minimizer) { auto &properties = minimizer.getProperties(); - for (auto prop = properties.begin(); prop != properties.end(); ++prop) { - if ((**prop).direction() == Kernel::Direction::Output && - (**prop).isValid() == "") { - Kernel::Property *property = (**prop).clone(); + for (auto propertie : properties) { + if ((*propertie).direction() == Kernel::Direction::Output && + (*propertie).isValid() == "") { + Kernel::Property *property = (*propertie).clone(); declareProperty(property); } } diff --git a/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp b/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp index ad467ccb52f..4048851063e 100644 --- a/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp +++ b/Framework/CurveFitting/src/Algorithms/FitPowderDiffPeaks.cpp @@ -435,8 +435,7 @@ void FitPowderDiffPeaks::fitPeaksRobust() { "Failed to fit the right most peak. Unable to process. "); stringstream robmsgss; - for (size_t i = 0; i < peakparnames.size(); ++i) { - string &parname = peakparnames[i]; + for (auto &parname : peakparnames) { robmsgss << parname << " = " << thispeak->getParameter(parname) << endl; } g_log.information() << "[DB1151] Robust Fit Result: Chi^2 = " << chi2 @@ -1216,8 +1215,7 @@ void FitPowderDiffPeaks::fitPeaksWithGoodStartingValues() { } else { // Fit overlapped peaks vector<BackToBackExponential_sptr> peaksgroup; - for (size_t index = 0; index < indexpeakgroup.size(); ++index) { - size_t ipk = indexpeakgroup[index]; + for (unsigned long ipk : indexpeakgroup) { BackToBackExponential_sptr temppeak = m_vecPeakFunctions[ipk].second.second; peaksgroup.push_back(temppeak); @@ -1473,8 +1471,7 @@ bool FitPowderDiffPeaks::fitSinglePeakConfident( stringstream debugss; debugss << "DB1251 Single Peak Confident Fit Result: Chi^2 = " << chi2 << endl; - for (size_t i = 0; i < parnames.size(); ++i) { - string &parname = parnames[i]; + for (auto &parname : parnames) { debugss << parname << " = " << peak->getParameter(parname) << endl; } g_log.notice(debugss.str()); @@ -1663,9 +1660,8 @@ void FitPowderDiffPeaks::storeFunctionParameters( IFunction_sptr function, std::map<string, double> ¶mmaps) { vector<string> paramnames = function->getParameterNames(); parammaps.clear(); - for (size_t i = 0; i < paramnames.size(); ++i) - parammaps.insert( - make_pair(paramnames[i], function->getParameter(paramnames[i]))); + for (auto ¶mname : paramnames) + parammaps.insert(make_pair(paramname, function->getParameter(paramname))); return; } @@ -1675,8 +1671,7 @@ void FitPowderDiffPeaks::storeFunctionParameters( void FitPowderDiffPeaks::restoreFunctionParameters( IFunction_sptr function, map<string, double> parammap) { vector<string> paramnames = function->getParameterNames(); - for (size_t i = 0; i < paramnames.size(); ++i) { - string &parname = paramnames[i]; + for (auto &parname : paramnames) { auto miter = parammap.find(parname); if (miter != parammap.end()) function->setParameter(parname, miter->second); @@ -1706,8 +1701,8 @@ bool FitPowderDiffPeaks::doFit1PeakSimple( dbss << peakfunction->asString() << endl; dbss << "Starting Value: "; vector<string> names = peakfunction->getParameterNames(); - for (size_t i = 0; i < names.size(); ++i) - dbss << names[i] << "= " << peakfunction->getParameter(names[i]) << ", \t"; + for (auto &name : names) + dbss << name << "= " << peakfunction->getParameter(name) << ", \t"; for (size_t i = 0; i < dataws->readX(workspaceindex).size(); ++i) dbss << dataws->readX(workspaceindex)[i] << "\t\t" << dataws->readY(workspaceindex)[i] << "\t\t" @@ -1988,8 +1983,8 @@ bool FitPowderDiffPeaks::fitOverlappedPeaks( // 7. Set up the composite function CompositeFunction_sptr peaksfunction(new CompositeFunction()); - for (size_t i = 0; i < peaks.size(); ++i) - peaksfunction->addFunction(peaks[i]); + for (auto &peak : peaks) + peaksfunction->addFunction(peak); // 8. Fit multiple peaks vector<double> chi2s; @@ -2176,9 +2171,7 @@ void FitPowderDiffPeaks::estimatePeakHeightsLeBail( */ void FitPowderDiffPeaks::setOverlappedPeaksConstraints( vector<BackToBackExponential_sptr> peaks) { - for (size_t ipk = 0; ipk < peaks.size(); ++ipk) { - BackToBackExponential_sptr thispeak = peaks[ipk]; - + for (auto thispeak : peaks) { // 1. Set constraint on X. double fwhm = thispeak->fwhm(); double centre = thispeak->centre(); @@ -2204,8 +2197,8 @@ bool FitPowderDiffPeaks::doFitNPeaksSimple( stringstream dbss0; dbss0 << "Starting Value: "; vector<string> names = peaksfunc->getParameterNames(); - for (size_t i = 0; i < names.size(); ++i) - dbss0 << names[i] << "= " << peaksfunc->getParameter(names[i]) << ", \t"; + for (auto &name : names) + dbss0 << name << "= " << peaksfunc->getParameter(name) << ", \t"; g_log.information() << "DBx430 " << dbss0.str() << endl; // 2. Create fit @@ -2230,8 +2223,8 @@ bool FitPowderDiffPeaks::doFitNPeaksSimple( // 4. Output stringstream dbss; dbss << "Fit N-Peaks @ "; - for (size_t i = 0; i < peakfuncs.size(); ++i) - dbss << peakfuncs[i]->centre() << ", "; + for (auto &peakfunc : peakfuncs) + dbss << peakfunc->centre() << ", "; if (isexecute) { // Figure out result @@ -2917,8 +2910,7 @@ FitPowderDiffPeaks::genPeak(map<string, int> hklmap, // Set peak parameters std::map<std::string, double>::iterator miter; - for (size_t ipn = 0; ipn < tnb2bfuncparnames.size(); ++ipn) { - string parname = tnb2bfuncparnames[ipn]; + for (auto parname : tnb2bfuncparnames) { if (parname.compare("Height") != 0) { miter = m_instrumentParmaeters.find(parname); if (miter == m_instrumentParmaeters.end()) { diff --git a/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp b/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp index 91212a986ea..95686369b3d 100644 --- a/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp +++ b/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp @@ -677,8 +677,7 @@ void LeBailFit::execRefineBackground() { outtablews->addColumn("double", "Value"); outtablews->addColumn("double", "Error"); - for (size_t i = 0; i < m_bkgdParameterNames.size(); ++i) { - string parname = m_bkgdParameterNames[i]; + for (auto parname : m_bkgdParameterNames) { double parvalue = m_backgroundFunction->getParameter(parname); TableRow newrow = outtablews->appendRow(); @@ -1623,15 +1622,15 @@ void LeBailFit::doMarkovChain(const map<string, Parameter> ¶mmap, for (size_t icycle = 1; icycle <= maxcycles; ++icycle) { // Refine parameters (for all parameters in turn) to data with background // removed - for (auto giter = m_MCGroups.begin(); giter != m_MCGroups.end(); ++giter) { + for (auto &m_MCGroup : m_MCGroups) { // Propose new value for ONE AND ONLY ONE Monte Carlo parameter group /* int igroup = giter->first; // group id g_log.debug() << "BigTrouble: Group " << igroup << "\n"; */ bool hasnewvalues = - proposeNewValues(giter->second, currR, mapCurrParameter, newparammap, - prevcyclebetterR); + proposeNewValues(m_MCGroup.second, currR, mapCurrParameter, + newparammap, prevcyclebetterR); if (!hasnewvalues) { // No parameter to have value updated in this MC group. Skip evaluation @@ -1868,8 +1867,8 @@ void LeBailFit::setupBuiltInRandomWalkStrategy() { m_MCGroups.insert(make_pair(0, geomparams)); dboutss << "Geometry parameters: "; - for (size_t i = 0; i < geomparams.size(); ++i) - dboutss << geomparams[i] << "\t\t"; + for (auto &geomparam : geomparams) + dboutss << geomparam << "\t\t"; dboutss << "\n"; // b. Alphas @@ -1881,8 +1880,8 @@ void LeBailFit::setupBuiltInRandomWalkStrategy() { m_MCGroups.insert(make_pair(1, alphs)); dboutss << "Alpha parameters"; - for (size_t i = 0; i < alphs.size(); ++i) - dboutss << alphs[i] << "\t\t"; + for (auto &alph : alphs) + dboutss << alph << "\t\t"; dboutss << "\n"; // c. Beta @@ -1894,8 +1893,8 @@ void LeBailFit::setupBuiltInRandomWalkStrategy() { m_MCGroups.insert(make_pair(2, betas)); dboutss << "Beta parameters"; - for (size_t i = 0; i < betas.size(); ++i) - dboutss << betas[i] << "\t\t"; + for (auto &beta : betas) + dboutss << beta << "\t\t"; dboutss << "\n"; // d. Sig @@ -1906,8 +1905,8 @@ void LeBailFit::setupBuiltInRandomWalkStrategy() { m_MCGroups.insert(make_pair(3, sigs)); dboutss << "Sig parameters"; - for (size_t i = 0; i < sigs.size(); ++i) - dboutss << sigs[i] << "\t\t"; + for (auto &sig : sigs) + dboutss << sig << "\t\t"; dboutss << "\n"; g_log.notice(dboutss.str()); @@ -1916,16 +1915,14 @@ void LeBailFit::setupBuiltInRandomWalkStrategy() { // 2. Dictionary for each parameter for non-negative, mcX0, mcX1 // a) Sig0, Sig1, Sig2 - for (size_t i = 0; i < sigs.size(); ++i) { - string parname = sigs[i]; + for (auto parname : sigs) { m_funcParameters[parname].mcA0 = 2.0; m_funcParameters[parname].mcA1 = 1.0; m_funcParameters[parname].nonnegative = true; } // b) Alpha - for (size_t i = 0; i < alphs.size(); ++i) { - string parname = alphs[i]; + for (auto parname : alphs) { m_funcParameters[parname].mcA1 = 1.0; m_funcParameters[parname].nonnegative = false; } @@ -1935,8 +1932,7 @@ void LeBailFit::setupBuiltInRandomWalkStrategy() { m_funcParameters["Alph1t"].mcA0 = 0.05; // c) Beta - for (size_t i = 0; i < betas.size(); ++i) { - string parname = betas[i]; + for (auto parname : betas) { m_funcParameters[parname].mcA1 = 1.0; m_funcParameters[parname].nonnegative = false; } @@ -2167,9 +2163,8 @@ bool LeBailFit::proposeNewValues(vector<string> mcgroup, Rfactor r, // Find out parameters to refine in this step/MC group g_log.debug() << "Parameter Number In Group = " << mcgroup.size() << "\n"; - for (size_t i = 0; i < mcgroup.size(); ++i) { + for (auto paramname : mcgroup) { // Find out the i-th parameter to be refined or not - string paramname = mcgroup[i]; auto mapiter = curparammap.find(paramname); if (mapiter == curparammap.end()) { stringstream errmsg; diff --git a/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp b/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp index 117213f9dee..b1b6856c176 100644 --- a/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp +++ b/Framework/CurveFitting/src/Algorithms/LeBailFunction.cpp @@ -67,8 +67,7 @@ LeBailFunction::LeBailFunction(std::string peaktype) { m_orderedProfileParameterNames.end()); // Peak parameter values - for (size_t i = 0; i < m_peakParameterNameVec.size(); ++i) { - string parname = m_peakParameterNameVec[i]; + for (auto parname : m_peakParameterNameVec) { m_functionParameters.insert(make_pair(parname, 0.0)); } @@ -320,8 +319,7 @@ IPowderDiffPeakFunction_sptr LeBailFunction::generatePeak(int h, int k, int l) { boost::dynamic_pointer_cast<IPowderDiffPeakFunction>(f); peak->setMillerIndex(h, k, l); - for (size_t i = 0; i < m_peakParameterNameVec.size(); ++i) { - string parname = m_peakParameterNameVec[i]; + for (auto parname : m_peakParameterNameVec) { double parvalue = m_functionParameters[parname]; peak->setParameter(parname, parvalue); } @@ -371,8 +369,7 @@ bool LeBailFunction::calculatePeaksIntensities( } // Set zero to all peaks out of boundary - for (size_t i = 0; i < outboundpeakvec.size(); ++i) { - IPowderDiffPeakFunction_sptr peak = outboundpeakvec[i]; + for (auto peak : outboundpeakvec) { peak->setHeight(0.); } @@ -477,9 +474,9 @@ bool LeBailFunction::calculateGroupPeakIntensities( << ", TOF_h = " << thispeak->centre() << ", FWHM = " << thispeak->fwhm() << "\n"; vector<string> peakparamnames = thispeak->getParameterNames(); - for (size_t ipar = 0; ipar < peakparamnames.size(); ++ipar) { - errss << "\t" << peakparamnames[ipar] << " = " - << thispeak->getParameter(peakparamnames[ipar]) << "\n"; + for (auto &peakparamname : peakparamnames) { + errss << "\t" << peakparamname << " = " + << thispeak->getParameter(peakparamname) << "\n"; } } diff --git a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp index 7ef71507ce4..486ffb442c8 100644 --- a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp +++ b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp @@ -362,13 +362,12 @@ void PlotPeakByLogValue::exec() { groupAlg->execute(); } - for (auto it = m_minimizerWorkspaces.begin(); - it != m_minimizerWorkspaces.end(); ++it) { - const std::string paramName = (*it).first; + for (auto &m_minimizerWorkspace : m_minimizerWorkspaces) { + const std::string paramName = m_minimizerWorkspace.first; API::IAlgorithm_sptr groupAlg = AlgorithmManager::Instance().createUnmanaged("GroupWorkspaces"); groupAlg->initialize(); - groupAlg->setProperty("InputWorkspaces", (*it).second); + groupAlg->setProperty("InputWorkspaces", m_minimizerWorkspace.second); groupAlg->setProperty("OutputWorkspace", m_baseName + "_" + paramName); groupAlg->execute(); } @@ -521,8 +520,8 @@ PlotPeakByLogValue::makeNames() const { typedef Poco::StringTokenizer tokenizer; tokenizer names(inputList, ";", tokenizer::TOK_IGNORE_EMPTY | tokenizer::TOK_TRIM); - for (auto it = names.begin(); it != names.end(); ++it) { - tokenizer params(*it, ",", tokenizer::TOK_TRIM); + for (const auto &it : names) { + tokenizer params(it, ",", tokenizer::TOK_TRIM); std::string name = params[0]; int wi = default_wi; int spec = default_spec; @@ -574,8 +573,8 @@ PlotPeakByLogValue::makeNames() const { boost::dynamic_pointer_cast<API::WorkspaceGroup>(ws); if (wsg) { std::vector<std::string> wsNames = wsg->getNames(); - for (auto i = wsNames.begin(); i != wsNames.end(); ++i) { - nameList.push_back(InputData(*i, wi, -1, period, start, end)); + for (auto &wsName : wsNames) { + nameList.push_back(InputData(wsName, wi, -1, period, start, end)); } continue; } @@ -604,13 +603,13 @@ PlotPeakByLogValue::getMinimizerString(const std::string &wsName, auto minimizer = FuncMinimizerFactory::Instance().createMinimizer(format); auto minimizerProps = minimizer->getProperties(); - for (auto it = minimizerProps.begin(); it != minimizerProps.end(); ++it) { + for (auto &minimizerProp : minimizerProps) { Mantid::API::WorkspaceProperty<> *wsProp = - dynamic_cast<Mantid::API::WorkspaceProperty<> *>(*it); + dynamic_cast<Mantid::API::WorkspaceProperty<> *>(minimizerProp); if (wsProp) { - std::string wsPropValue = (*it)->value(); + std::string wsPropValue = minimizerProp->value(); if (wsPropValue != "") { - std::string wsPropName = (*it)->name(); + std::string wsPropName = minimizerProp->name(); m_minimizerWorkspaces[wsPropName].push_back(wsPropValue); } } diff --git a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp index 80d4fdec61c..af45d3912ea 100644 --- a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp +++ b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters.cpp @@ -247,8 +247,7 @@ void RefinePowderInstrumentParameters::fitInstrumentParameters() { stringstream msgss; msgss << "Set Instrument Function Parameter : " << endl; std::map<std::string, double>::iterator paramiter; - for (size_t i = 0; i < funparamnames.size(); ++i) { - string parname = funparamnames[i]; + for (auto parname : funparamnames) { paramiter = m_FuncParameters.find(parname); if (paramiter == m_FuncParameters.end()) { // Not found and thus skip @@ -340,8 +339,7 @@ void RefinePowderInstrumentParameters::fitInstrumentParameters() { cout << "Homemade Chi^2 = " << selfchi2 << endl; // 5. Update fitted parameters - for (size_t i = 0; i < funparamnames.size(); ++i) { - std::string parname = funparamnames[i]; + for (auto parname : funparamnames) { double parvalue = fitfunc->getParameter(parname); m_FuncParameters[parname] = parvalue; } @@ -894,26 +892,26 @@ void RefinePowderInstrumentParameters::genPeaksFromTable( sigma2 = -1; API::TableRow row = peakparamws->getRow(ir); - for (size_t ic = 0; ic < colnames.size(); ++ic) { - if (colnames[ic].compare("H") == 0) + for (auto &colname : colnames) { + if (colname.compare("H") == 0) row >> h; - else if (colnames[ic].compare("K") == 0) + else if (colname.compare("K") == 0) row >> k; - else if (colnames[ic].compare("L") == 0) + else if (colname.compare("L") == 0) row >> l; - else if (colnames[ic].compare("Alpha") == 0) + else if (colname.compare("Alpha") == 0) row >> alpha; - else if (colnames[ic].compare("Beta") == 0) + else if (colname.compare("Beta") == 0) row >> beta; - else if (colnames[ic].compare("Sigma2") == 0) + else if (colname.compare("Sigma2") == 0) row >> sigma2; - else if (colnames[ic].compare("Sigma") == 0) + else if (colname.compare("Sigma") == 0) row >> sigma; - else if (colnames[ic].compare("Chi2") == 0) + else if (colname.compare("Chi2") == 0) row >> chi2; - else if (colnames[ic].compare("Height") == 0) + else if (colname.compare("Height") == 0) row >> height; - else if (colnames[ic].compare("TOF_h") == 0) + else if (colname.compare("TOF_h") == 0) row >> tof_h; else { try { @@ -1078,9 +1076,8 @@ void RefinePowderInstrumentParameters::importMonteCarloParametersFromTable( // 3. Retrieve the information for geometry parameters map<string, vector<double>>::iterator mit; - for (size_t i = 0; i < parameternames.size(); ++i) { + for (auto parname : parameternames) { // a) Get on hold of the MC parameter vector - string parname = parameternames[i]; mit = mcparameters.find(parname); if (mit == mcparameters.end()) { // Not found the parameter. raise error! @@ -1133,8 +1130,7 @@ void RefinePowderInstrumentParameters::calculateThermalNeutronSpecial( double width = m_Function->getParameter("Width"); double tcross = m_Function->getParameter("Tcross"); - for (size_t i = 0; i < vec_d.size(); ++i) { - double dh = vec_d[i]; + for (double dh : vec_d) { double n = 0.5 * gsl_sf_erfc(width * (tcross - 1 / dh)); vec_n.push_back(n); } @@ -1253,8 +1249,8 @@ RefinePowderInstrumentParameters::genMCResultTable() { tablews->addColumn("double", "Chi2"); tablews->addColumn("double", "GSLChi2"); - for (size_t i = 0; i < m_PeakFunctionParameterNames.size(); ++i) { - tablews->addColumn("double", m_PeakFunctionParameterNames[i]); + for (auto &m_PeakFunctionParameterName : m_PeakFunctionParameterNames) { + tablews->addColumn("double", m_PeakFunctionParameterName); } // 2. Put values in diff --git a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp index d8c3ee728ba..c432a057dad 100644 --- a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp +++ b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp @@ -520,13 +520,12 @@ double RefinePowderInstrumentParameters3::doSimulatedAnnealing( void RefinePowderInstrumentParameters3::proposeNewValues( vector<string> mcgroup, map<string, Parameter> &curparammap, map<string, Parameter> &newparammap, double currchisq) { - for (size_t i = 0; i < mcgroup.size(); ++i) { + for (auto paramname : mcgroup) { // random number between -1 and 1 double randomnumber = 2 * static_cast<double>(rand()) / static_cast<double>(RAND_MAX) - 1.0; // parameter information - string paramname = mcgroup[i]; Parameter param = curparammap[paramname]; double stepsize = m_dampingFactor * currchisq * (param.curvalue * param.mcA1 + param.mcA0) * @@ -723,8 +722,8 @@ void RefinePowderInstrumentParameters3::setupRandomWalkStrategy( mcgroups.push_back(geomparams); dboutss << "Geometry parameters: "; - for (size_t i = 0; i < geomparams.size(); ++i) - dboutss << geomparams[i] << "\t\t"; + for (auto &geomparam : geomparams) + dboutss << geomparam << "\t\t"; dboutss << endl; g_log.notice(dboutss.str()); @@ -1187,8 +1186,7 @@ void RefinePowderInstrumentParameters3::setFunctionParameterValues( msgss << "Set Instrument Function Parameter : " << endl; std::map<std::string, Parameter>::iterator paramiter; - for (size_t i = 0; i < funparamnames.size(); ++i) { - string parname = funparamnames[i]; + for (auto parname : funparamnames) { paramiter = params.find(parname); if (paramiter != params.end()) { @@ -1413,8 +1411,7 @@ void restoreFunctionParameterValue( map<string, Parameter> ¶mmap) { vector<string> parnames = function->getParameterNames(); - for (size_t i = 0; i < parnames.size(); ++i) { - string &parname = parnames[i]; + for (auto &parname : parnames) { map<string, pair<double, double>>::iterator miter; miter = parvaluemap.find(parname); diff --git a/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp b/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp index c9ba83eb4f2..0fb49b14a9c 100644 --- a/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp +++ b/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp @@ -67,8 +67,8 @@ void SplineBackground::exec() { std::vector<int> masked(Y.size()); if (isMasked) { auto maskedBins = inWS->maskedBins(spec); - for (auto it = maskedBins.begin(); it != maskedBins.end(); ++it) - masked[it->first] = 1; + for (auto &maskedBin : maskedBins) + masked[maskedBin.first] = 1; n -= static_cast<int>(inWS->maskedBins(spec).size()); } diff --git a/Framework/CurveFitting/src/Functions/ChebfunBase.cpp b/Framework/CurveFitting/src/Functions/ChebfunBase.cpp index 00c5646d009..2c5d20d014a 100644 --- a/Framework/CurveFitting/src/Functions/ChebfunBase.cpp +++ b/Framework/CurveFitting/src/Functions/ChebfunBase.cpp @@ -170,8 +170,8 @@ bool ChebfunBase::hasConverged(const std::vector<double> &a, double maxA, if (a.empty()) return true; if (maxA == 0.0) { - for (auto it = a.begin(); it != a.end(); ++it) { - double tmp = fabs(*it); + for (double it : a) { + double tmp = fabs(it); if (tmp > maxA) { maxA = tmp; } @@ -400,8 +400,8 @@ ChebfunBase::bestFitTempl(double start, double end, FunctionType f, a = base.calcA(p2); if (calcMaxA) { maxA = 0.0; - for (auto it = a.begin(); it != a.end(); ++it) { - double tmp = fabs(*it); + for (double &it : a) { + double tmp = fabs(it); if (tmp > maxA) { maxA = tmp; } @@ -492,8 +492,8 @@ std::vector<double> ChebfunBase::linspace(size_t n) const { std::vector<double> space(n); double x = m_start; const double dx = width() / double(n - 1); - for (auto s = space.begin(); s != space.end(); ++s) { - *s = x; + for (double &s : space) { + s = x; x += dx; } space.back() = m_end; diff --git a/Framework/CurveFitting/src/Functions/ComptonScatteringCountRate.cpp b/Framework/CurveFitting/src/Functions/ComptonScatteringCountRate.cpp index fa9ed893cb0..eb9a1e13cbb 100644 --- a/Framework/CurveFitting/src/Functions/ComptonScatteringCountRate.cpp +++ b/Framework/CurveFitting/src/Functions/ComptonScatteringCountRate.cpp @@ -309,8 +309,8 @@ void ComptonScatteringCountRate::cacheComptonProfile( const size_t paramsOffset) { m_profiles.push_back(profile.get()); auto fixedParams = profile->intensityParameterIndices(); - for (size_t j = 0; j < fixedParams.size(); ++j) { - const size_t indexOfFixed = paramsOffset + fixedParams[j]; + for (unsigned long fixedParam : fixedParams) { + const size_t indexOfFixed = paramsOffset + fixedParam; this->fix(indexOfFixed); m_fixedParamIndices.push_back(indexOfFixed); } diff --git a/Framework/CurveFitting/src/Functions/Convolution.cpp b/Framework/CurveFitting/src/Functions/Convolution.cpp index 3040b82b33a..b86738b13b4 100644 --- a/Framework/CurveFitting/src/Functions/Convolution.cpp +++ b/Framework/CurveFitting/src/Functions/Convolution.cpp @@ -260,8 +260,7 @@ void Convolution::function(const FunctionDomain &domain, std::transform(out, out + nData, tmp.data(), out, std::plus<double>()); } else if (!dltFuns.empty()) { std::vector<double> x(nData); - for (auto it = dltFuns.begin(); it != dltFuns.end(); ++it) { - auto df = *it; + for (auto df : dltFuns) { double shift = -df->getParameter("Centre"); dltF = df->getParameter("Height") * df->HeightPrefactor(); std::transform(xValues, xValues + nData, x.data(), diff --git a/Framework/CurveFitting/src/Functions/DiffSphere.cpp b/Framework/CurveFitting/src/Functions/DiffSphere.cpp index a3ed631afa8..a8fc95b5c04 100644 --- a/Framework/CurveFitting/src/Functions/DiffSphere.cpp +++ b/Framework/CurveFitting/src/Functions/DiffSphere.cpp @@ -133,10 +133,10 @@ void InelasticDiffSphere::initAlphaCoeff() { * numerical indeterminacies. To avoid them, we will interpolate linearly. */ void InelasticDiffSphere::initLinJlist() { - for (size_t i = 0; i < m_xnl.size(); i++) { + for (auto &i : m_xnl) { linearJ abJ; - double x = m_xnl[i].x; // eigenvalue for a (n, l) pair - unsigned int l = (unsigned int)(m_xnl[i].l); + double x = i.x; // eigenvalue for a (n, l) pair + unsigned int l = (unsigned int)(i.l); double Qa = x - m_divZone; // left of the numerical divergence point double J0 = (Qa * boost::math::sph_bessel(l + 1, Qa) - l * boost::math::sph_bessel(l, Qa)) / diff --git a/Framework/CurveFitting/src/Functions/PawleyFunction.cpp b/Framework/CurveFitting/src/Functions/PawleyFunction.cpp index 33ca783ae1c..592b966ed50 100644 --- a/Framework/CurveFitting/src/Functions/PawleyFunction.cpp +++ b/Framework/CurveFitting/src/Functions/PawleyFunction.cpp @@ -497,8 +497,8 @@ void PawleyFunction::setPeaks(const std::vector<Kernel::V3D> &hkls, double fwhm, double height) { clearPeaks(); - for (size_t i = 0; i < hkls.size(); ++i) { - addPeak(hkls[i], fwhm, height); + for (const auto &hkl : hkls) { + addPeak(hkl, fwhm, height); } } diff --git a/Framework/CurveFitting/src/Functions/ProcessBackground.cpp b/Framework/CurveFitting/src/Functions/ProcessBackground.cpp index 42c6259065e..1ff9b7dce29 100644 --- a/Framework/CurveFitting/src/Functions/ProcessBackground.cpp +++ b/Framework/CurveFitting/src/Functions/ProcessBackground.cpp @@ -598,9 +598,9 @@ void ProcessBackground::selectFromGivenFunction() { int bkgdorder = static_cast<int>(parmap.size() - 1); // A0 - A(n) total n+1 parameters bkgdfunc->setAttributeValue("n", bkgdorder); - for (auto mit = parmap.begin(); mit != parmap.end(); ++mit) { - string parname = mit->first; - double parvalue = mit->second; + for (auto &mit : parmap) { + string parname = mit.first; + double parvalue = mit.second; bkgdfunc->setParameter(parname, parvalue); } @@ -1096,8 +1096,8 @@ size_t RemovePeaks::excludePeaks(vector<double> v_inX, vector<bool> &v_useX, // Count non-excluded region size_t count = 0; - for (size_t i = 0; i < v_useX.size(); ++i) - if (v_useX[i]) + for (auto &&i : v_useX) + if (i) ++count; return count; diff --git a/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp b/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp index 568f42ad24d..7ad18e0b0d4 100644 --- a/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp +++ b/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp @@ -55,9 +55,9 @@ void TabulatedFunction::eval(double scaling, double xshift, double xscale, // shift and scale the domain over which the function is defined std::vector<double> xData(m_xData); - for (auto it = xData.begin(); it != xData.end(); ++it) { - *it *= xscale; - *it += xshift; + for (double &it : xData) { + it *= xscale; + it += xshift; } const double xStart = xData.front(); diff --git a/Framework/CurveFitting/src/GSLVector.cpp b/Framework/CurveFitting/src/GSLVector.cpp index cdbc2a12db0..95ae1c7e434 100644 --- a/Framework/CurveFitting/src/GSLVector.cpp +++ b/Framework/CurveFitting/src/GSLVector.cpp @@ -138,8 +138,8 @@ double GSLVector::norm() const { return sqrt(norm2()); } /// Get vector's norm squared double GSLVector::norm2() const { double res = 0.0; - for (auto el = m_data.begin(); el != m_data.end(); ++el) { - res += (*el) * (*el); + for (double el : m_data) { + res += el * el; } return res; } diff --git a/Framework/CurveFitting/src/IFittingAlgorithm.cpp b/Framework/CurveFitting/src/IFittingAlgorithm.cpp index 4984b1edc74..487c0d621d7 100644 --- a/Framework/CurveFitting/src/IFittingAlgorithm.cpp +++ b/Framework/CurveFitting/src/IFittingAlgorithm.cpp @@ -241,10 +241,10 @@ void IFittingAlgorithm::addWorkspaces() { new MultiDomainCreator(this, m_workspacePropertyNames)); } auto props = getProperties(); - for (auto prop = props.begin(); prop != props.end(); ++prop) { - if ((**prop).direction() == Kernel::Direction::Input && - dynamic_cast<API::IWorkspaceProperty *>(*prop)) { - const std::string workspacePropertyName = (**prop).name(); + for (auto &prop : props) { + if ((*prop).direction() == Kernel::Direction::Input && + dynamic_cast<API::IWorkspaceProperty *>(prop)) { + const std::string workspacePropertyName = (*prop).name(); API::Workspace_const_sptr ws = getProperty(workspacePropertyName); IDomainCreator *creator = createDomainCreator(m_function.get(), ws.get(), workspacePropertyName, diff --git a/Framework/CurveFitting/src/MultiDomainCreator.cpp b/Framework/CurveFitting/src/MultiDomainCreator.cpp index 202c4dbd10a..54cbe5a1765 100644 --- a/Framework/CurveFitting/src/MultiDomainCreator.cpp +++ b/Framework/CurveFitting/src/MultiDomainCreator.cpp @@ -43,12 +43,12 @@ void MultiDomainCreator::createDomain( auto jointDomain = new API::JointDomain; API::FunctionValues_sptr values; i0 = 0; - for (auto c = m_creators.begin(); c != m_creators.end(); ++c) { - if (!(*c)) { + for (auto &m_creator : m_creators) { + if (!m_creator) { throw std::runtime_error("Missing domain creator"); } API::FunctionDomain_sptr domain; - (**c).createDomain(domain, values, i0); + (*m_creator).createDomain(domain, values, i0); jointDomain->addDomain(domain); i0 += domain->size(); } diff --git a/Framework/CurveFitting/src/SeqDomain.cpp b/Framework/CurveFitting/src/SeqDomain.cpp index 8a704c17456..45f430b203b 100644 --- a/Framework/CurveFitting/src/SeqDomain.cpp +++ b/Framework/CurveFitting/src/SeqDomain.cpp @@ -10,8 +10,8 @@ namespace CurveFitting { /// Return the number of points in the domain size_t SeqDomain::size() const { size_t n = 0; - for (auto it = m_creators.begin(); it != m_creators.end(); ++it) { - n += (**it).getDomainSize(); + for (const auto &m_creator : m_creators) { + n += (*m_creator).getDomainSize(); } return n; } -- GitLab