Commit 383f0acd authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Refs #14764. Reviewed changes through Framework/Algorithms/src/GetEi2.cpp.

parent fb49fa6f
......@@ -169,7 +169,7 @@ AlgorithmHistory::getChildAlgorithmHistory(const size_t index) const {
throw std::out_of_range(
"AlgorithmHistory::getAlgorithmHistory() - Index out of range");
}
auto start = m_childHistories.begin();
auto start = m_childHistories.cbegin();
std::advance(start, index);
return *start;
}
......
......@@ -149,8 +149,7 @@ void AlgorithmManagerImpl::setMaxAlgorithms(int n) {
*/
IAlgorithm_sptr AlgorithmManagerImpl::getAlgorithm(AlgorithmID id) const {
Mutex::ScopedLock _lock(this->m_managedMutex);
for (auto a = m_managed_algs.begin();
a != m_managed_algs.end(); ++a) {
for (auto a = m_managed_algs.cbegin(); a != m_managed_algs.cend(); ++a) {
if ((**a).getAlgorithmID() == id)
return *a;
}
......
......@@ -90,9 +90,8 @@ void Expression::add_operators(const std::vector<std::string> &ops) {
void Expression::add_unary(const std::set<std::string> &ops) {
m_operators->unary = ops;
for (auto it = ops.begin(); it != ops.end();
++it) {
for (std::string::const_iterator c = it->begin(); c != it->end(); ++c) {
for (auto it = ops.cbegin(); it != ops.cend(); ++it) {
for (auto c = it->cbegin(); c != it->cend(); ++c) {
m_operators->symbols.insert(*c);
}
}
......
......@@ -126,7 +126,7 @@ std::string FileFinderImpl::getFullPath(const std::string &filename,
const std::vector<std::string> &searchPaths =
Kernel::ConfigService::Instance().getDataSearchDirs();
for (auto it = searchPaths.begin(); it != searchPaths.end(); ++it) {
for (auto it = searchPaths.cbegin(); it != searchPaths.cend(); ++it) {
// On windows globbing is note working properly with network drives
// for example a network drive containing a $
// For this reason, and since windows is case insensitive anyway
......@@ -478,8 +478,8 @@ FileFinderImpl::findRun(const std::string &hintstr,
tolower);
if (!archiveOpt.empty() && archiveOpt != "off" &&
!facility.archiveSearch().empty()) {
for (auto it = facility.archiveSearch().begin();
it != facility.archiveSearch().end(); ++it) {
for (auto it = facility.archiveSearch().cbegin();
it != facility.archiveSearch().cend(); ++it) {
g_log.debug() << "get archive search for the facility..." << *it
<< "\n";
archs.push_back(ArchiveSearchFactory::Instance().create(*it));
......@@ -684,8 +684,7 @@ FileFinderImpl::getArchivePath(const std::vector<IArchiveSearch_sptr> &archs,
const std::set<std::string> &filenames,
const std::vector<std::string> &exts) const {
std::string path = "";
auto it = archs.begin();
for (; it != archs.end(); ++it) {
for (auto it = archs.cbegin(); it != archs.cend(); ++it) {
try {
path = (*it)->getArchivePath(filenames, exts);
if (!path.empty()) {
......@@ -748,8 +747,8 @@ FileFinderImpl::getPath(const std::vector<IArchiveSearch_sptr> &archs,
}
}
for (auto ext = extensions.begin(); ext != extensions.end(); ++ext) {
for (auto it = filenames.begin(); it != filenames.end(); ++it) {
for (auto ext = extensions.cbegin(); ext != extensions.cend(); ++ext) {
for (auto it = filenames.cbegin(); it != filenames.cend(); ++it) {
path = getFullPath(*it + *ext);
try {
if (!path.empty() && Poco::File(path).exists()) {
......
......@@ -227,10 +227,8 @@ bool FileProperty::extsMatchRunFiles() {
Kernel::FacilityInfo facilityInfo =
Kernel::ConfigService::Instance().getFacility();
const std::vector<std::string> facilityExts = facilityInfo.extensions();
auto facilityExtsBegin =
facilityExts.begin();
auto facilityExtsEnd =
facilityExts.end();
auto facilityExtsBegin = facilityExts.cbegin();
auto facilityExtsEnd = facilityExts.cend();
const std::vector<std::string> allowedExts = this->allowedValues();
for (auto it = allowedExts.begin(); it != allowedExts.end(); ++it) {
......
......@@ -83,7 +83,7 @@ IFunction_sptr FunctionFactoryImpl::createSimple(
}
const std::vector<Expression> &terms = expr.terms();
auto term = terms.begin();
auto term = terms.cbegin();
if (term->name() != "=")
inputError(expr.str());
......@@ -146,7 +146,7 @@ CompositeFunction_sptr FunctionFactoryImpl::createComposite(
}
const std::vector<Expression> &terms = expr.terms();
auto it = terms.begin();
auto it = terms.cbegin();
const Expression &term = it->bracketsRemoved();
CompositeFunction_sptr cfun;
......@@ -166,7 +166,7 @@ CompositeFunction_sptr FunctionFactoryImpl::createComposite(
inputError(expr.str());
}
} else if (term.name() == ",") {
auto firstTerm = term.terms().begin();
auto firstTerm = term.terms().cbegin();
if (firstTerm->name() == "=") {
if (firstTerm->terms()[0].name() == "composite") {
cfun = boost::dynamic_pointer_cast<CompositeFunction>(
......
......@@ -10,7 +10,7 @@ HistoryView::HistoryView(const WorkspaceHistory &wsHist)
: m_wsHist(wsHist), m_historyItems() {
// add all of the top level algorithms to the view by default
const auto algorithms = wsHist.getAlgorithmHistories();
for (auto iter = algorithms.begin(); iter != algorithms.end(); ++iter) {
for (auto iter = algorithms.cbegin(); iter != algorithms.cend(); ++iter) {
m_historyItems.emplace_back(*iter);
}
}
......
......@@ -146,9 +146,8 @@ Mantid::Geometry::VecIMDDimension_const_sptr
MDGeometry::getNonIntegratedDimensions() const {
using namespace Mantid::Geometry;
VecIMDDimension_const_sptr vecCollapsedDimensions;
auto it =
this->m_dimensions.begin();
for (; it != this->m_dimensions.end(); ++it) {
for (auto it = this->m_dimensions.cbegin(); it != this->m_dimensions.cend();
++it) {
IMDDimension_sptr current = (*it);
if (!current->getIsIntegrated()) {
vecCollapsedDimensions.push_back(current);
......
......@@ -519,8 +519,7 @@ void MatrixWorkspace::getDetectorIDToWorkspaceIndexVector(
// Allow multiple detectors per workspace index, or,
// If only one is allowed, then this has thrown already
for (auto it = detList.begin();
it != detList.end(); ++it) {
for (auto it = detList.cbegin(); it != detList.cend(); ++it) {
int index = *it + offset;
if (index < 0 || index >= outSize) {
g_log.debug() << "MatrixWorkspace::getDetectorIDToWorkspaceIndexVector("
......@@ -550,8 +549,8 @@ void MatrixWorkspace::getIndicesFromSpectra(
indexList.clear();
indexList.reserve(this->getNumberHistograms());
auto iter = spectraList.begin();
while (iter != spectraList.end()) {
auto iter = spectraList.cbegin();
while (iter != spectraList.cend()) {
for (size_t i = 0; i < this->getNumberHistograms(); ++i) {
if (this->getSpectrum(i)->getSpectrumNo() == *iter) {
indexList.push_back(i);
......@@ -1013,8 +1012,7 @@ void MatrixWorkspace::maskWorkspaceIndex(const std::size_t index) {
spec->clearData();
const std::set<detid_t> dets = spec->getDetectorIDs();
for (auto iter = dets.begin();
iter != dets.end(); ++iter) {
for (auto iter = dets.cbegin(); iter != dets.cend(); ++iter) {
try {
if (const Geometry::Detector *det =
dynamic_cast<const Geometry::Detector *>(
......@@ -1235,8 +1233,7 @@ size_t MatrixWorkspace::binIndexOf(const double xValue,
throw std::out_of_range("MatrixWorkspace::binIndexOf - X value lower than "
"lowest in current range.");
}
auto lowit =
std::lower_bound(xValues.begin(), xValues.end(), xValue);
auto lowit = std::lower_bound(xValues.cbegin(), xValues.cend(), xValue);
if (lowit == xValues.end()) {
throw std::out_of_range("MatrixWorkspace::binIndexOf - X value greater "
"than highest in current range.");
......@@ -1564,7 +1561,7 @@ signal_t MatrixWorkspace::getSignalAtCoord(
if (wi < nhist) {
const MantidVec &X = this->readX(wi);
auto it = std::lower_bound(X.begin(), X.end(), x);
auto it = std::lower_bound(X.cbegin(), X.cend(), x);
if (it == X.end()) {
// Out of range
return std::numeric_limits<double>::quiet_NaN();
......
......@@ -154,7 +154,7 @@ std::vector<std::string> MultipleFileProperty::flattenFileNames(
const std::vector<std::vector<std::string>> &fileNames) {
std::vector<std::string> flattenedFileNames;
for (auto it = fileNames.begin(); it != fileNames.end(); ++it) {
for (auto it = fileNames.cbegin(); it != fileNames.cend(); ++it) {
flattenedFileNames.insert(flattenedFileNames.end(), it->begin(), it->end());
}
......
......@@ -152,8 +152,8 @@ double ParamFunction::getParameter(const std::string &name) const {
std::string ucName(name);
// std::transform(name.begin(), name.end(), ucName.begin(), toupper);
auto it =
std::find(m_parameterNames.begin(), m_parameterNames.end(), ucName);
if (it == m_parameterNames.end()) {
std::find(m_parameterNames.cbegin(), m_parameterNames.cend(), ucName);
if (it == m_parameterNames.cend()) {
std::ostringstream msg;
msg << "ParamFunction tries to get value of non-existing parameter ("
<< ucName << ") "
......@@ -164,7 +164,7 @@ double ParamFunction::getParameter(const std::string &name) const {
throw std::invalid_argument(msg.str());
}
double parvalue = m_parameters[it - m_parameterNames.begin()];
double parvalue = m_parameters[it - m_parameterNames.cbegin()];
if (parvalue != parvalue || !(parvalue > -DBL_MAX && parvalue < DBL_MAX)) {
g_log.warning() << "Parameter " << name << " has a NaN or infinity value "
......@@ -183,14 +183,14 @@ size_t ParamFunction::parameterIndex(const std::string &name) const {
std::string ucName(name);
// std::transform(name.begin(), name.end(), ucName.begin(), toupper);
auto it =
std::find(m_parameterNames.begin(), m_parameterNames.end(), ucName);
if (it == m_parameterNames.end()) {
std::find(m_parameterNames.cbegin(), m_parameterNames.cend(), ucName);
if (it == m_parameterNames.cend()) {
std::ostringstream msg;
msg << "ParamFunction " << this->name() << " does not have parameter ("
<< ucName << ").";
throw std::invalid_argument(msg.str());
}
return int(it - m_parameterNames.begin());
return std::distance(m_parameterNames.cbegin(), it);
}
/** Returns the name of parameter i
......@@ -368,9 +368,8 @@ ParameterTie *ParamFunction::getTie(size_t i) const {
if (i >= nParams()) {
throw std::out_of_range("ParamFunction parameter index out of range.");
}
auto it =
std::find_if(m_ties.begin(), m_ties.end(), ReferenceEqual(i));
if (it != m_ties.end()) {
auto it = std::find_if(m_ties.cbegin(), m_ties.cend(), ReferenceEqual(i));
if (it != m_ties.cend()) {
return *it;
}
return NULL;
......@@ -416,9 +415,9 @@ IConstraint *ParamFunction::getConstraint(size_t i) const {
if (i >= nParams()) {
throw std::out_of_range("ParamFunction parameter index out of range.");
}
auto it = std::find_if(
m_constraints.begin(), m_constraints.end(), ReferenceEqual(i));
if (it != m_constraints.end()) {
auto it = std::find_if(m_constraints.cbegin(), m_constraints.cend(),
ReferenceEqual(i));
if (it != m_constraints.cend()) {
return *it;
}
return NULL;
......
......@@ -75,9 +75,8 @@ std::ostream &operator<<(std::ostream &s, const TableRow &row) {
row.m_columns[0]->print(row.row(), s);
return s;
}
auto ci =
row.m_columns.begin();
for (; ci != row.m_columns.end() - 1; ++ci) {
auto ci = row.m_columns.cbegin();
for (; ci != row.m_columns.cend() - 1; ++ci) {
(*ci)->print(row.row(), s);
s << row.m_sep;
}
......
......@@ -331,7 +331,7 @@ bool WorkspaceGroup::isMultiperiod() const {
return false;
}
// Loop through all inner workspaces, checking each one in turn.
for (auto iterator = m_workspaces.begin(); iterator != m_workspaces.end();
for (auto iterator = m_workspaces.cbegin(); iterator != m_workspaces.cend();
++iterator) {
if (MatrixWorkspace_sptr ws =
boost::dynamic_pointer_cast<MatrixWorkspace>(*iterator)) {
......
......@@ -95,7 +95,7 @@ WorkspaceHistory::getAlgorithmHistory(const size_t index) const {
throw std::out_of_range(
"WorkspaceHistory::getAlgorithmHistory() - Index out of range");
}
auto start = m_algorithms.begin();
auto start = m_algorithms.cbegin();
std::advance(start, index);
return *start;
}
......@@ -180,7 +180,7 @@ void WorkspaceHistory::saveNexus(::NeXus::File *file) const {
// Algorithm History
int algCount = 0;
for (auto histIter = m_algorithms.begin(); histIter != m_algorithms.end();
for (auto histIter = m_algorithms.cbegin(); histIter != m_algorithms.cend();
++histIter) {
(*histIter)->saveNexus(file, algCount);
}
......
......@@ -76,10 +76,10 @@ private:
void parseStringToVector(std::string liststr, std::vector<detid_t> &detidvec);
/// Extract mask from a workspace to a list of detectors
void extractMaskFromMatrixWorkspace(std::vector<detid_t> &maskeddetids);
std::vector<detid_t> extractMaskFromMatrixWorkspace();
/// Extract masked detectors from a MaskWorkspace
void extractMaskFromMaskWorkspace(std::vector<detid_t> &maskeddetids);
std::vector<detid_t> extractMaskFromMaskWorkspace();
/// Copy table workspace content from one workspace to another
void copyTableWorkspaceContent(DataObjects::TableWorkspace_sptr sourceWS,
......
......@@ -684,16 +684,15 @@ API::MatrixWorkspace_sptr ConvertUnits::removeUnphysicalBins(
}
// Get an X spectrum to search (they're all the same, monitors excepted)
const MantidVec &X0 = workspace->readX(i);
auto start =
std::lower_bound(X0.begin(), X0.end(), -1.0e-10 * DBL_MAX);
auto start = std::lower_bound(X0.cbegin(), X0.cend(), -1.0e-10 * DBL_MAX);
if (start == X0.end()) {
const std::string e("Check the input EFixed: the one given leads to all "
"bins being in the physically inaccessible region.");
g_log.error(e);
throw std::invalid_argument(e);
}
MantidVec::difference_type bins = X0.end() - start;
MantidVec::difference_type first = start - X0.begin();
MantidVec::difference_type bins = X0.cend() - start;
MantidVec::difference_type first = start - X0.cbegin();
result =
WorkspaceFactory::Instance().create(workspace, numSpec, bins, bins - 1);
......@@ -717,9 +716,8 @@ API::MatrixWorkspace_sptr ConvertUnits::removeUnphysicalBins(
int maxBins = 0;
for (size_t i = 0; i < numSpec; ++i) {
const MantidVec &X = workspace->readX(i);
auto end =
std::lower_bound(X.begin(), X.end(), 1.0e-10 * DBL_MAX);
MantidVec::difference_type bins = end - X.begin();
auto end = std::lower_bound(X.cbegin(), X.cend(), 1.0e-10 * DBL_MAX);
MantidVec::difference_type bins = end - X.cbegin();
lastBins[i] = bins;
if (bins > maxBins)
maxBins = static_cast<int>(bins);
......
......@@ -647,16 +647,15 @@ API::MatrixWorkspace_sptr ConvertUnitsUsingDetectorTable::removeUnphysicalBins(
}
// Get an X spectrum to search (they're all the same, monitors excepted)
const MantidVec &X0 = workspace->readX(i);
auto start =
std::lower_bound(X0.begin(), X0.end(), -1.0e-10 * DBL_MAX);
if (start == X0.end()) {
auto start = std::lower_bound(X0.cbegin(), X0.cend(), -1.0e-10 * DBL_MAX);
if (start == X0.cend()) {
const std::string e("Check the input EFixed: the one given leads to all "
"bins being in the physically inaccessible region.");
g_log.error(e);
throw std::invalid_argument(e);
}
MantidVec::difference_type bins = X0.end() - start;
MantidVec::difference_type first = start - X0.begin();
MantidVec::difference_type bins = X0.cend() - start;
MantidVec::difference_type first = start - X0.cbegin();
result =
WorkspaceFactory::Instance().create(workspace, numSpec, bins, bins - 1);
......@@ -680,9 +679,8 @@ API::MatrixWorkspace_sptr ConvertUnitsUsingDetectorTable::removeUnphysicalBins(
int maxBins = 0;
for (size_t i = 0; i < numSpec; ++i) {
const MantidVec &X = workspace->readX(i);
auto end =
std::lower_bound(X.begin(), X.end(), 1.0e-10 * DBL_MAX);
MantidVec::difference_type bins = end - X.begin();
auto end = std::lower_bound(X.cbegin(), X.cend(), 1.0e-10 * DBL_MAX);
MantidVec::difference_type bins = end - X.cbegin();
lastBins[i] = bins;
if (bins > maxBins)
maxBins = static_cast<int>(bins);
......
......@@ -97,8 +97,7 @@ void CorrectToFile::exec() {
const double currentX =
histogramData ? (xIn[j] + xIn[j + 1]) / 2.0 : xIn[j];
// Find out the index of the first correction point after this value
auto pos =
std::lower_bound(Xcor.begin(), Xcor.end(), currentX);
auto pos = std::lower_bound(Xcor.cbegin(), Xcor.cend(), currentX);
const size_t index = pos - Xcor.begin();
if (index == Xcor.size()) {
// If we're past the end of the correction factors vector, use the
......
......@@ -222,8 +222,7 @@ void CreateCalFileByNames::saveGroupingFile(const std::string &filename,
}
} else //
{
auto it = instrcalib.begin();
for (; it != instrcalib.end(); ++it)
for (auto it = instrcalib.cbegin(); it != instrcalib.cend(); ++it)
writeCalEntry(outfile, (*it).first, ((*it).second).first, 0.0, 1,
((*it).second).second);
}
......
......@@ -223,8 +223,7 @@ void CreateDummyCalFile::saveGroupingFile(const std::string &filename,
}
} else //
{
auto it = instrcalib.begin();
for (; it != instrcalib.end(); ++it)
for (auto it = instrcalib.cbegin(); it != instrcalib.cend(); ++it)
writeCalEntry(outfile, (*it).first, ((*it).second).first, 0.0, 1,
((*it).second).second);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment