diff --git a/Framework/LiveData/src/ADARA/ADARAParser.cpp b/Framework/LiveData/src/ADARA/ADARAParser.cpp index 5e5bea2611b1df0354231c9e5c75053e5b4f1a90..d5d3b4e33ebf95696406031be2b7326cbd3db0bd 100644 --- a/Framework/LiveData/src/ADARA/ADARAParser.cpp +++ b/Framework/LiveData/src/ADARA/ADARAParser.cpp @@ -297,14 +297,13 @@ void Parser::getDiscardedPacketsLogString(std::string &log_info) { uint64_t total_discarded = 0; // Append Each Discarded Packet Type Count... - for (auto it = m_discarded_packets.begin(); it != m_discarded_packets.end(); - ++it) { + for (auto &m_discarded_packet : m_discarded_packets) { std::stringstream ss; - ss << std::hex << "0x" << it->first << std::dec << "=" << it->second - << "; "; + ss << std::hex << "0x" << m_discarded_packet.first << std::dec << "=" + << m_discarded_packet.second << "; "; log_info.append(ss.str()); - total_discarded += it->second; + total_discarded += m_discarded_packet.second; } // Append Total Discarded Packet Count diff --git a/Framework/LiveData/src/ISISHistoDataListener.cpp b/Framework/LiveData/src/ISISHistoDataListener.cpp index 53c3ae7833b6c1c07b1c2965068522a893a1a145..8ce686f1a88fc5516ab3280ae2b2397974d820e4 100644 --- a/Framework/LiveData/src/ISISHistoDataListener.cpp +++ b/Framework/LiveData/src/ISISHistoDataListener.cpp @@ -547,9 +547,8 @@ void ISISHistoDataListener::loadTimeRegimes() { m_monitorSpectra[i] = m_specIDs[monitorIndices[i] - 1]; } - for (auto mon = m_monitorSpectra.begin(); mon != m_monitorSpectra.end(); - ++mon) { - g_log.information() << "Monitor spectrum " << *mon << std::endl; + for (int &mon : m_monitorSpectra) { + g_log.information() << "Monitor spectrum " << mon << std::endl; } const std::string detRTCB = @@ -598,14 +597,13 @@ int ISISHistoDataListener::getTimeRegimeToLoad() const { if (m_monitorSpectra.empty()) return 0; int regime = -1; - for (auto specIt = m_specList.begin(); specIt != m_specList.end(); - ++specIt) { + for (int specIt : m_specList) { bool isMonitor = - std::find(m_monitorSpectra.begin(), m_monitorSpectra.end(), - *specIt) != m_monitorSpectra.end(); - if (!isMonitor && *specIt > m_totalNumberOfSpectra) + std::find(m_monitorSpectra.begin(), m_monitorSpectra.end(), specIt) != + m_monitorSpectra.end(); + if (!isMonitor && specIt > m_totalNumberOfSpectra) throw std::invalid_argument("Invalid spectra index is found: " + - boost::lexical_cast<std::string>(*specIt)); + boost::lexical_cast<std::string>(specIt)); int specRegime = isMonitor ? 1 : 0; if (regime < 0) { regime = specRegime; diff --git a/Framework/LiveData/src/ISISLiveEventDataListener.cpp b/Framework/LiveData/src/ISISLiveEventDataListener.cpp index e18ca7752a4db9f9f8615d1cd0d2f4eac6f24fb0..4bb96bfa357ed264d7ef83316b8c17f18dbcb116 100644 --- a/Framework/LiveData/src/ISISLiveEventDataListener.cpp +++ b/Framework/LiveData/src/ISISLiveEventDataListener.cpp @@ -387,9 +387,9 @@ void ISISLiveEventDataListener::saveEvents( period = 0; } - for (auto it = data.begin(); it != data.end(); ++it) { - Mantid::DataObjects::TofEvent event(it->time_of_flight, pulseTime); - m_eventBuffer[period]->getEventList(it->spectrum).addEventQuickly(event); + for (auto it : data) { + Mantid::DataObjects::TofEvent event(it.time_of_flight, pulseTime); + m_eventBuffer[period]->getEventList(it.spectrum).addEventQuickly(event); } } diff --git a/Framework/LiveData/src/LiveDataAlgorithm.cpp b/Framework/LiveData/src/LiveDataAlgorithm.cpp index 5a3390e0770d772d468476abed15da338b80dd4a..93f3f749fb7ecfb30178e1b497f3fcd4ba74edbd 100644 --- a/Framework/LiveData/src/LiveDataAlgorithm.cpp +++ b/Framework/LiveData/src/LiveDataAlgorithm.cpp @@ -40,9 +40,9 @@ void LiveDataAlgorithm::initProps() { std::vector<std::string> instruments; auto &instrInfo = Kernel::ConfigService::Instance().getFacility().instruments(); - for (auto it = instrInfo.begin(); it != instrInfo.end(); ++it) { - if (!it->liveDataAddress().empty()) { - instruments.push_back(it->name()); + for (const auto &it : instrInfo) { + if (!it.liveDataAddress().empty()) { + instruments.push_back(it.name()); } } #ifndef NDEBUG @@ -161,8 +161,7 @@ void LiveDataAlgorithm::initProps() { */ void LiveDataAlgorithm::copyPropertyValuesFrom(const LiveDataAlgorithm &other) { std::vector<Property *> props = this->getProperties(); - for (size_t i = 0; i < props.size(); i++) { - Property *prop = props[i]; + for (auto prop : props) { this->setPropertyValue(prop->name(), other.getPropertyValue(prop->name())); } } diff --git a/Framework/LiveData/src/LoadLiveData.cpp b/Framework/LiveData/src/LoadLiveData.cpp index cd7bf27a9e95160d938d1a2cc99c201932e3f472..384d156e25e9686e815b17f2808d6f370663c240 100644 --- a/Framework/LiveData/src/LoadLiveData.cpp +++ b/Framework/LiveData/src/LoadLiveData.cpp @@ -108,8 +108,7 @@ LoadLiveData::runProcessing(Mantid::API::Workspace_sptr inputWS, g_log.debug() << "Processing algorithm (" << alg->name() << ") has " << proplist.size() << " properties." << std::endl; bool inputPropertyWorkspaceFound = false; - for (size_t i = 0; i < proplist.size(); ++i) { - Property *prop = proplist[i]; + for (auto prop : proplist) { if ((prop->direction() == 0) && (inputPropertyWorkspaceFound == false)) { if (boost::ends_with(prop->type(), "Workspace")) { diff --git a/Framework/LiveData/src/SNSLiveEventDataListener.cpp b/Framework/LiveData/src/SNSLiveEventDataListener.cpp index 4ea7b4d1f5ad9beee314f709414dc686c9d6974e..87566528110d6052edad6b268fa6924348f78194 100644 --- a/Framework/LiveData/src/SNSLiveEventDataListener.cpp +++ b/Framework/LiveData/src/SNSLiveEventDataListener.cpp @@ -1397,8 +1397,8 @@ boost::shared_ptr<Workspace> SNSLiveEventDataListener::extractData() { temp->mutableRun().clearOutdatedTimeSeriesLogValues(); // Clear out old monitor logs - for (unsigned i = 0; i < m_monitorLogs.size(); i++) { - temp->mutableRun().removeProperty(m_monitorLogs[i]); + for (auto &m_monitorLog : m_monitorLogs) { + temp->mutableRun().removeProperty(m_monitorLog); } m_monitorLogs.clear(); diff --git a/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp b/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp index b58b8ffae1159278da7293635d9bc0e0b9e7ab09..618f4dbc0c66e5b9b21a3b55d3e289f6921cf903 100644 --- a/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp +++ b/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp @@ -587,8 +587,8 @@ boost::shared_ptr<Workspace> TOPAZLiveEventDataListener::extractData() { // TODO: At present, there's no way for monitor logs to be added // to m_monitorLogs. Either implement this feature, or remove // m_monitorLogs! - for (unsigned i = 0; i < m_monitorLogs.size(); i++) { - temp->mutableRun().removeProperty(m_monitorLogs[i]); + for (auto &m_monitorLog : m_monitorLogs) { + temp->mutableRun().removeProperty(m_monitorLog); } m_monitorLogs.clear(); diff --git a/Framework/Nexus/src/MuonNexusReader.cpp b/Framework/Nexus/src/MuonNexusReader.cpp index 594dc6d35b4d754ce18b5e55e0353563a411072f..5d93fc6f605fbf622ff958b18eb5f34f9fdf5f73 100644 --- a/Framework/Nexus/src/MuonNexusReader.cpp +++ b/Framework/Nexus/src/MuonNexusReader.cpp @@ -44,9 +44,9 @@ MuonNexusReader::~MuonNexusReader() { void MuonNexusReader::openFirstNXentry(NeXus::File &handle) { std::map<string, string> entries = handle.getEntries(); bool found = false; - for (auto it = entries.begin(); it != entries.end(); ++it) { - if (it->second == NXENTRY) { - handle.openGroup(it->first, NXENTRY); + for (auto &entrie : entries) { + if (entrie.second == NXENTRY) { + handle.openGroup(entrie.first, NXENTRY); found = true; break; } @@ -78,9 +78,9 @@ void MuonNexusReader::readFromFile(const string &filename) { // find all of the NXdata in the entry std::vector<string> nxdataname; std::map<string, string> entries = handle.getEntries(); - for (auto it = entries.begin(); it != entries.end(); ++it) { - if (it->second == NXDATA) { - nxdataname.push_back(it->first); + for (auto &entrie : entries) { + if (entrie.second == NXDATA) { + nxdataname.push_back(entrie.first); } } handle.openGroup(nxdataname.front(), NXDATA); @@ -129,8 +129,8 @@ void MuonNexusReader::readFromFile(const string &filename) { // If not available set as one period. entries = handle.getEntries(); t_nper = 1; - for (auto it = entries.begin(); it != entries.end(); ++it) { - if (it->first == "switching_states") { + for (auto &entrie : entries) { + if (entrie.first == "switching_states") { int ssPeriods; handle.readData("switching_states", ssPeriods); t_nper = abs(ssPeriods); @@ -184,9 +184,9 @@ void MuonNexusReader::readLogData(const string &filename) { // memory // Also get the start_time string needed to change these times into ISO times std::map<string, string> entries = handle.getEntries(); - for (auto it = entries.begin(); it != entries.end(); ++it) { - string nxname = it->first; - string nxclass = it->second; + for (auto &entrie : entries) { + string nxname = entrie.first; + string nxclass = entrie.second; if (nxclass == NXLOG) { handle.openGroup(nxname, nxclass); diff --git a/Framework/Nexus/src/NexusClasses.cpp b/Framework/Nexus/src/NexusClasses.cpp index f0266f90289c01b2342eec5c45e20a207610cb5a..de961c9889f5a191781c487211e68a83fdaf61bc 100644 --- a/Framework/Nexus/src/NexusClasses.cpp +++ b/Framework/Nexus/src/NexusClasses.cpp @@ -8,15 +8,15 @@ namespace NeXus { std::vector<std::string> NXAttributes::names() const { std::vector<std::string> out; - for (auto it = m_values.cbegin(); it != m_values.cend(); ++it) - out.push_back(it->first); + for (const auto &m_value : m_values) + out.push_back(m_value.first); return out; } std::vector<std::string> NXAttributes::values() const { std::vector<std::string> out; - for (auto it = m_values.begin(); it != m_values.end(); ++it) - out.push_back(it->second); + for (const auto &m_value : m_values) + out.push_back(m_value.second); return out; } diff --git a/Framework/Nexus/src/NexusFileIO.cpp b/Framework/Nexus/src/NexusFileIO.cpp index 784d92329233234c728af09671e909ea3aba7c38..4107952d0cdf2125650ebd1048d0cc76bc98e4b2 100644 --- a/Framework/Nexus/src/NexusFileIO.cpp +++ b/Framework/Nexus/src/NexusFileIO.cpp @@ -219,9 +219,9 @@ bool NexusFileIO::writeNxStringArray( int dimensions[2]; size_t maxlen = 0; dimensions[0] = static_cast<int>(values.size()); - for (size_t i = 0; i < values.size(); i++) - if (values[i].size() > maxlen) - maxlen = values[i].size(); + for (const auto &value : values) + if (value.size() > maxlen) + maxlen = value.size(); dimensions[1] = static_cast<int>(maxlen); NXstatus status = NXmakedata(fileID, name.c_str(), NX_CHAR, 2, dimensions); if (status == NX_ERROR) @@ -1057,8 +1057,8 @@ bool NexusFileIO::checkAttributeName(const std::string &target) const { // clang-format off const std::vector< ::NeXus::AttrInfo> infos = m_filehandle->getAttrInfos(); // clang-format on - for (auto it = infos.begin(); it != infos.end(); ++it) { - if (target.compare(it->name) == 0) + for (const auto &info : infos) { + if (target.compare(info.name) == 0) return true; } @@ -1141,9 +1141,9 @@ int NexusFileIO::findMantidWSEntries() const { // count int count = 0; std::map<std::string, std::string> entries = m_filehandle->getEntries(); - for (auto it = entries.begin(); it != entries.end(); ++it) { - if (it->second == "NXentry") { - if (it->first.find("mantid_workspace_") == 0) + for (auto &entrie : entries) { + if (entrie.second == "NXentry") { + if (entrie.first.find("mantid_workspace_") == 0) count++; } } @@ -1154,8 +1154,8 @@ int NexusFileIO::findMantidWSEntries() const { bool NexusFileIO::checkEntryAtLevel(const std::string &item) const { // Search the currently open level for name "item" std::map<std::string, std::string> entries = m_filehandle->getEntries(); - for (auto it = entries.begin(); it != entries.end(); ++it) { - if (it->first == item) + for (auto &entrie : entries) { + if (entrie.first == item) return true; } @@ -1167,13 +1167,13 @@ bool NexusFileIO::checkEntryAtLevelByAttribute(const std::string &attribute, // Search the currently open level for a section with "attribute" and return // entry name std::map<std::string, std::string> entries = m_filehandle->getEntries(); - for (auto it = entries.begin(); it != entries.end(); ++it) { - if (it->second == "SDS") { - m_filehandle->openData(it->first); + for (auto &entrie : entries) { + if (entrie.second == "SDS") { + m_filehandle->openData(entrie.first); bool result = checkAttributeName(attribute); m_filehandle->closeData(); if (result) { - entry = it->first; + entry = entrie.first; return true; } } @@ -1199,9 +1199,9 @@ bool NexusFileIO::writeNexusBinMasking( const API::MatrixWorkspace::MaskList &mList = ws->maskedBins(i); spectra.push_back(spectra_count); spectra.push_back(offset); - for (auto it = mList.cbegin(); it != mList.cend(); ++it) { - bins.push_back(it->first); - weights.push_back(it->second); + for (const auto &it : mList) { + bins.push_back(it.first); + weights.push_back(it.second); } ++spectra_count; offset += static_cast<int>(mList.size()); @@ -1304,9 +1304,9 @@ int getNexusEntryTypes(const std::string &fileName, } // for each entry found, look for "analysis" or "definition" text data fields // and return value plus entry name - for (size_t i = 0; i < entryList.size(); i++) { + for (auto &i : entryList) { // - stat = NXopengroup(fileH, entryList[i].c_str(), "NXentry"); + stat = NXopengroup(fileH, i.c_str(), "NXentry"); // loop through field names in this entry while ((stat = NXgetnextentry(fileH, nxname, nxclass, &nxdatatype)) == NX_OK) { @@ -1326,7 +1326,7 @@ int getNexusEntryTypes(const std::string &fileName, value[dims[0]] = '\0'; // return e.g entryName "analysis"/definition "muonTD" definition.push_back(value); - entryName.push_back(entryList[i]); + entryName.push_back(i); delete[] value; NXclosegroup(fileH); // close data group, then entry stat = NXclosegroup(fileH); diff --git a/Framework/RemoteAlgorithms/src/QueryAllRemoteJobs2.cpp b/Framework/RemoteAlgorithms/src/QueryAllRemoteJobs2.cpp index ebb53d0a943d56506b82f5cddcb6d15141a43ff6..d8c4798fefc5c3575719869271f09f158dfca28d 100644 --- a/Framework/RemoteAlgorithms/src/QueryAllRemoteJobs2.cpp +++ b/Framework/RemoteAlgorithms/src/QueryAllRemoteJobs2.cpp @@ -84,16 +84,16 @@ void QueryAllRemoteJobs2::exec() { std::vector<std::string> startDates; std::vector<std::string> completionDates; std::vector<std::string> cmdLine; - for (size_t j = 0; j < infos.size(); ++j) { - jobIds.push_back(infos[j].id); - jobNames.push_back(infos[j].name); - jobStatusStrs.push_back(infos[j].status); - transIds.push_back(infos[j].transactionID); - runNames.push_back(infos[j].runnableName); - submitDates.push_back(infos[j].submitDate.toISO8601String()); - startDates.push_back(infos[j].startDate.toISO8601String()); - completionDates.push_back(infos[j].completionTime.toISO8601String()); - cmdLine.push_back(infos[j].cmdLine); + for (auto &info : infos) { + jobIds.push_back(info.id); + jobNames.push_back(info.name); + jobStatusStrs.push_back(info.status); + transIds.push_back(info.transactionID); + runNames.push_back(info.runnableName); + submitDates.push_back(info.submitDate.toISO8601String()); + startDates.push_back(info.startDate.toISO8601String()); + completionDates.push_back(info.completionTime.toISO8601String()); + cmdLine.push_back(info.cmdLine); } setProperty("JobID", jobIds); setProperty("JobStatusString", jobStatusStrs); diff --git a/Framework/RemoteAlgorithms/src/QueryRemoteFile.cpp b/Framework/RemoteAlgorithms/src/QueryRemoteFile.cpp index 1866d01f12b7e810c2f60537bc0128f01ae47376..7883a6825a49cc06bc63f12bcaa6cf55d765e803 100644 --- a/Framework/RemoteAlgorithms/src/QueryRemoteFile.cpp +++ b/Framework/RemoteAlgorithms/src/QueryRemoteFile.cpp @@ -69,8 +69,8 @@ void QueryRemoteFile::exec() { std::vector<std::string> filenames; std::string oneFile; resp["Files"].getValue(files); - for (unsigned int i = 0; i < files.size(); i++) { - files[i].getValue(oneFile); + for (auto &file : files) { + file.getValue(oneFile); filenames.push_back(oneFile); } diff --git a/Framework/RemoteAlgorithms/src/SCARFTomoReconstruction.cpp b/Framework/RemoteAlgorithms/src/SCARFTomoReconstruction.cpp index 69ff52f1e778a92b707b625081097b257bd9582a..a8b97fcdeab40e98011be9dc03c524bf46e99651 100644 --- a/Framework/RemoteAlgorithms/src/SCARFTomoReconstruction.cpp +++ b/Framework/RemoteAlgorithms/src/SCARFTomoReconstruction.cpp @@ -1466,8 +1466,8 @@ void SCARFTomoReconstruction::getAllJobFiles(const std::string &jobId, while (std::getline(ss, PACname, ';')) { filePACNames.push_back(PACname); } - for (size_t i = 0; i < filePACNames.size(); i++) { - getOneJobFile(jobId, filePACNames[i], localDir, t); + for (auto &filePACName : filePACNames) { + getOneJobFile(jobId, filePACName, localDir, t); } } } else {