diff --git a/Framework/API/inc/MantidAPI/AlgorithmFactory.h b/Framework/API/inc/MantidAPI/AlgorithmFactory.h index 4e35e283e1f853b1f9a356224c706d8718316ab7..c8c68b4fcb0e2f9bd9182d11d3766ca0cec7781f 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmFactory.h +++ b/Framework/API/inc/MantidAPI/AlgorithmFactory.h @@ -5,7 +5,7 @@ // Includes //---------------------------------------------------------------------- #include <vector> -#include <set> +#include <unordered_set> #include <sstream> #include "MantidAPI/DllConfig.h" #include "MantidKernel/DynamicFactory.h" @@ -126,7 +126,8 @@ public: int highestVersion(const std::string &algorithmName) const; /// Get the algorithm categories - const std::set<std::string> getCategories(bool includeHidden = false) const; + const std::unordered_set<std::string> + getCategories(bool includeHidden = false) const; /// Get the algorithm categories const std::map<std::string, bool> getCategoriesWithState() const; @@ -162,7 +163,7 @@ private: /// creates an algorithm name convolved from an name and version std::string createName(const std::string &, const int &) const; /// fills a set with the hidden categories - void fillHiddenCategories(std::set<std::string> *categorySet) const; + void fillHiddenCategories(std::unordered_set<std::string> *categorySet) const; /// A typedef for the map of algorithm versions typedef std::map<std::string, int> VersionMap; diff --git a/Framework/API/inc/MantidAPI/Expression.h b/Framework/API/inc/MantidAPI/Expression.h index f5addaab581d4eb4ddca4130c007f41dd87d7cdf..e7229bd668bde377c41ecf386f9c91d1b4c6d16f 100644 --- a/Framework/API/inc/MantidAPI/Expression.h +++ b/Framework/API/inc/MantidAPI/Expression.h @@ -10,7 +10,7 @@ #include <string> #include <vector> #include <map> -#include <set> +#include <unordered_set> namespace Mantid { namespace API { @@ -56,7 +56,7 @@ public: Expression(const std::vector<std::string> &ops); /// contructor Expression(const std::vector<std::string> &binary, - const std::set<std::string> &unary); + const std::unordered_set<std::string> &unary); /// copy contructor Expression(const Expression &expr); /// Assignment operator @@ -104,7 +104,7 @@ public: /// This method returns first sub-expression without brackets const Expression &bracketsRemoved() const; /// Return a list of all variable names in this expression - std::set<std::string> getVariables() const; + std::unordered_set<std::string> getVariables() const; /** * Rename all variables with a given name * @param oldName :: The old name @@ -192,10 +192,10 @@ private: struct Operators { std::vector<std::string> binary; ///< Binary operators in reverse precedence order - std::set<std::string> unary; ///< Unary operators + std::unordered_set<std::string> unary; ///< Unary operators std::map<std::string, size_t> precedence; ///< Map of the operator precedence order - std::set<char> + std::unordered_set<char> symbols; ///< All the symbols that are used in the binary operators std::map<std::string, char> op_number; ///< map of operators }; @@ -215,7 +215,7 @@ private: * Adds new unary operators to the expression * @param ops :: A vector with unary operators */ - void add_unary(const std::set<std::string> &ops); + void add_unary(const std::unordered_set<std::string> &ops); /** * Check if a string is a unary operator * @param op :: The string to check diff --git a/Framework/API/inc/MantidAPI/WorkspaceProperty.h b/Framework/API/inc/MantidAPI/WorkspaceProperty.h index 2e992ede0e730a663f0634873770575ef6dafe41..6bdb1bbe503d89a889e6c946fe06315c749c20c4 100644 --- a/Framework/API/inc/MantidAPI/WorkspaceProperty.h +++ b/Framework/API/inc/MantidAPI/WorkspaceProperty.h @@ -322,8 +322,7 @@ public: if (this->direction() == Kernel::Direction::Input || this->direction() == Kernel::Direction::InOut) { // If an input workspace, get the list of workspaces currently in the ADS - std::set<std::string> vals = - AnalysisDataService::Instance().getObjectNames(); + auto vals = AnalysisDataService::Instance().getObjectNames(); if (isOptional()) // Insert an empty option { vals.insert(""); @@ -331,8 +330,7 @@ public: // Copy-construct a temporary workspace property to test the validity of // each workspace WorkspaceProperty<TYPE> tester(*this); - std::set<std::string>::iterator it; - for (it = vals.begin(); it != vals.end();) { + for (auto it = vals.begin(); it != vals.end();) { // Remove any workspace that's not valid for this algorithm if (!tester.setValue(*it).empty()) { vals.erase( diff --git a/Framework/API/src/AlgorithmFactory.cpp b/Framework/API/src/AlgorithmFactory.cpp index b61325935d5572202d9aa7b5dd3e8ea684c2b63b..510801beece5b076ab93e5b97b29a881515acb32 100644 --- a/Framework/API/src/AlgorithmFactory.cpp +++ b/Framework/API/src/AlgorithmFactory.cpp @@ -178,7 +178,7 @@ AlgorithmFactoryImpl::getKeys(bool includeHidden) const { return names; } else { // hidden categories - std::set<std::string> hiddenCategories; + std::unordered_set<std::string> hiddenCategories; fillHiddenCategories(&hiddenCategories); // strip out any algorithms names where all of the categories are hidden @@ -245,7 +245,7 @@ AlgorithmFactoryImpl::getCategoriesWithState() const { std::map<std::string, bool> resultCategories; // hidden categories - empty initially - std::set<std::string> hiddenCategories; + std::unordered_set<std::string> hiddenCategories; fillHiddenCategories(&hiddenCategories); // get all of the algorithm keys, including the hidden ones for speed purposes @@ -287,20 +287,18 @@ AlgorithmFactoryImpl::getCategoriesWithState() const { * the default is false * @returns The category strings */ -const std::set<std::string> +const std::unordered_set<std::string> AlgorithmFactoryImpl::getCategories(bool includeHidden) const { - std::set<std::string> validCategories; + std::unordered_set<std::string> validCategories; // get all of the information we need - std::map<std::string, bool> categoryMap = getCategoriesWithState(); + auto categoryMap = getCategoriesWithState(); // iterate around the map - std::map<std::string, bool>::const_iterator it_end = categoryMap.end(); - for (std::map<std::string, bool>::const_iterator it = categoryMap.begin(); - it != it_end; ++it) { - bool isHidden = (*it).second; + for (auto const &category : categoryMap) { + bool isHidden = (category).second; if (includeHidden || (!isHidden)) { - validCategories.insert((*it).first); + validCategories.insert((category).first); } } @@ -319,20 +317,18 @@ AlgorithmFactoryImpl::getCategories(bool includeHidden) const { std::vector<Algorithm_descriptor> AlgorithmFactoryImpl::getDescriptors(bool includeHidden) const { // algorithm names - std::vector<std::string> sv; - sv = getKeys(true); + auto sv = getKeys(true); // hidden categories - std::set<std::string> hiddenCategories; - if (includeHidden == false) { + std::unordered_set<std::string> hiddenCategories; + if (!includeHidden) { fillHiddenCategories(&hiddenCategories); } // results vector std::vector<Algorithm_descriptor> res; - for (std::vector<std::string>::const_iterator s = sv.begin(); s != sv.end(); - ++s) { + for (auto s = sv.cbegin(); s != sv.cend(); ++s) { if (s->empty()) continue; Algorithm_descriptor desc; @@ -348,7 +344,7 @@ AlgorithmFactoryImpl::getDescriptors(bool includeHidden) const { continue; boost::shared_ptr<IAlgorithm> alg = create(desc.name, desc.version); - std::vector<std::string> categories = alg->categories(); + auto categories = alg->categories(); desc.alias = alg->alias(); // For each category @@ -387,7 +383,7 @@ AlgorithmFactoryImpl::getDescriptors(bool includeHidden) const { } void AlgorithmFactoryImpl::fillHiddenCategories( - std::set<std::string> *categorySet) const { + std::unordered_set<std::string> *categorySet) const { std::string categoryString = Kernel::ConfigService::Instance().getString( "algorithms.categories.hidden"); Mantid::Kernel::StringTokenizer tokenizer( diff --git a/Framework/API/src/ExperimentInfo.cpp b/Framework/API/src/ExperimentInfo.cpp index 913b1c625fe2d7ad92052dae231a76dc6895102f..29a1e8d51473949c8a495e4603b8ddddaa2606d7 100644 --- a/Framework/API/src/ExperimentInfo.cpp +++ b/Framework/API/src/ExperimentInfo.cpp @@ -790,18 +790,14 @@ std::string ExperimentInfo::getAvailableWorkspaceEndDate() const { //--------------------------------------------------------------------------------------- /** A given instrument may have multiple IDFs associated with it. This method -*return an -* identifier which identify a given IDF for a given instrument. An IDF filename -*is -* required to be of the form IDFname + _Definition + Identifier + .xml, the -*identifier -* then is the part of a filename that identifies the IDF valid at a given date. +*return an identifier which identify a given IDF for a given instrument. +* An IDF filename is required to be of the form IDFname + _Definition + +*Identifier + .xml, the identifier then is the part of a filename that +*identifies the IDF valid at a given date. * * If several IDF files are valid at the given date the file with the most -*recent from -* date is selected. If no such files are found the file with the latest from -*date is -* selected. +*recent from date is selected. If no such files are found the file with the +*latest from date is selected. * * If no file is found for the given instrument, an empty string is returned. * diff --git a/Framework/API/src/Expression.cpp b/Framework/API/src/Expression.cpp index 38af9a12770104f399f976821de44d7a54edeec1..ec8ba7247905b98852c8cd68caa01b1f7ad6f9ff 100644 --- a/Framework/API/src/Expression.cpp +++ b/Framework/API/src/Expression.cpp @@ -24,7 +24,7 @@ Expression::Expression() { add_operators(ops); // Define unary operators - std::set<std::string> unary; + std::unordered_set<std::string> unary; unary.insert("+"); unary.insert("-"); @@ -39,7 +39,7 @@ Expression::Expression(const std::vector<std::string> &ops) { /// contructor Expression::Expression(const std::vector<std::string> &binary, - const std::set<std::string> &unary) { + const std::unordered_set<std::string> &unary) { m_operators.reset(new Operators()); add_operators(binary); add_unary(unary); @@ -86,7 +86,7 @@ void Expression::add_operators(const std::vector<std::string> &ops) { } } -void Expression::add_unary(const std::set<std::string> &ops) { +void Expression::add_unary(const std::unordered_set<std::string> &ops) { m_operators->unary = ops; for (const auto &op : ops) { m_operators->symbols.insert(op.cbegin(), op.cend()); @@ -479,8 +479,8 @@ const Expression &Expression::bracketsRemoved() const { /** * Return a list of all variable names in this expression */ -std::set<std::string> Expression::getVariables() const { - std::set<std::string> out; +std::unordered_set<std::string> Expression::getVariables() const { + std::unordered_set<std::string> out; if (!isFunct()) { std::string s = name(); if (!s.empty() && !isdigit(s[0])) { @@ -489,7 +489,7 @@ std::set<std::string> Expression::getVariables() const { } else { for (const auto &e : *this) { if (e.isFunct()) { - std::set<std::string> tout = e.getVariables(); + std::unordered_set<std::string> tout = e.getVariables(); out.insert(tout.begin(), tout.end()); } else { std::string s = e.name(); diff --git a/Framework/API/src/MatrixWorkspace.cpp b/Framework/API/src/MatrixWorkspace.cpp index edffa4fe94aeb25c787503597aabf0403a7b6cca..a1cc342bf580fdaa107b5caba621f79d7ef0c6ac 100644 --- a/Framework/API/src/MatrixWorkspace.cpp +++ b/Framework/API/src/MatrixWorkspace.cpp @@ -760,7 +760,7 @@ MatrixWorkspace::getDetector(const size_t workspaceIndex) const { "workspace index.", ""); - const std::set<detid_t> &dets = spec->getDetectorIDs(); + const auto &dets = spec->getDetectorIDs(); Instrument_const_sptr localInstrument = getInstrument(); if (!localInstrument) { g_log.debug() << "No instrument defined.\n"; @@ -1011,7 +1011,7 @@ void MatrixWorkspace::maskWorkspaceIndex(const std::size_t index) { // Virtual method clears the spectrum as appropriate spec->clearData(); - const std::set<detid_t> dets = spec->getDetectorIDs(); + const auto dets = spec->getDetectorIDs(); for (auto detId : dets) { try { if (const Geometry::Detector *det = @@ -1656,7 +1656,7 @@ void MatrixWorkspace::saveSpectraMapNexus( spectra[i] = int32_t(spectrum->getSpectrumNo()); // The detectors in this spectrum - const std::set<detid_t> &detectorgroup = spectrum->getDetectorIDs(); + const auto &detectorgroup = spectrum->getDetectorIDs(); const int ndet1 = static_cast<int>(detectorgroup.size()); detector_index[i + 1] = int32_t( diff --git a/Framework/API/src/SpectrumDetectorMapping.cpp b/Framework/API/src/SpectrumDetectorMapping.cpp index e54a293581ee99bd664204d4438ffb0e44944dfc..de51be6d8740cb89bbbf3e80317cbd29f72fc4bd 100644 --- a/Framework/API/src/SpectrumDetectorMapping.cpp +++ b/Framework/API/src/SpectrumDetectorMapping.cpp @@ -104,7 +104,7 @@ std::set<specid_t> SpectrumDetectorMapping::getSpectrumNumbers() const { const std::set<detid_t> &SpectrumDetectorMapping::getDetectorIDsForSpectrumNo( const specid_t spectrumNo) const { if (!m_indexIsSpecNo) - throw std::runtime_error("Indicies are in spectrum index, not number."); + throw std::runtime_error("Indices are in spectrum index, not number."); return m_mapping.at(spectrumNo); } @@ -112,7 +112,7 @@ const std::set<detid_t> & SpectrumDetectorMapping::getDetectorIDsForSpectrumIndex( const size_t spectrumIndex) const { if (m_indexIsSpecNo) - throw std::runtime_error("Indicies are in spectrum number, not index."); + throw std::runtime_error("Indices are in spectrum number, not index."); return m_mapping.at(static_cast<int>(spectrumIndex)); } diff --git a/Framework/API/test/AlgorithmFactoryTest.h b/Framework/API/test/AlgorithmFactoryTest.h index a1b841fd2b96bd38fe346cf25dd4d05ec8582d0f..5b8554ffec077924949bcb0eee0cd6eb4e242ac5 100644 --- a/Framework/API/test/AlgorithmFactoryTest.h +++ b/Framework/API/test/AlgorithmFactoryTest.h @@ -189,7 +189,7 @@ public: void testGetCategories() { AlgorithmFactory::Instance().subscribe<CategoryAlgorithm>(); - std::set<std::string> validCategories; + std::unordered_set<std::string> validCategories; TS_ASSERT_THROWS_NOTHING( validCategories = AlgorithmFactory::Instance().getCategories(true)); diff --git a/Framework/API/test/ExperimentInfoTest.h b/Framework/API/test/ExperimentInfoTest.h index dcfed7df77a813ecd88ed7028990304f8050a955..4dac282c5f6c3d4ed00503575252dadb18aa8419 100644 --- a/Framework/API/test/ExperimentInfoTest.h +++ b/Framework/API/test/ExperimentInfoTest.h @@ -26,6 +26,7 @@ #include <Poco/DirectoryIterator.h> #include <set> +#include <unordered_map> using namespace Mantid::API; using namespace Mantid::Kernel; @@ -464,8 +465,8 @@ public: // Collect all IDF filenames and put them in a multimap where the instrument // identifier is the key - std::multimap<std::string, fromToEntry> idfFiles; - std::set<std::string> idfIdentifiers; + std::unordered_multimap<std::string, fromToEntry> idfFiles; + std::unordered_set<std::string> idfIdentifiers; boost::regex regex(".*_Definition.*\\.xml", boost::regex_constants::icase); Poco::DirectoryIterator end_iter; @@ -498,12 +499,11 @@ public: } // iterator to browse through the multimap: paramInfoFromIDF - std::multimap<std::string, fromToEntry>::const_iterator it1, it2; - std::pair<std::multimap<std::string, fromToEntry>::iterator, - std::multimap<std::string, fromToEntry>::iterator> ret; + std::unordered_multimap<std::string, fromToEntry>::const_iterator it1, it2; + std::pair<std::unordered_multimap<std::string, fromToEntry>::iterator, + std::unordered_multimap<std::string, fromToEntry>::iterator> ret; - std::set<std::string>::iterator setIt; - for (setIt = idfIdentifiers.begin(); setIt != idfIdentifiers.end(); + for (auto setIt = idfIdentifiers.begin(); setIt != idfIdentifiers.end(); setIt++) { ret = idfFiles.equal_range(*setIt); for (it1 = ret.first; it1 != ret.second; ++it1) { diff --git a/Framework/API/test/ExpressionTest.h b/Framework/API/test/ExpressionTest.h index 44db56d28e15286a6d542c0c945c6a8080cf3fae..752376ed88f8f10bfc43295c99c98f640325ea79 100644 --- a/Framework/API/test/ExpressionTest.h +++ b/Framework/API/test/ExpressionTest.h @@ -171,7 +171,7 @@ public: TS_ASSERT_EQUALS(e4[1].name(), "+"); std::vector<std::string> bin_ops{"="}; - std::set<std::string> un_ops{"!", "%%"}; + std::unordered_set<std::string> un_ops{"!", "%%"}; Expression e5(bin_ops, un_ops); TS_ASSERT_THROWS_NOTHING(e5.parse("x=!1")); @@ -206,7 +206,7 @@ public: TS_ASSERT_EQUALS(e8[1].name(), "%%"); std::vector<std::string> bin_ops1{"=="}; - std::set<std::string> un_ops1{"!", "%%"}; + std::unordered_set<std::string> un_ops1{"!", "%%"}; Expression e9(bin_ops1, un_ops1); TS_ASSERT_THROWS_NOTHING(e9.parse("x==!1")); @@ -247,7 +247,7 @@ public: TS_ASSERT_THROWS(e14.parse("x==%% "), std::runtime_error); std::vector<std::string> bin_ops2{"-", "--"}; - std::set<std::string> un_ops2{"-", "--"}; + std::unordered_set<std::string> un_ops2{"-", "--"}; Expression e15(bin_ops2, un_ops2); TS_ASSERT_THROWS_NOTHING(e15.parse("x--1")); @@ -339,7 +339,7 @@ public: void testGetVariables() { Expression e; e.parse("a+b*sin(x)*fun1(fun2(a+c))"); - std::set<std::string> vars = e.getVariables(); + std::unordered_set<std::string> vars = e.getVariables(); TS_ASSERT_EQUALS(vars.size(), 4); TS_ASSERT(vars.find("a") != vars.end()); TS_ASSERT(vars.find("b") != vars.end()); diff --git a/Framework/API/test/FilePropertyTest.h b/Framework/API/test/FilePropertyTest.h index 971bb99a7ad20d244fcd2d9a4565697d683722ea..efd2256f2e51dc7c2dd102e31e1a44059a9cb4e0 100644 --- a/Framework/API/test/FilePropertyTest.h +++ b/Framework/API/test/FilePropertyTest.h @@ -144,7 +144,7 @@ public: ConfigService::Instance().setString("default.instrument", "LOQ"); error = fp.setValue("25654"); TS_ASSERT_EQUALS(error, ""); - TS_ASSERT(fp.value().find("LOQ25654") != std::string::npos); + TS_ASSERT_DIFFERS(fp.value().find("LOQ25654"), std::string::npos); fileFinder.setCaseSensitive(startingCaseOption); } diff --git a/Framework/API/test/InstrumentDataServiceTest.h b/Framework/API/test/InstrumentDataServiceTest.h index 034b18bd9e3e82e909e45ebd6126a6385e930378..6826175e0531b55631b125abc43e9b0c72123fcf 100644 --- a/Framework/API/test/InstrumentDataServiceTest.h +++ b/Framework/API/test/InstrumentDataServiceTest.h @@ -99,11 +99,10 @@ public: void testGetObjectNames() { InstrumentDataService::Instance().add("inst2", inst2); - std::set<std::string> names; + std::unordered_set<std::string> names; names.insert("inst1"); names.insert("inst2"); - std::set<std::string> result; - result = InstrumentDataService::Instance().getObjectNames(); + auto result = InstrumentDataService::Instance().getObjectNames(); TS_ASSERT_EQUALS(result, names); // Check with an empty store InstrumentDataService::Instance().clear(); diff --git a/Framework/API/test/MultipleFilePropertyTest.h b/Framework/API/test/MultipleFilePropertyTest.h index f8a6c09bb5e19e8f67830c394bbb0d69c30f5728..7ebe06dc06b87b60e5486f81cfe63c183c8539c1 100644 --- a/Framework/API/test/MultipleFilePropertyTest.h +++ b/Framework/API/test/MultipleFilePropertyTest.h @@ -13,6 +13,7 @@ #include <Poco/File.h> #include <boost/algorithm/string/join.hpp> +#include <unordered_set> using namespace Mantid; using namespace Mantid::API; @@ -45,11 +46,10 @@ std::string createAbsoluteDirectory(const std::string &dirPath) { * @param filenames :: the names of the files to create. * @param dirPath :: the directory in which to create the files. */ -void createFilesInDirectory(const std::set<std::string> &filenames, +void createFilesInDirectory(const std::unordered_set<std::string> &filenames, const std::string &dirPath) { - for (auto filename = filenames.begin(); filename != filenames.end(); - ++filename) { - Poco::File file(dirPath + "/" + *filename); + for (const auto &filename : filenames) { + Poco::File file(dirPath + "/" + filename); file.createFile(); } } @@ -73,7 +73,7 @@ private: std::string m_oldDefaultInstrument; std::string m_dummyFilesDir; std::string m_dirWithWhitespace; - std::set<std::string> m_tempDirs; + std::unordered_set<std::string> m_tempDirs; std::vector<std::string> m_exts; Mantid::Kernel::ConfigServiceImpl &g_config; @@ -104,7 +104,7 @@ public: m_tempDirs.insert(m_dummyFilesDir); m_tempDirs.insert(m_dirWithWhitespace); - std::set<std::string> dummyFilenames = { + std::unordered_set<std::string> dummyFilenames = { // Standard raw file runs. "TSC00001.raw", "TSC00002.raw", "TSC00003.raw", "TSC00004.raw", "TSC00005.raw", @@ -131,7 +131,8 @@ public: // when multifileloading is turned off via the preferences file. "_test_multiFileLoadingSwitchedOff_tempFileWithA+AndA,InTheName.txt"}; - std::set<std::string> whiteSpaceDirFilenames = {"file with whitespace.txt"}; + std::unordered_set<std::string> whiteSpaceDirFilenames = { + "file with whitespace.txt"}; createFilesInDirectory(dummyFilenames, m_dummyFilesDir); createFilesInDirectory(whiteSpaceDirFilenames, m_dummyFilesDir); @@ -144,9 +145,8 @@ public: */ ~MultipleFilePropertyTest() { // Remove temp dirs. - for (auto tempDir = m_tempDirs.begin(); tempDir != m_tempDirs.end(); - ++tempDir) { - Poco::File dir(*tempDir); + for (const auto &tempDir : m_tempDirs) { + Poco::File dir(tempDir); dir.remove(true); } } diff --git a/Framework/API/test/PropertyManagerDataServiceTest.h b/Framework/API/test/PropertyManagerDataServiceTest.h index 77063af16abb294dac4c712d26bf36f8a8b730a9..2874f1768a78c46f4b3e02f754259cb5bc30eb51 100644 --- a/Framework/API/test/PropertyManagerDataServiceTest.h +++ b/Framework/API/test/PropertyManagerDataServiceTest.h @@ -95,10 +95,10 @@ public: } void testGetObjectNames() { PropertyManagerDataService::Instance().add("inst2", inst2); - std::set<std::string> names; + std::unordered_set<std::string> names; names.insert("inst1"); names.insert("inst2"); - std::set<std::string> result; + std::unordered_set<std::string> result; result = PropertyManagerDataService::Instance().getObjectNames(); TS_ASSERT_EQUALS(result, names); // Check with an empty store diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h b/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h index 954910d63eb640c9f4fcaf47250fbb8c59531777..267bd95173826bfbcc0e21b77fa3eb95a12d9005 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h @@ -124,7 +124,7 @@ private: /// Flag to use matrix splitters or table splitters bool m_useTableSplitters; - std::set<int> m_workGroupIndexes; + std::unordered_set<int> m_workGroupIndexes; Kernel::TimeSplitterType m_splitters; std::map<int, DataObjects::EventWorkspace_sptr> m_outputWS; std::vector<std::string> m_wsNames; diff --git a/Framework/Algorithms/src/ConjoinWorkspaces.cpp b/Framework/Algorithms/src/ConjoinWorkspaces.cpp index 6c9534667016d823b41472bd3e0286bf5c575e80..8946cc0f06192c9d52ef7f3bcb1761cee4d237a0 100644 --- a/Framework/Algorithms/src/ConjoinWorkspaces.cpp +++ b/Framework/Algorithms/src/ConjoinWorkspaces.cpp @@ -123,10 +123,9 @@ void ConjoinWorkspaces::checkForOverlap(API::MatrixWorkspace_const_sptr ws1, const ISpectrum *spec = ws1->getSpectrum(i); const specid_t spectrum = spec->getSpectrumNo(); spectra.insert(spectrum); - const std::set<detid_t> &dets = spec->getDetectorIDs(); - std::set<detid_t>::const_iterator it; - for (it = dets.begin(); it != dets.end(); ++it) { - detectors.insert(*it); + const auto &dets = spec->getDetectorIDs(); + for (auto const &det : dets) { + detectors.insert(det); } } @@ -145,11 +144,10 @@ void ConjoinWorkspaces::checkForOverlap(API::MatrixWorkspace_const_sptr ws1, "The input workspaces have overlapping spectrum numbers"); } } - const std::set<detid_t> &dets = spec->getDetectorIDs(); - std::set<detid_t>::const_iterator it; - for (it = dets.begin(); it != dets.end(); ++it) { - if (detectors.find(*it) != detectors.end()) { - g_log.error() << "The input workspaces have common detectors: " << (*it) + const auto &dets = spec->getDetectorIDs(); + for (const auto &det : dets) { + if (detectors.find(det) != detectors.end()) { + g_log.error() << "The input workspaces have common detectors: " << (det) << "\n"; throw std::invalid_argument( "The input workspaces have common detectors"); diff --git a/Framework/Algorithms/src/ConvertSpectrumAxis.cpp b/Framework/Algorithms/src/ConvertSpectrumAxis.cpp index fac339636a818b894535c1d973b7040e5f6a9b70..a43827690a7d96f7583e4ce0100a1dd3efefb39a 100644 --- a/Framework/Algorithms/src/ConvertSpectrumAxis.cpp +++ b/Framework/Algorithms/src/ConvertSpectrumAxis.cpp @@ -68,8 +68,7 @@ void ConvertSpectrumAxis::exec() { MatrixWorkspace_const_sptr inputWS = getProperty("InputWorkspace"); std::string unitTarget = getProperty("Target"); // Loop over the original spectrum axis, finding the theta (n.b. not 2theta!) - // for each spectrum - // and storing it's corresponding workspace index + // for each spectrum and storing it's corresponding workspace index // Map will be sorted on theta, so resulting axis will be ordered as well std::multimap<double, size_t> indexMap; const size_t nHist = inputWS->getNumberHistograms(); diff --git a/Framework/Algorithms/src/CreateGroupingWorkspace.cpp b/Framework/Algorithms/src/CreateGroupingWorkspace.cpp index fbe867a4f98a10dbe234c94d151509a24229c431..52b8975ca5c5b80ecfbb5f110144c6dc9bdb19e6 100644 --- a/Framework/Algorithms/src/CreateGroupingWorkspace.cpp +++ b/Framework/Algorithms/src/CreateGroupingWorkspace.cpp @@ -423,7 +423,7 @@ void CreateGroupingWorkspace::exec() { // Make the groups, if any std::map<detid_t, int>::const_iterator it_end = detIDtoGroup.end(); std::map<detid_t, int>::const_iterator it; - std::set<int> groupCount; + std::unordered_set<int> groupCount; for (it = detIDtoGroup.begin(); it != it_end; ++it) { int detID = it->first; int group = it->second; diff --git a/Framework/Algorithms/src/FilterEvents.cpp b/Framework/Algorithms/src/FilterEvents.cpp index fa4dc28b6b1465bea50cfb49f41ea3d565514c37..681835f6e1fe0e3088d953f5f9c52da080e7dfc1 100644 --- a/Framework/Algorithms/src/FilterEvents.cpp +++ b/Framework/Algorithms/src/FilterEvents.cpp @@ -520,16 +520,13 @@ void FilterEvents::createOutputWorkspaces() { } // Set up new workspaces - std::set<int>::iterator groupit; int numoutputws = 0; double numnewws = static_cast<double>(m_workGroupIndexes.size()); double wsgindex = 0.; - for (groupit = m_workGroupIndexes.begin(); - groupit != m_workGroupIndexes.end(); ++groupit) { + for (auto const wsgroup : m_workGroupIndexes) { // Generate new workspace name bool add2output = true; - int wsgroup = *groupit; std::stringstream wsname; if (wsgroup >= 0) { wsname << m_outputWSNameBase << "_" << (wsgroup + delta_wsindex); @@ -776,8 +773,7 @@ void FilterEvents::setupCustomizedTOFCorrection() { // If there are more than 1 spectrum, it is very likely to have problem // with correction factor const DataObjects::EventList events = m_eventWS->getEventList(i); - std::set<detid_t> detids = events.getDetectorIDs(); - std::set<detid_t>::iterator detit; + auto detids = events.getDetectorIDs(); if (detids.size() != 1) { // Check whether there are more than 1 detector per spectra. stringstream errss; @@ -788,7 +784,7 @@ void FilterEvents::setupCustomizedTOFCorrection() { throw runtime_error(errss.str()); } detid_t detid = 0; - for (detit = detids.begin(); detit != detids.end(); ++detit) + for (auto detit = detids.begin(); detit != detids.end(); ++detit) detid = *detit; vecDetIDs[i] = detid; } diff --git a/Framework/Algorithms/src/FindDeadDetectors.cpp b/Framework/Algorithms/src/FindDeadDetectors.cpp index 5fb2ce0e2884ae50846e39c76a6d513c4f110fcf..ca3e4059fe225d0dc1ff4fdd66223e90e5d905c3 100644 --- a/Framework/Algorithms/src/FindDeadDetectors.cpp +++ b/Framework/Algorithms/src/FindDeadDetectors.cpp @@ -101,14 +101,13 @@ void FindDeadDetectors::exec() { // Write the spectrum number to file file << i << " " << specNo; // Get the list of detectors for this spectrum and iterate over - const std::set<detid_t> &dets = spec->getDetectorIDs(); - std::set<detid_t>::const_iterator it; - for (it = dets.begin(); it != dets.end(); ++it) { + const auto &dets = spec->getDetectorIDs(); + for (const auto &det : dets) { // Write the detector ID to file, log & the FoundDead output property - file << " " << *it; + file << " " << det; // we could write dead detectors to the log but if they are viewing the // log in the MantidPlot viewer it will crash MantidPlot - deadDets.push_back(*it); + deadDets.push_back(det); ++countDets; } file << std::endl; diff --git a/Framework/Algorithms/src/GeneratePeaks.cpp b/Framework/Algorithms/src/GeneratePeaks.cpp index b5b4d043d5a755a0e9a92494bd049d8a05471aad..35b703449d07e243243f57b6559a9bc89b91adf5 100644 --- a/Framework/Algorithms/src/GeneratePeaks.cpp +++ b/Framework/Algorithms/src/GeneratePeaks.cpp @@ -647,9 +647,8 @@ void GeneratePeaks::getSpectraSet( g_log.debug(outss.str()); } - std::set<specid_t>::iterator pit; specid_t icount = 0; - for (pit = m_spectraSet.begin(); pit != m_spectraSet.end(); ++pit) { + for (auto pit = m_spectraSet.begin(); pit != m_spectraSet.end(); ++pit) { m_SpectrumMap.emplace(*pit, icount); ++icount; } @@ -720,10 +719,10 @@ API::MatrixWorkspace_sptr GeneratePeaks::createOutputWorkspace() { inputWS, inputWS->getNumberHistograms(), inputWS->dataX(0).size(), inputWS->dataY(0).size()); - std::set<specid_t>::iterator siter; // Only copy the X-values from spectra with peaks specified in the table // workspace. - for (siter = m_spectraSet.begin(); siter != m_spectraSet.end(); ++siter) { + for (auto siter = m_spectraSet.begin(); siter != m_spectraSet.end(); + ++siter) { specid_t iws = *siter; std::copy(inputWS->dataX(iws).begin(), inputWS->dataX(iws).end(), outputWS->dataX(iws).begin()); diff --git a/Framework/Algorithms/src/GetDetectorOffsets.cpp b/Framework/Algorithms/src/GetDetectorOffsets.cpp index 30e9896572d57aa9351841a55d42934bcf3ab661..2261ed03e7e8eb6996d50c90c6ccfdb36fd30e78 100644 --- a/Framework/Algorithms/src/GetDetectorOffsets.cpp +++ b/Framework/Algorithms/src/GetDetectorOffsets.cpp @@ -131,16 +131,15 @@ void GetDetectorOffsets::exec() { } // Get the list of detectors in this pixel - const std::set<detid_t> &dets = inputW->getSpectrum(wi)->getDetectorIDs(); + const auto &dets = inputW->getSpectrum(wi)->getDetectorIDs(); // Most of the exec time is in FitSpectra, so this critical block should not // be a problem. PARALLEL_CRITICAL(GetDetectorOffsets_setValue) { // Use the same offset for all detectors from this pixel - std::set<detid_t>::iterator it; - for (it = dets.begin(); it != dets.end(); ++it) { - outputW->setValue(*it, offset); - const auto mapEntry = pixel_to_wi.find(*it); + for (const auto &det : dets) { + outputW->setValue(det, offset); + const auto mapEntry = pixel_to_wi.find(det); if (mapEntry == pixel_to_wi.end()) continue; const size_t workspaceIndex = mapEntry->second; diff --git a/Framework/Algorithms/src/GetEi.cpp b/Framework/Algorithms/src/GetEi.cpp index 77e45e525bb4ec3a54c55d284ec5b3f1827edc3d..c778cf56927f586dbdfc22666b4fc3277adf4057 100644 --- a/Framework/Algorithms/src/GetEi.cpp +++ b/Framework/Algorithms/src/GetEi.cpp @@ -165,7 +165,7 @@ void GetEi::getGeometry(API::MatrixWorkspace_const_sptr WS, specid_t mon0Spec, g_log.error() << "Error retrieving data for the first monitor" << std::endl; throw std::bad_cast(); } - const std::set<detid_t> &dets = WS->getSpectrum(monWI)->getDetectorIDs(); + const auto &dets = WS->getSpectrum(monWI)->getDetectorIDs(); if (dets.size() != 1) { g_log.error() << "The detector for spectrum number " << mon0Spec @@ -187,7 +187,7 @@ void GetEi::getGeometry(API::MatrixWorkspace_const_sptr WS, specid_t mon0Spec, g_log.error() << "Error retrieving data for the second monitor\n"; throw std::bad_cast(); } - const std::set<detid_t> &dets2 = WS->getSpectrum(monWI)->getDetectorIDs(); + const auto &dets2 = WS->getSpectrum(monWI)->getDetectorIDs(); if (dets2.size() != 1) { g_log.error() << "The detector for spectrum number " << mon1Spec << " was either not found or is a group, grouped monitors " diff --git a/Framework/Algorithms/src/IntegrateByComponent.cpp b/Framework/Algorithms/src/IntegrateByComponent.cpp index f4e0d64f31a28f7d4796778ecfbce5c048b293f0..f7b51208d6b5d5cf83cfd1cf502caf687231cb63 100644 --- a/Framework/Algorithms/src/IntegrateByComponent.cpp +++ b/Framework/Algorithms/src/IntegrateByComponent.cpp @@ -5,6 +5,7 @@ #include <boost/math/special_functions/fpclassify.hpp> #include <gsl/gsl_statistics.h> +#include <unordered_map> namespace Mantid { namespace Algorithms { @@ -190,7 +191,7 @@ IntegrateByComponent::makeInstrumentMap(API::MatrixWorkspace_sptr countsWS) { */ std::vector<std::vector<size_t>> IntegrateByComponent::makeMap(API::MatrixWorkspace_sptr countsWS, int parents) { - std::multimap<Mantid::Geometry::ComponentID, size_t> mymap; + std::unordered_multimap<Mantid::Geometry::ComponentID, size_t> mymap; Geometry::Instrument_const_sptr instrument = countsWS->getInstrument(); if (parents == 0) // this should not happen in this file, but if one reuses @@ -226,13 +227,16 @@ IntegrateByComponent::makeMap(API::MatrixWorkspace_sptr countsWS, int parents) { std::vector<std::vector<size_t>> speclist; std::vector<size_t> speclistsingle; - std::multimap<Mantid::Geometry::ComponentID, size_t>::iterator m_it, s_it; + std::unordered_multimap<Mantid::Geometry::ComponentID, size_t>::iterator m_it, + s_it; for (m_it = mymap.begin(); m_it != mymap.end(); m_it = s_it) { Mantid::Geometry::ComponentID theKey = (*m_it).first; - std::pair<std::multimap<Mantid::Geometry::ComponentID, size_t>::iterator, - std::multimap<Mantid::Geometry::ComponentID, size_t>::iterator> - keyRange = mymap.equal_range(theKey); + std::pair<std::unordered_multimap<Mantid::Geometry::ComponentID, + size_t>::iterator, + std::unordered_multimap<Mantid::Geometry::ComponentID, + size_t>::iterator> keyRange = + mymap.equal_range(theKey); // Iterate over all map elements with key == theKey speclistsingle.clear(); diff --git a/Framework/Algorithms/src/MaskDetectorsIf.cpp b/Framework/Algorithms/src/MaskDetectorsIf.cpp index ef6248b234016ad9e892670dc7e274f953ea4641..eb6a4d81051c7cabcb7f81fd77e82ac6bc499da3 100644 --- a/Framework/Algorithms/src/MaskDetectorsIf.cpp +++ b/Framework/Algorithms/src/MaskDetectorsIf.cpp @@ -72,7 +72,7 @@ void MaskDetectorsIf::exec() { for (size_t i = 0; i < nspec; ++i) { // Get the list of udets contributing to this spectra - const std::set<detid_t> &dets = inputW->getSpectrum(i)->getDetectorIDs(); + const auto &dets = inputW->getSpectrum(i)->getDetectorIDs(); if (dets.empty()) continue; diff --git a/Framework/Algorithms/src/MergeRuns.cpp b/Framework/Algorithms/src/MergeRuns.cpp index 823b6230ef4ff42cae1ffdcc03b9de178bb2aae4..77aec7377284f63fb0fd5c75dce015f4138053dc 100644 --- a/Framework/Algorithms/src/MergeRuns.cpp +++ b/Framework/Algorithms/src/MergeRuns.cpp @@ -168,7 +168,7 @@ void MergeRuns::buildAdditionTables() { table->reserve(nhist); for (int inWI = 0; inWI < static_cast<int>(nhist); inWI++) { // Get the set of detectors in the output - std::set<detid_t> &inDets = ews->getEventList(inWI).getDetectorIDs(); + auto &inDets = ews->getEventList(inWI).getDetectorIDs(); bool done = false; @@ -177,7 +177,7 @@ void MergeRuns::buildAdditionTables() { int outWI = inWI; if (outWI < lhs_nhist) // don't go out of bounds { - std::set<detid_t> &outDets = lhs->getEventList(outWI).getDetectorIDs(); + auto &outDets = lhs->getEventList(outWI).getDetectorIDs(); // Checks that inDets is a subset of outDets if (std::includes(outDets.begin(), outDets.end(), inDets.begin(), diff --git a/Framework/Algorithms/src/PDDetermineCharacterizations.cpp b/Framework/Algorithms/src/PDDetermineCharacterizations.cpp index 7347441ff8ffa0f91d9629bd76bc06571548a471..ec4d16655d58781534bab540fa2d85deea4f7c2d 100644 --- a/Framework/Algorithms/src/PDDetermineCharacterizations.cpp +++ b/Framework/Algorithms/src/PDDetermineCharacterizations.cpp @@ -216,7 +216,7 @@ double PDDetermineCharacterizations::getLogValue(API::Run &run, if (propName == WL_PROP_NAME) label = "wavelength"; - std::set<std::string> validUnits; + std::unordered_set<std::string> validUnits; if (propName == WL_PROP_NAME) { validUnits.insert("Angstrom"); validUnits.insert("A"); diff --git a/Framework/Algorithms/src/ReadGroupsFromFile.cpp b/Framework/Algorithms/src/ReadGroupsFromFile.cpp index 31fbd99753666251f622e86f0d84ef0be5de8ae7..12204805a8f37126f7f48159ceee12ad9ee76fe2 100644 --- a/Framework/Algorithms/src/ReadGroupsFromFile.cpp +++ b/Framework/Algorithms/src/ReadGroupsFromFile.cpp @@ -112,7 +112,7 @@ void ReadGroupsFromFile::exec() { for (int64_t i = 0; i < nHist; i++) { ISpectrum *spec = localWorkspace->getSpectrum(i); - const std::set<detid_t> &dets = spec->getDetectorIDs(); + const auto &dets = spec->getDetectorIDs(); if (dets.empty()) // Nothing { spec->dataY()[0] = 0.0; diff --git a/Framework/Algorithms/src/SmoothNeighbours.cpp b/Framework/Algorithms/src/SmoothNeighbours.cpp index 961bd5cd497d82fed1c9d751f9f6578acdb31ebe..1df42d6021a6ae2d2fad6a1e5a834cbc523f288a 100644 --- a/Framework/Algorithms/src/SmoothNeighbours.cpp +++ b/Framework/Algorithms/src/SmoothNeighbours.cpp @@ -355,7 +355,7 @@ void SmoothNeighbours::findNeighboursUbiqutious() { // We want to skip monitors try { // Get the list of detectors in this pixel - const std::set<detid_t> &dets = inWS->getSpectrum(wi)->getDetectorIDs(); + const auto &dets = inWS->getSpectrum(wi)->getDetectorIDs(); det = inst->getDetector(*dets.begin()); if (det->isMonitor()) continue; // skip monitor @@ -713,7 +713,7 @@ void SmoothNeighbours::setupNewInstrument(MatrixWorkspace_sptr outws) { const ISpectrum *inSpec = inWS->getSpectrum(inWI); - std::set<detid_t> thesedetids = inSpec->getDetectorIDs(); + auto thesedetids = inSpec->getDetectorIDs(); outSpec->addDetectorIDs(thesedetids); } //(each neighbour) @@ -748,7 +748,7 @@ void SmoothNeighbours::spreadPixels(MatrixWorkspace_sptr outws) { ISpectrum *inSpec = inWS->getSpectrum(outWIi); MantidVec &inX = inSpec->dataX(); - std::set<detid_t> thesedetids = inSpec->getDetectorIDs(); + auto thesedetids = inSpec->getDetectorIDs(); ISpectrum *outSpec2 = outws2->getSpectrum(outWIi); MantidVec &outX = outSpec2->dataX(); outX = inX; diff --git a/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp b/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp index 532424b9cdb095c5184be3b515826cc942466082..13fda3bbc94503fb0d8a40951704e3bf5e672572 100644 --- a/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp +++ b/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp @@ -29,8 +29,8 @@ const std::string pointDetectorAnalysis = "PointDetectorAnalysis"; */ void checkSpectrumNumbers(const std::vector<int> &spectrumNumbers, bool strictSpectrumChecking, Logger &logger) { - std::set<int> uniqueSpectrumNumbers(spectrumNumbers.begin(), - spectrumNumbers.end()); + std::unordered_set<int> uniqueSpectrumNumbers(spectrumNumbers.begin(), + spectrumNumbers.end()); if (uniqueSpectrumNumbers.size() != spectrumNumbers.size()) { throw std::invalid_argument("Spectrum numbers are not unique."); } diff --git a/Framework/Algorithms/src/SumSpectra.cpp b/Framework/Algorithms/src/SumSpectra.cpp index 713199aa9f004818990c43e9b679b7503067a905..d033e2da1551f2d207e68b3533590bab4788f511 100644 --- a/Framework/Algorithms/src/SumSpectra.cpp +++ b/Framework/Algorithms/src/SumSpectra.cpp @@ -239,9 +239,8 @@ void SumSpectra::doWorkspace2D(MatrixWorkspace_const_sptr localworkspace, numZeros = 0; // Loop over spectra - std::set<int>::iterator it; // for (int i = m_minSpec; i <= m_maxSpec; ++i) - for (it = this->m_indices.begin(); it != this->m_indices.end(); ++it) { + for (auto it = this->m_indices.begin(); it != this->m_indices.end(); ++it) { int i = *it; // Don't go outside the range. if ((i >= this->m_numberOfSpectra) || (i < 0)) { @@ -354,9 +353,8 @@ void SumSpectra::doRebinnedOutput(MatrixWorkspace_sptr outputWorkspace, numZeros = 0; // Loop over spectra - std::set<int>::iterator it; // for (int i = m_minSpec; i <= m_maxSpec; ++i) - for (it = m_indices.begin(); it != m_indices.end(); ++it) { + for (auto it = m_indices.begin(); it != m_indices.end(); ++it) { int i = *it; // Don't go outside the range. if ((i >= m_numberOfSpectra) || (i < 0)) { @@ -449,12 +447,11 @@ void SumSpectra::execEvent(EventWorkspace_const_sptr localworkspace, outEL.clearDetectorIDs(); // Loop over spectra - std::set<int>::iterator it; size_t numSpectra(0); size_t numMasked(0); size_t numZeros(0); // for (int i = m_minSpec; i <= m_maxSpec; ++i) - for (it = indices.begin(); it != indices.end(); ++it) { + for (auto it = indices.begin(); it != indices.end(); ++it) { int i = *it; // Don't go outside the range. if ((i >= m_numberOfSpectra) || (i < 0)) { diff --git a/Framework/Algorithms/src/UnGroupWorkspace.cpp b/Framework/Algorithms/src/UnGroupWorkspace.cpp index 8d4b97b05c8178e895cb5ff9ca9e1572088d9aea..34317a69c7eb34ce335756eb5a4f4c073f1ed5ac 100644 --- a/Framework/Algorithms/src/UnGroupWorkspace.cpp +++ b/Framework/Algorithms/src/UnGroupWorkspace.cpp @@ -13,11 +13,10 @@ using namespace API; void UnGroupWorkspace::init() { const AnalysisDataServiceImpl &data_store = AnalysisDataService::Instance(); // Get the list of workspaces in the ADS - std::set<std::string> workspaceList = data_store.getObjectNames(); - std::set<std::string> groupWorkspaceList; + auto workspaceList = data_store.getObjectNames(); + std::unordered_set<std::string> groupWorkspaceList; // Not iterate over, removing all those which are not group workspaces - std::set<std::string>::iterator it; - for (it = workspaceList.begin(); it != workspaceList.end(); ++it) { + for (auto it = workspaceList.begin(); it != workspaceList.end(); ++it) { WorkspaceGroup_const_sptr group = boost::dynamic_pointer_cast<const WorkspaceGroup>( data_store.retrieve(*it)); diff --git a/Framework/Algorithms/test/CopyDetectorMappingTest.h b/Framework/Algorithms/test/CopyDetectorMappingTest.h index b08c2fc8c8998fa672664eeda165291b5acd2d21..d652eb1244874d2f3cce0bed87d015d8a72462f9 100644 --- a/Framework/Algorithms/test/CopyDetectorMappingTest.h +++ b/Framework/Algorithms/test/CopyDetectorMappingTest.h @@ -52,7 +52,7 @@ public: TS_ASSERT_THROWS_NOTHING( result = boost::dynamic_pointer_cast<MatrixWorkspace>( AnalysisDataService::Instance().retrieve("to_remap"))); - std::set<detid_t> resultDetIDs = result->getSpectrum(0)->getDetectorIDs(); + auto resultDetIDs = result->getSpectrum(0)->getDetectorIDs(); TS_ASSERT(detIDs == resultDetIDs); // Clean up workspace diff --git a/Framework/Algorithms/test/CopyInstrumentParametersTest.h b/Framework/Algorithms/test/CopyInstrumentParametersTest.h index c1fd30c4109f073778342cfebb879fe62bcf0425..4628beecaaa0858b0d49998903b4d4c31debebd9 100644 --- a/Framework/Algorithms/test/CopyInstrumentParametersTest.h +++ b/Framework/Algorithms/test/CopyInstrumentParametersTest.h @@ -103,7 +103,7 @@ public: TS_ASSERT_DELTA(newPos2.Y(), 0.1, 0.0001); TS_ASSERT_DELTA(newPos2.Z(), 0.7, 0.0001); auto instr2 = ws2->getInstrument(); - std::set<std::string> param_names = instr2->getParameterNames(); + auto param_names = instr2->getParameterNames(); TS_ASSERT(param_names.find("Ei") != param_names.end()); TS_ASSERT(param_names.find("some_param") != param_names.end()); @@ -164,7 +164,7 @@ public: TS_ASSERT(copyInstParam.isInstrumentDifferent()); auto instr2 = ws2->getInstrument(); - std::set<std::string> param_names = instr2->getParameterNames(); + auto param_names = instr2->getParameterNames(); TS_ASSERT(param_names.find("Ei") != param_names.end()); TS_ASSERT(param_names.find("some_param") != param_names.end()); TS_ASSERT(param_names.find("T") == param_names.end()); @@ -279,10 +279,9 @@ public: dataStore.retrieveWS<API::MatrixWorkspace>(m_TargetWSName); auto instr2 = ws2->getInstrument(); - std::set<std::string> param_names = instr2->getParameterNames(); + auto param_names = instr2->getParameterNames(); - for (auto it = param_names.begin(); it != param_names.end(); it++) { - auto name = *it; + for (auto const &name : param_names) { double num = boost::lexical_cast<double>(name.substr(6, name.size() - 6)); double val = instr2->getNumberParameter(name)[0]; TS_ASSERT_DELTA(num * 10, val, 1.e-8); diff --git a/Framework/Algorithms/test/DiffractionFocussing2Test.h b/Framework/Algorithms/test/DiffractionFocussing2Test.h index 59e85081f299adef2713c427bbeb563813382774..78d717e83e79e6629e72c5048c35b37b875931ac 100644 --- a/Framework/Algorithms/test/DiffractionFocussing2Test.h +++ b/Framework/Algorithms/test/DiffractionFocussing2Test.h @@ -203,7 +203,7 @@ public: // Now let's test the grouping of detector UDETS to groups for (size_t wi = 0; wi < output->getNumberHistograms(); wi++) { // This is the list of the detectors (grouped) - std::set<detid_t> mylist = output->getSpectrum(wi)->getDetectorIDs(); + auto mylist = output->getSpectrum(wi)->getDetectorIDs(); // 1024 pixels in a bank TS_ASSERT_EQUALS(mylist.size(), bankWidthInPixels * bankWidthInPixels); } diff --git a/Framework/Algorithms/test/EditInstrumentGeometryTest.h b/Framework/Algorithms/test/EditInstrumentGeometryTest.h index f0ba68a4ee1ab17000994576f0c510f38bb09431..1db033238c7fcecb4b5db6d6cb1c1654d8317aa2 100644 --- a/Framework/Algorithms/test/EditInstrumentGeometryTest.h +++ b/Framework/Algorithms/test/EditInstrumentGeometryTest.h @@ -61,11 +61,10 @@ public: API::ISpectrum *spectrum1 = workspace->getSpectrum(0); Geometry::Instrument_const_sptr instrument = workspace->getInstrument(); - std::set<detid_t> detids = spectrum1->getDetectorIDs(); + auto detids = spectrum1->getDetectorIDs(); TS_ASSERT_EQUALS(detids.size(), 1); detid_t detid = 0; - std::set<detid_t>::iterator it; - for (it = detids.begin(); it != detids.end(); ++it) { + for (auto it = detids.begin(); it != detids.end(); ++it) { detid = *it; } Geometry::IDetector_const_sptr detector = instrument->getDetector(detid); @@ -172,11 +171,10 @@ public: API::ISpectrum *spectrum1 = workspace->getSpectrum(wsindex); Geometry::Instrument_const_sptr instrument = workspace->getInstrument(); - std::set<detid_t> detids = spectrum1->getDetectorIDs(); + auto detids = spectrum1->getDetectorIDs(); TS_ASSERT_EQUALS(detids.size(), 1); detid_t detid = 0; - std::set<detid_t>::iterator it; - for (it = detids.begin(); it != detids.end(); ++it) { + for (auto it = detids.begin(); it != detids.end(); ++it) { detid = *it; } Geometry::IDetector_const_sptr detector = instrument->getDetector(detid); @@ -195,11 +193,10 @@ public: API::ISpectrum *spectrum1 = workspace->getSpectrum(wsindex); Geometry::Instrument_const_sptr instrument = workspace->getInstrument(); - std::set<detid_t> detids = spectrum1->getDetectorIDs(); + auto detids = spectrum1->getDetectorIDs(); TS_ASSERT_EQUALS(detids.size(), 1); detid_t thisdetid = 0; - std::set<detid_t>::iterator it; - for (it = detids.begin(); it != detids.end(); ++it) { + for (auto it = detids.begin(); it != detids.end(); ++it) { thisdetid = *it; } diff --git a/Framework/Algorithms/test/ExtractSingleSpectrumTest.h b/Framework/Algorithms/test/ExtractSingleSpectrumTest.h index b5dbbdd1a1900b3ae197ff1a2190e8449ed5475d..c760c0f5fea7a96de358637eb7512e194c7e90ad 100644 --- a/Framework/Algorithms/test/ExtractSingleSpectrumTest.h +++ b/Framework/Algorithms/test/ExtractSingleSpectrumTest.h @@ -113,7 +113,7 @@ private: TS_ASSERT_THROWS_NOTHING(spectrum = outputWS->getSpectrum(0)); if (spectrum) { TS_ASSERT_EQUALS(spectrum->getSpectrumNo(), specID); - std::set<detid_t> detids = spectrum->getDetectorIDs(); + auto detids = spectrum->getDetectorIDs(); TS_ASSERT_EQUALS(detids.size(), 1); const detid_t id = *(detids.begin()); TS_ASSERT_EQUALS(id, detID); diff --git a/Framework/Algorithms/test/InvertMaskTest.h b/Framework/Algorithms/test/InvertMaskTest.h index 422422e53fdcd67113f75685e0eab062da2e5194..20d5f8d0532a0a166b9e4da02b9ae80027daa3f5 100644 --- a/Framework/Algorithms/test/InvertMaskTest.h +++ b/Framework/Algorithms/test/InvertMaskTest.h @@ -67,7 +67,7 @@ public: // 4. Check output for (size_t ih = 0; ih < ws4->getNumberHistograms(); ih++) { - std::set<detid_t> tempdetids = ws4->getDetectorIDs(ih); + auto tempdetids = ws4->getDetectorIDs(ih); detid_t tempdetid = *(tempdetids.begin()); TS_ASSERT_EQUALS(tempdetids.size(), 1); TS_ASSERT_DELTA(ws4->getValue(tempdetid), ws1->getValue(tempdetid), 1); diff --git a/Framework/Algorithms/test/MaskBinsFromTableTest.h b/Framework/Algorithms/test/MaskBinsFromTableTest.h index ee036eacf36d9b27edd244783e3682b426660733..71fb96fa7da66da2c140bec39ce26869d0aa1c26 100644 --- a/Framework/Algorithms/test/MaskBinsFromTableTest.h +++ b/Framework/Algorithms/test/MaskBinsFromTableTest.h @@ -279,9 +279,9 @@ public: << ".\n"; return; } else { - std::set<detid_t> detidset = spec->getDetectorIDs(); - set<detid_t>::iterator setiter; - for (setiter = detidset.begin(); setiter != detidset.end(); ++setiter) + auto detidset = spec->getDetectorIDs(); + for (auto setiter = detidset.begin(); setiter != detidset.end(); + ++setiter) cout << "WorkspaceIndex = " << i << ": Detector ID = " << *setiter << ".\n"; } diff --git a/Framework/Algorithms/test/PlusMinusTest.in.h b/Framework/Algorithms/test/PlusMinusTest.in.h index be37447afe5a6ae5eb69db1eddbc130dfd836e77..603bdc16992a7f47488388d1c5725ce792ee8564 100644 --- a/Framework/Algorithms/test/PlusMinusTest.in.h +++ b/Framework/Algorithms/test/PlusMinusTest.in.h @@ -583,7 +583,7 @@ public: //But two detector IDs in each one for (int i=0; i<3; i++) { - std::set<detid_t>::const_iterator detIT = work_out->getSpectrum(i)->getDetectorIDs().begin(); + auto detIT = work_out->getSpectrum(i)->getDetectorIDs().begin(); TS_ASSERT_EQUALS( *detIT, 0+i ); if (DO_PLUS) { diff --git a/Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h b/Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h index 7e7e6eac7ec0ed2bf8cc04794b451d0a406dc381..6493f796c30caf47fc80bbd70c913d9670a93b14 100644 --- a/Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h +++ b/Framework/Crystal/inc/MantidCrystal/ConnectedComponentLabeling.h @@ -9,7 +9,7 @@ #include <boost/tuple/tuple.hpp> #include <boost/optional.hpp> #include <map> -#include <set> +#include <unordered_set> namespace Mantid { namespace API { @@ -27,7 +27,7 @@ typedef std::map<size_t, SignalErrorSQPair> LabelIdIntensityMap; typedef std::map<Mantid::Kernel::V3D, size_t> PositionToLabelIdMap; typedef std::vector<size_t> VecIndexes; typedef std::vector<DisjointElement> VecElements; -typedef std::set<size_t> SetIds; +typedef std::unordered_set<size_t> SetIds; typedef std::map<size_t, boost::shared_ptr<Mantid::Crystal::ICluster>> ClusterMap; typedef boost::tuple<Mantid::API::IMDHistoWorkspace_sptr, ClusterMap> diff --git a/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h b/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h index 0f6715c513169cfcbe9765dd909a69e5bbf4e7d7..23d86a048562f7ffb7e4fc7164d89353bdd0a5d4 100644 --- a/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h @@ -90,9 +90,8 @@ public: } size_t candidateHKLSize() const { return _hkls.size(); } void delHKL(int h, int k, int l) { - std::set<index>::const_iterator it = - std::find(_hkls.begin(), _hkls.end(), index(h, k, l)); - if (it != _hkls.end()) + auto it = std::find(_hkls.cbegin(), _hkls.cend(), index(h, k, l)); + if (it != _hkls.cend()) _hkls.erase(it); } const Mantid::Kernel::V3D &getQ() const { return _Q; } @@ -103,7 +102,7 @@ public: } void setFirst() { if (_hkls.size() > 0) { - std::set<index>::iterator it = _hkls.begin(); // Take the first possiblity + auto it = _hkls.begin(); // Take the first possiblity it++; _hkls.erase(it, _hkls.end()); // Erase all others! } diff --git a/Framework/Crystal/src/AnvredCorrection.cpp b/Framework/Crystal/src/AnvredCorrection.cpp index 397711117a63f083c1522a4b4fe93c38aaa671ea..e0fa82fa7e13ae6af75ae71ef379b9eea6e5d124 100644 --- a/Framework/Crystal/src/AnvredCorrection.cpp +++ b/Framework/Crystal/src/AnvredCorrection.cpp @@ -360,10 +360,9 @@ void AnvredCorrection::execEvent() { } correctionFactors->getOrAddEventList(i) += events; - std::set<detid_t> &dets = eventW->getEventList(i).getDetectorIDs(); - std::set<detid_t>::iterator j; - for (j = dets.begin(); j != dets.end(); ++j) - correctionFactors->getOrAddEventList(i).addDetectorID(*j); + auto &dets = eventW->getEventList(i).getDetectorIDs(); + for (auto const &det : dets) + correctionFactors->getOrAddEventList(i).addDetectorID(det); // When focussing in place, you can clear out old memory from the input one! if (inPlace) { eventW->getEventList(i).clear(); diff --git a/Framework/Crystal/src/ClusterRegister.cpp b/Framework/Crystal/src/ClusterRegister.cpp index f0765ac08e465c175ecc82d20eebe0141be7a49e..720a8300dec406e499cf959259734d092e0147b5 100644 --- a/Framework/Crystal/src/ClusterRegister.cpp +++ b/Framework/Crystal/src/ClusterRegister.cpp @@ -4,7 +4,7 @@ #include <boost/make_shared.hpp> #include <boost/functional/hash.hpp> #include <list> -#include <set> +#include <unordered_set> namespace { template <typename T> std::pair<T, T> ordered_pair(const T &a, const T &b) { @@ -26,13 +26,13 @@ public: ClusterRegister::MapCluster m_unique; /// Type for identifying label groups - typedef std::list<std::set<size_t>> GroupType; + typedef std::list<std::unordered_set<size_t>> GroupType; /// Groups of labels to maintain GroupType m_groups; /// Type for identifying labels already seen - typedef std::set<size_t> LabelHash; + typedef std::unordered_set<size_t> LabelHash; /// Hash of labels merged LabelHash m_labelHash; diff --git a/Framework/Crystal/src/PeakHKLErrors.cpp b/Framework/Crystal/src/PeakHKLErrors.cpp index eec8ea5538b9b96e24724032eed113ebf951268a..92314edc9afa3af099908e76ea5ee9993c4105e5 100644 --- a/Framework/Crystal/src/PeakHKLErrors.cpp +++ b/Framework/Crystal/src/PeakHKLErrors.cpp @@ -115,7 +115,7 @@ void PeakHKLErrors::cLone( return; if (component->isParametrized()) { - std::set<std::string> nms = pmapSv->names(component.get()); + auto nms = pmapSv->names(component.get()); for (const auto &nm : nms) { if (pmapSv->contains(component.get(), nm, "double")) { diff --git a/Framework/Crystal/src/SaveIsawPeaks.cpp b/Framework/Crystal/src/SaveIsawPeaks.cpp index af0d7775e3ede8883de66b928fb72e98431a9c78..16f83bbd5438ca6b92352fef9477002bc62ff660 100644 --- a/Framework/Crystal/src/SaveIsawPeaks.cpp +++ b/Framework/Crystal/src/SaveIsawPeaks.cpp @@ -76,7 +76,7 @@ void SaveIsawPeaks::exec() { // workspace indices of it typedef std::map<int, std::vector<size_t>> bankMap_t; typedef std::map<int, bankMap_t> runMap_t; - std::set<int> uniqueBanks; + std::unordered_set<int> uniqueBanks; runMap_t runMap; for (size_t i = 0; i < peaks.size(); ++i) { Peak &p = peaks[i]; @@ -165,8 +165,7 @@ void SaveIsawPeaks::exec() { " CenterY CenterZ BaseX BaseY BaseZ UpX UpY " " UpZ" << std::endl; // Here would save each detector... - std::set<int>::iterator it; - for (it = uniqueBanks.begin(); it != uniqueBanks.end(); ++it) { + for (auto it = uniqueBanks.begin(); it != uniqueBanks.end(); ++it) { // Build up the bank name int bank = *it; std::ostringstream mess; diff --git a/Framework/Crystal/test/ConnectedComponentLabelingTest.h b/Framework/Crystal/test/ConnectedComponentLabelingTest.h index ebd477c6bdf28c287978400d5664b22437728657..8b2e4cdb2a8861295a1b2bd463eb81578dccf62d 100644 --- a/Framework/Crystal/test/ConnectedComponentLabelingTest.h +++ b/Framework/Crystal/test/ConnectedComponentLabelingTest.h @@ -25,7 +25,7 @@ using namespace testing; namespace { // Helper function for determining if a set contains a specific value. template <typename T> -bool does_set_contain(const std::set<T> &container, const T &value) { +bool does_set_contain(const std::unordered_set<T> &container, const T &value) { return std::find(container.begin(), container.end(), value) != container.end(); } @@ -39,9 +39,9 @@ bool does_vector_contain(const std::vector<size_t> &container, // Helper function for converting a IMDHistoWorkspace of labels into a set of // unique labels. -std::set<size_t> +std::unordered_set<size_t> connection_workspace_to_set_of_labels(IMDHistoWorkspace const *const ws) { - std::set<size_t> unique_values; + std::unordered_set<size_t> unique_values; for (size_t i = 0; i < ws->getNPoints(); ++i) { const size_t signal = static_cast<size_t>(ws->getSignalAt(i)); unique_values.insert(signal); @@ -170,8 +170,7 @@ public: ConnectedComponentLabeling ccl(labelingId, multiThreaded); auto outWS = ccl.execute(inWS, &mockStrategy, prog); - std::set<size_t> uniqueEntries = - connection_workspace_to_set_of_labels(outWS.get()); + auto uniqueEntries = connection_workspace_to_set_of_labels(outWS.get()); TSM_ASSERT_EQUALS("2 objects so should have 3 unique entries", 3, uniqueEntries.size()); TS_ASSERT(does_set_contain(uniqueEntries, labelingId)); @@ -209,8 +208,7 @@ public: Progress prog; auto outWS = ccl.execute(inWS, &mockStrategy, prog); - std::set<size_t> uniqueEntries = - connection_workspace_to_set_of_labels(outWS.get()); + auto uniqueEntries = connection_workspace_to_set_of_labels(outWS.get()); TSM_ASSERT_EQUALS("3 objects so should have 4 unique entries", 4, uniqueEntries.size()); TS_ASSERT(does_set_contain(uniqueEntries, labelingId)); @@ -237,8 +235,7 @@ public: Progress prog; auto outWS = ccl.execute(inWS, &mockStrategy, prog); - std::set<size_t> uniqueEntries = - connection_workspace_to_set_of_labels(outWS.get()); + auto uniqueEntries = connection_workspace_to_set_of_labels(outWS.get()); TSM_ASSERT_EQUALS("Just one object", 1, uniqueEntries.size()); TS_ASSERT(does_set_contain(uniqueEntries, labelingId)); TS_ASSERT(Mock::VerifyAndClearExpectations(&mockStrategy)); @@ -280,8 +277,7 @@ public: Progress prog; auto outWS = ccl.execute(inWS, &mockStrategy, prog); - std::set<size_t> uniqueEntries = - connection_workspace_to_set_of_labels(outWS.get()); + auto uniqueEntries = connection_workspace_to_set_of_labels(outWS.get()); TSM_ASSERT_EQUALS("Just one object, but we have some 'empty' entries too", 2, uniqueEntries.size()); TS_ASSERT(does_set_contain(uniqueEntries, labelingId)); @@ -362,8 +358,7 @@ public: Progress prog; auto outWS = ccl.execute(inWS, &mockStrategy, prog); - std::set<size_t> uniqueEntries = - connection_workspace_to_set_of_labels(outWS.get()); + auto uniqueEntries = connection_workspace_to_set_of_labels(outWS.get()); TSM_ASSERT_EQUALS("Just one object, but we have some 'empty' entries too", 2, uniqueEntries.size()); TS_ASSERT(does_set_contain(uniqueEntries, labelingId)); @@ -373,7 +368,7 @@ public: void do_test_cluster_labeling(const std::vector<size_t> &clusterIndexes, IMDHistoWorkspace const *const ws) { - std::set<double> valuesInCluster; + std::unordered_set<double> valuesInCluster; for (size_t i = 0; i < ws->getNPoints(); ++i) { if (does_vector_contain(clusterIndexes, i)) { valuesInCluster.insert(ws->getSignalAt(i)); @@ -430,8 +425,7 @@ public: // ----------- Basic cluster checks - std::set<size_t> uniqueEntries = - connection_workspace_to_set_of_labels(outWS.get()); + auto uniqueEntries = connection_workspace_to_set_of_labels(outWS.get()); TSM_ASSERT_EQUALS( "Should have 3 clusters, but we have some 'empty' entries too", 4, uniqueEntries.size()); @@ -492,8 +486,7 @@ public: ConnectedComponentLabeling ccl(labelingId, nThreads); auto outWS = ccl.execute(inWS, &backgroundStrategy, prog); - std::set<size_t> uniqueEntries = - connection_workspace_to_set_of_labels(outWS.get()); + auto uniqueEntries = connection_workspace_to_set_of_labels(outWS.get()); TSM_ASSERT_EQUALS("2 objects so should have 3 unique entries", 3, uniqueEntries.size()); TS_ASSERT(does_set_contain(uniqueEntries, labelingId)); @@ -516,8 +509,7 @@ public: ConnectedComponentLabeling ccl(labelingId, nThreads); auto outWS = ccl.execute(inWS, &backgroundStrategy, prog); - std::set<size_t> uniqueEntries = - connection_workspace_to_set_of_labels(outWS.get()); + auto uniqueEntries = connection_workspace_to_set_of_labels(outWS.get()); TSM_ASSERT_EQUALS("1 object covering entire space", 1, uniqueEntries.size()); TS_ASSERT(does_set_contain(uniqueEntries, labelingId)); @@ -540,8 +532,7 @@ public: ConnectedComponentLabeling ccl(labelingId, nThreads); auto outWS = ccl.execute(inWS, &backgroundStrategy, prog); - std::set<size_t> uniqueEntries = - connection_workspace_to_set_of_labels(outWS.get()); + auto uniqueEntries = connection_workspace_to_set_of_labels(outWS.get()); TSM_ASSERT_EQUALS("3 objects", 3, uniqueEntries.size()); TS_ASSERT(does_set_contain(uniqueEntries, labelingId)); TS_ASSERT(does_set_contain(uniqueEntries, m_emptyLabel)); @@ -612,8 +603,7 @@ public: Progress prog; auto outWS = ccl.execute(inWS, &backgroundStrategy, prog); - std::set<size_t> uniqueEntries = - connection_workspace_to_set_of_labels(outWS.get()); + auto uniqueEntries = connection_workspace_to_set_of_labels(outWS.get()); TSM_ASSERT_EQUALS("One unique real label (and one empty)", 2, uniqueEntries.size()); TS_ASSERT(does_set_contain(uniqueEntries, labelingId)); @@ -679,8 +669,7 @@ public: // ----------- Basic cluster checks - std::set<size_t> uniqueEntries = - connection_workspace_to_set_of_labels(outWS.get()); + auto uniqueEntries = connection_workspace_to_set_of_labels(outWS.get()); TSM_ASSERT_EQUALS("Should be chequered pattern", 2, uniqueEntries.size()); TS_ASSERT(does_set_contain(uniqueEntries, size_t(0))); TS_ASSERT(does_set_contain(uniqueEntries, size_t(1))); diff --git a/Framework/Crystal/test/IntegratePeaksHybridTest.h b/Framework/Crystal/test/IntegratePeaksHybridTest.h index 8f76baa78907fdcf7bca88fb2f261eda18e2ca4a..693cf2f8bbce0a8bedcc38c6ecdc1f9d00fa817f 100644 --- a/Framework/Crystal/test/IntegratePeaksHybridTest.h +++ b/Framework/Crystal/test/IntegratePeaksHybridTest.h @@ -178,7 +178,7 @@ public: TS_ASSERT_EQUALS(outPeaksWS->getNumberPeaks(), peaksWS->getNumberPeaks()); TS_ASSERT_EQUALS(nBins * nBins * nBins, outClustersWS->getNPoints()); // Check clusters by extracting unique label ids. - std::set<Mantid::signal_t> labelIds; + std::unordered_set<Mantid::signal_t> labelIds; for (size_t i = 0; i < outClustersWS->getNPoints(); ++i) { labelIds.insert(outClustersWS->getSignalAt(i)); } @@ -270,7 +270,7 @@ public: TS_ASSERT_EQUALS(nBins * nBins * nBins, outClustersWS1->getNPoints()); TS_ASSERT_EQUALS(nBins * nBins * nBins, outClustersWS2->getNPoints()); // Check clusters by extracting unique label ids. - std::set<Mantid::signal_t> labelIds1; + std::unordered_set<Mantid::signal_t> labelIds1; for (size_t i = 0; i < outClustersWS1->getNPoints(); ++i) { labelIds1.insert(outClustersWS1->getSignalAt(i)); } @@ -278,7 +278,7 @@ public: "have two unique label ids", 2, labelIds1.size()); - std::set<Mantid::signal_t> labelIds2; + std::unordered_set<Mantid::signal_t> labelIds2; for (size_t i = 0; i < outClustersWS2->getNPoints(); ++i) { labelIds2.insert(outClustersWS2->getSignalAt(i)); } @@ -347,7 +347,7 @@ public: TS_ASSERT_EQUALS(nBins * nBins * nBins, outClustersWS1->getNPoints()); TS_ASSERT_EQUALS(nBins * nBins * nBins, outClustersWS2->getNPoints()); // Check clusters by extracting unique label ids. - std::set<Mantid::signal_t> labelIds1; + std::unordered_set<Mantid::signal_t> labelIds1; for (size_t i = 0; i < outClustersWS1->getNPoints(); ++i) { labelIds1.insert(outClustersWS1->getSignalAt(i)); } @@ -355,7 +355,7 @@ public: "have two unique label ids", 2, labelIds1.size()); - std::set<Mantid::signal_t> labelIds2; + std::unordered_set<Mantid::signal_t> labelIds2; for (size_t i = 0; i < outClustersWS2->getNPoints(); ++i) { labelIds2.insert(outClustersWS2->getSignalAt(i)); } diff --git a/Framework/Crystal/test/IntegratePeaksUsingClustersTest.h b/Framework/Crystal/test/IntegratePeaksUsingClustersTest.h index 9fb958cbb3bb9f6c9bc5b3eecac4a3aeb243cb88..1999f8ba3b5f94b69f727799ea3638909a6cf95b 100644 --- a/Framework/Crystal/test/IntegratePeaksUsingClustersTest.h +++ b/Framework/Crystal/test/IntegratePeaksUsingClustersTest.h @@ -121,7 +121,7 @@ public: IMDHistoWorkspace_sptr outClustersWS = integratedWorkspaces.get<0>(); IPeaksWorkspace_sptr outPeaksWS = integratedWorkspaces.get<1>(); - std::set<Mantid::signal_t> labelIds; + std::unordered_set<Mantid::signal_t> labelIds; for (size_t i = 0; i < outClustersWS->getNPoints(); ++i) { labelIds.insert(outClustersWS->getSignalAt(i)); } @@ -158,7 +158,7 @@ public: TS_ASSERT_EQUALS(outPeaksWS->getNumberPeaks(), peaksWS->getNumberPeaks()); TS_ASSERT_EQUALS(mdWS->getNPoints(), outClustersWS->getNPoints()); // Check clusters by extracting unique label ids. - std::set<Mantid::signal_t> labelIds; + std::unordered_set<Mantid::signal_t> labelIds; for (size_t i = 0; i < outClustersWS->getNPoints(); ++i) { labelIds.insert(outClustersWS->getSignalAt(i)); } @@ -199,7 +199,7 @@ public: TS_ASSERT_EQUALS(outPeaksWS->getNumberPeaks(), peaksWS->getNumberPeaks()); TS_ASSERT_EQUALS(mdWS->getNPoints(), outClustersWS->getNPoints()); // Check clusters by extracting unique label ids. - std::set<Mantid::signal_t> labelIds; + std::unordered_set<Mantid::signal_t> labelIds; for (size_t i = 0; i < outClustersWS->getNPoints(); ++i) { labelIds.insert(outClustersWS->getSignalAt(i)); } @@ -254,7 +254,7 @@ public: TS_ASSERT_EQUALS(outPeaksWS->getNumberPeaks(), peaksWS->getNumberPeaks()); TS_ASSERT_EQUALS(mdWS->getNPoints(), outClustersWS->getNPoints()); // Check clusters by extracting unique label ids. - std::set<Mantid::signal_t> labelIds; + std::unordered_set<Mantid::signal_t> labelIds; for (size_t i = 0; i < outClustersWS->getNPoints(); ++i) { labelIds.insert(outClustersWS->getSignalAt(i)); } diff --git a/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp b/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp index 9cc5d65aa7a0b3cd1810bed4218231eb5931fe52..94137137b586a6d524814c5456529fea1a8722a7 100644 --- a/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp +++ b/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp @@ -287,16 +287,15 @@ void SplineSmoothing::addSmoothingPoints(const std::set<int> &points, breakPoints.reserve(num_points); // set each of the x and y points to redefine the spline - std::set<int>::const_iterator pts; - for (pts = points.begin(); pts != points.end(); ++pts) { - breakPoints.push_back(xs[*pts]); + for (auto const &point : points) { + breakPoints.push_back(xs[point]); } m_cspline->setAttribute("BreakPoints", API::IFunction::Attribute(breakPoints)); int i = 0; - for (pts = points.begin(); pts != points.end(); ++pts) { - m_cspline->setParameter(i, ys[*pts]); + for (auto const &point : points) { + m_cspline->setParameter(i, ys[point]); ++i; } } diff --git a/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h b/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h index 1d5a8488d99c3a143fd1ed5df9d99c4d97e3a7e6..ead30e5efe56094a889f5f40069dde72aea3870a 100644 --- a/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h +++ b/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h @@ -33,8 +33,8 @@ public: // Test names as they are used in scripts if (profile->nAttributes() > 0) { - std::set<std::string> expectedAttrSet(expectedAttrs, - expectedAttrs + nattrs); + std::unordered_set<std::string> expectedAttrSet(expectedAttrs, + expectedAttrs + nattrs); std::vector<std::string> actualNames = profile->getAttributeNames(); for (size_t i = 0; i < nattrs; ++i) { diff --git a/Framework/CurveFitting/test/Functions/ComptonProfileTest.h b/Framework/CurveFitting/test/Functions/ComptonProfileTest.h index 2d21d6981cac2ea1c2bdd06f2e744938371e4cf7..0df3b42f0c7b947c508881076c23d11878b8a00b 100644 --- a/Framework/CurveFitting/test/Functions/ComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/ComptonProfileTest.h @@ -5,6 +5,7 @@ #include "MantidCurveFitting/Functions/ComptonProfile.h" #include <boost/make_shared.hpp> +#include <unordered_set> using Mantid::CurveFitting::Functions::ComptonProfile; @@ -30,8 +31,8 @@ public: // Test names as they are used in scripts if (profile->nAttributes() > 0) { - std::set<std::string> expectedAttrSet(expectedAttrs, - expectedAttrs + nattrs); + std::unordered_set<std::string> expectedAttrSet(expectedAttrs, + expectedAttrs + nattrs); std::vector<std::string> actualNames = profile->getAttributeNames(); for (size_t i = 0; i < nattrs; ++i) { diff --git a/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h b/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h index dfec3f0af151f71660962a523f453ec815eb1a96..9b20131892c1cacebaa046c10e65dc1712da0d4f 100644 --- a/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h @@ -56,8 +56,8 @@ public: // Test names as they are used in scripts if (profile->nAttributes() > 0) { - std::set<std::string> expectedAttrSet(expectedAttrs, - expectedAttrs + nattrs); + std::unordered_set<std::string> expectedAttrSet(expectedAttrs, + expectedAttrs + nattrs); std::vector<std::string> actualNames = profile->getAttributeNames(); for (size_t i = 0; i < nattrs; ++i) { diff --git a/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h b/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h index 905278a19172c6d03ee6b237f972058c2da5d16a..9564aa969daa157fc6f9d08631d2ec33b78617df 100644 --- a/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h @@ -129,7 +129,8 @@ private: // Test names as they are used in scripts if (nattrs <= profile.nAttributes()) { const char *attrAarr[nattrs] = {"Mass", "HermiteCoeffs"}; - std::set<std::string> expectedAttrs(attrAarr, attrAarr + nattrs); + std::unordered_set<std::string> expectedAttrs(attrAarr, + attrAarr + nattrs); std::vector<std::string> actualNames = profile.getAttributeNames(); for (size_t i = 0; i < nattrs; ++i) { diff --git a/Framework/CurveFitting/test/Functions/VesuvioResolutionTest.h b/Framework/CurveFitting/test/Functions/VesuvioResolutionTest.h index 8488b55e50588cf4734bf3b03463c4c3dd374660..cb856cefc08f34e66087ed037c49f09d0de12fcb 100644 --- a/Framework/CurveFitting/test/Functions/VesuvioResolutionTest.h +++ b/Framework/CurveFitting/test/Functions/VesuvioResolutionTest.h @@ -67,7 +67,8 @@ private: // Test names as they are used in scripts if (nattrs <= func.nAttributes()) { const char *attrAarr[nattrs] = {"Mass"}; - std::set<std::string> expectedAttrs(attrAarr, attrAarr + nattrs); + std::unordered_set<std::string> expectedAttrs(attrAarr, + attrAarr + nattrs); std::vector<std::string> actualNames = func.getAttributeNames(); for (size_t i = 0; i < nattrs; ++i) { diff --git a/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h b/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h index b90b0a561e509c1bbfc8f5779671a7834bae54ac..66c3e167245dd42f4df49c98332d38be9ac3ab1a 100644 --- a/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h +++ b/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h @@ -84,7 +84,7 @@ public: private: std::vector<IPeakFunction_sptr> - getAllPeakFunctions(const std::set<std::string> &blackList) const { + getAllPeakFunctions(const std::unordered_set<std::string> &blackList) const { std::vector<IPeakFunction_sptr> peakFunctions; std::vector<std::string> registeredFunctions = @@ -145,7 +145,7 @@ private: std::vector<IPeakFunction_sptr> m_peakFunctions; std::vector<ParameterSet> m_parameterSets; - std::set<std::string> m_blackList; + std::unordered_set<std::string> m_blackList; }; #endif // IPEAKFUNCTIONINTENSITYTEST_H diff --git a/Framework/DataHandling/inc/MantidDataHandling/DownloadInstrument.h b/Framework/DataHandling/inc/MantidDataHandling/DownloadInstrument.h index e9e4453764fff6176d3663efae79e7bc0d7913fa..f234f05d2a0f9bbcf50bde23dee27a69a858cbb8 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/DownloadInstrument.h +++ b/Framework/DataHandling/inc/MantidDataHandling/DownloadInstrument.h @@ -61,9 +61,9 @@ private: const std::string &key, const std::string &defaultValue) const; - size_t - removeOrphanedFiles(const std::string &directoryPath, - const std::set<std::string> &filenamesToKeep) const; + size_t removeOrphanedFiles( + const std::string &directoryPath, + const std::unordered_set<std::string> &filenamesToKeep) const; Kernel::ProxyInfo m_proxyInfo; }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/Load.h b/Framework/DataHandling/inc/MantidDataHandling/Load.h index 521d80f563fcd35f1777fddc9e79f61b9ddba6ee..40c66ae8d7580210dc547facd312e04fb740d05d 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/Load.h +++ b/Framework/DataHandling/inc/MantidDataHandling/Load.h @@ -105,7 +105,7 @@ private: groupWsList(const std::vector<API::Workspace_sptr> &wsList); /// The base properties - std::set<std::string> m_baseProps; + std::unordered_set<std::string> m_baseProps; /// The actual loader API::IAlgorithm_sptr m_loader; /// The name of the property that will be passed the property from our diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h b/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h index 20bef365ca920fd6335ac6d174c7b291d8f41575..14b68523a4313a9936cee9bb7d6afc0ee6b3c3e0 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h @@ -70,9 +70,9 @@ public: private: /// Store the units known to the UnitFactory - std::set<std::string> m_unitKeys; + std::unordered_set<std::string> m_unitKeys; /// Store the units added as options for this algorithm - std::set<std::string> m_RKHKeys; + std::unordered_set<std::string> m_RKHKeys; /// the input stream for the file being loaded std::ifstream m_fileIn; diff --git a/Framework/DataHandling/src/DownloadInstrument.cpp b/Framework/DataHandling/src/DownloadInstrument.cpp index 8df3f25d29e63809b35e5726baf9a8bdecbd7351..2ac3f74bca8f6a91d9014482fc3d410230627171 100644 --- a/Framework/DataHandling/src/DownloadInstrument.cpp +++ b/Framework/DataHandling/src/DownloadInstrument.cpp @@ -177,7 +177,7 @@ DownloadInstrument::StringToStringMap DownloadInstrument::processRepository() { } fileStream.close(); - std::set<std::string> repoFilenames; + std::unordered_set<std::string> repoFilenames; for (auto &serverElement : serverContents) { std::string name = serverElement.get("name", "").asString(); @@ -268,7 +268,7 @@ DownloadInstrument::getFileShas(const std::string &directoryPath) { **/ size_t DownloadInstrument::removeOrphanedFiles( const std::string &directoryPath, - const std::set<std::string> &filenamesToKeep) const { + const std::unordered_set<std::string> &filenamesToKeep) const { // hold files to delete in a set so we don't remove files while iterating over // the directory. std::vector<std::string> filesToDelete; diff --git a/Framework/DataHandling/src/EventWorkspaceCollection.cpp b/Framework/DataHandling/src/EventWorkspaceCollection.cpp index 3e8ca03dd93fd9c5a1ba352e65411be680d98aca..e5a6da361dab6f43ff71a0f4acd255f2aaab5097 100644 --- a/Framework/DataHandling/src/EventWorkspaceCollection.cpp +++ b/Framework/DataHandling/src/EventWorkspaceCollection.cpp @@ -80,7 +80,8 @@ void EventWorkspaceCollection::setNPeriods( m_WsVec = std::vector<DataObjects::EventWorkspace_sptr>(nPeriods); std::vector<int> periodNumbers = periodLog->valuesAsVector(); - std::set<int> uniquePeriods(periodNumbers.begin(), periodNumbers.end()); + std::unordered_set<int> uniquePeriods(periodNumbers.begin(), + periodNumbers.end()); const bool addBoolTimeSeries = (uniquePeriods.size() == nPeriods); for (size_t i = 0; i < m_WsVec.size(); ++i) { diff --git a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp index 1a5e69b45e449a3b61a34d70db59b5608419d8e9..c59ec319e9abb6dee871d7fcd1b6cd207a2addf3 100644 --- a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp +++ b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp @@ -598,9 +598,9 @@ FilterEventsByLogValuePreNexus::setupOutputEventWorkspace() { * (3) (Optionally) write out information */ void FilterEventsByLogValuePreNexus::processEventLogs() { - std::set<PixelType>::iterator pit; std::map<PixelType, size_t>::iterator mit; - for (pit = this->wrongdetids.begin(); pit != this->wrongdetids.end(); ++pit) { + for (auto pit = this->wrongdetids.begin(); pit != this->wrongdetids.end(); + ++pit) { // Convert Pixel ID to 'wrong detectors ID' map's index PixelType pid = *pit; mit = this->wrongdetidmap.find(pid); @@ -1110,8 +1110,7 @@ void FilterEventsByLogValuePreNexus::procEvents( << "Number of Wrong Detector IDs = " << wrongdetids.size() << "\n"; - std::set<PixelType>::iterator wit; - for (wit = this->wrongdetids.begin(); wit != this->wrongdetids.end(); + for (auto wit = this->wrongdetids.begin(); wit != this->wrongdetids.end(); ++wit) { g_log.notice() << "Wrong Detector ID : " << *wit << std::endl; } @@ -1360,8 +1359,8 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( this->m_numBadEvents += local_numBadEvents; this->m_numWrongdetidEvents += local_numWrongdetidEvents; - std::set<PixelType>::iterator it; - for (it = local_wrongdetids.begin(); it != local_wrongdetids.end(); ++it) { + for (auto it = local_wrongdetids.begin(); it != local_wrongdetids.end(); + ++it) { PixelType tmpid = *it; this->wrongdetids.insert(*it); @@ -1757,14 +1756,12 @@ void FilterEventsByLogValuePreNexus::filterEvents() { << " microsec; longest TOF: " << m_longestTof << " microsec." << "\n"; - std::set<PixelType>::iterator wit; - for (wit = this->wrongdetids.begin(); wit != this->wrongdetids.end(); + for (auto wit = this->wrongdetids.begin(); wit != this->wrongdetids.end(); ++wit) { g_log.notice() << "Wrong Detector ID : " << *wit << std::endl; } - std::map<PixelType, size_t>::iterator git; - for (git = this->wrongdetidmap.begin(); git != this->wrongdetidmap.end(); - ++git) { + for (auto git = this->wrongdetidmap.begin(); + git != this->wrongdetidmap.end(); ++git) { PixelType tmpid = git->first; size_t vindex = git->second; g_log.notice() << "Pixel " << tmpid << ": Total number of events = " diff --git a/Framework/DataHandling/src/LoadEventPreNexus2.cpp b/Framework/DataHandling/src/LoadEventPreNexus2.cpp index ea50553b23e3d497d7f3164f18e66b40d04470b7..71ec3dcb2f6bea1959f3320e6e484e0b61237b45 100644 --- a/Framework/DataHandling/src/LoadEventPreNexus2.cpp +++ b/Framework/DataHandling/src/LoadEventPreNexus2.cpp @@ -529,9 +529,9 @@ LoadEventPreNexus2::generateEventDistribtionWorkspace() { /** Process imbed logs (marked by bad pixel IDs) */ void LoadEventPreNexus2::processImbedLogs() { - std::set<PixelType>::iterator pit; std::map<PixelType, size_t>::iterator mit; - for (pit = this->wrongdetids.begin(); pit != this->wrongdetids.end(); ++pit) { + for (auto pit = this->wrongdetids.begin(); pit != this->wrongdetids.end(); + ++pit) { // a. pixel ID -> index PixelType pid = *pit; mit = this->wrongdetidmap.find(pid); diff --git a/Framework/DataHandling/src/LoadIsawDetCal.cpp b/Framework/DataHandling/src/LoadIsawDetCal.cpp index dc4210e84fef3a9af2c8dc9f91a4210b2e65b26e..1896c1a09b3ff208861da98e7d2558ed34a15403 100644 --- a/Framework/DataHandling/src/LoadIsawDetCal.cpp +++ b/Framework/DataHandling/src/LoadIsawDetCal.cpp @@ -130,7 +130,7 @@ void LoadIsawDetCal::exec() { } } } - std::set<int> uniqueBanks; // for CORELLI and WISH + std::unordered_set<int> uniqueBanks; // for CORELLI and WISH std::string bankPart = "bank"; if (instname.compare("WISH") == 0) bankPart = "WISHpanel"; @@ -295,8 +295,7 @@ void LoadIsawDetCal::exec() { } // Loop through tube detectors to match names with number from DetCal file idnum = -1; - std::set<int>::iterator it; - for (it = uniqueBanks.begin(); it != uniqueBanks.end(); ++it) + for (auto it = uniqueBanks.begin(); it != uniqueBanks.end(); ++it) if (*it == id) idnum = *it; if (idnum < 0) diff --git a/Framework/DataHandling/src/LoadVulcanCalFile.cpp b/Framework/DataHandling/src/LoadVulcanCalFile.cpp index c75e092a8df23089b040ad219d3adf37d67fd73d..8e411fb1dfc37238078b0e387cff1c65846a6425 100644 --- a/Framework/DataHandling/src/LoadVulcanCalFile.cpp +++ b/Framework/DataHandling/src/LoadVulcanCalFile.cpp @@ -435,11 +435,10 @@ void LoadVulcanCalFile::processOffsets( } // Get the global correction - std::set<int>::iterator biter; g_log.information() << "Number of bankds to process = " << set_bankID.size() << "\n"; map<int, double> map_bankLogCorr; - for (biter = set_bankID.begin(); biter != set_bankID.end(); ++biter) { + for (auto biter = set_bankID.begin(); biter != set_bankID.end(); ++biter) { // Locate inter bank and inter pack correction (log) int bankid = *biter; double globalfactor = 0.; diff --git a/Framework/DataHandling/src/SaveDetectorsGrouping.cpp b/Framework/DataHandling/src/SaveDetectorsGrouping.cpp index 6cf919364ca236a5c0170635e2623e61800afce3..55d50ff0b166b17071e59c26350d172ac544d03b 100644 --- a/Framework/DataHandling/src/SaveDetectorsGrouping.cpp +++ b/Framework/DataHandling/src/SaveDetectorsGrouping.cpp @@ -109,7 +109,7 @@ void SaveDetectorsGrouping::createGroupDetectorIDMap( << " has no spectrum. Impossible!" << std::endl; throw; } - std::set<detid_t> detids = mspec->getDetectorIDs(); + auto detids = mspec->getDetectorIDs(); if (detids.size() != 1) { g_log.error() << "Spectrum " << mspec->getSpectrumNo() << " has " << detids.size() << " detectors. Not allowed situation!" diff --git a/Framework/DataHandling/src/SaveMask.cpp b/Framework/DataHandling/src/SaveMask.cpp index 6100cd482a81e4f00e1a8d4ffe72844f6079df42..091c175fc42dfeacc6b69be44cf64a038cd97342 100644 --- a/Framework/DataHandling/src/SaveMask.cpp +++ b/Framework/DataHandling/src/SaveMask.cpp @@ -99,16 +99,12 @@ void SaveMask::exec() { throw std::invalid_argument("Cannot find spectrum"); } - const std::set<detid_t> detids = spec->getDetectorIDs(); + const auto detids = spec->getDetectorIDs(); // b) get detector id & Store - detid_t detid; - ; - std::set<detid_t>::const_iterator it; - for (it = detids.begin(); it != detids.end(); ++it) { - detid = *it; + for (const auto &det_id : detids) { // c) store - detid0s.push_back(detid); + detid0s.push_back(det_id); } } // if } // for diff --git a/Framework/DataHandling/test/LoadEventPreNexus2Test.h b/Framework/DataHandling/test/LoadEventPreNexus2Test.h index 82cfdcf29a8876e8d15e1010b7c39815b5797ce6..e6177dd0b453dee59561c22241068b67270f6513 100644 --- a/Framework/DataHandling/test/LoadEventPreNexus2Test.h +++ b/Framework/DataHandling/test/LoadEventPreNexus2Test.h @@ -254,7 +254,7 @@ public: // Are the pixel IDs ok? TS_ASSERT_EQUALS(ew->getSpectrum(0)->getSpectrumNo(), 46); - std::set<detid_t> dets = ew->getSpectrum(0)->getDetectorIDs(); + auto dets = ew->getSpectrum(0)->getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*dets.begin(), 45); diff --git a/Framework/DataHandling/test/LoadEventPreNexusTest.h b/Framework/DataHandling/test/LoadEventPreNexusTest.h index 6ede4d9091d811d0e951323f1df2f771a99ba4fa..8247027bac4ceed0aaa814a9c4b183594e744b17 100644 --- a/Framework/DataHandling/test/LoadEventPreNexusTest.h +++ b/Framework/DataHandling/test/LoadEventPreNexusTest.h @@ -253,7 +253,7 @@ public: // Are the pixel IDs ok? TS_ASSERT_EQUALS(ew->getSpectrum(0)->getSpectrumNo(), 46); - std::set<detid_t> dets = ew->getSpectrum(0)->getDetectorIDs(); + auto dets = ew->getSpectrum(0)->getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*dets.begin(), 45); diff --git a/Framework/DataHandling/test/LoadInstrumentTest.h b/Framework/DataHandling/test/LoadInstrumentTest.h index 416d5801b6bc415db46cd1b6fd05c87db2191b25..911edd5e7e773e32ec964d1731511a28ed334e41 100644 --- a/Framework/DataHandling/test/LoadInstrumentTest.h +++ b/Framework/DataHandling/test/LoadInstrumentTest.h @@ -138,7 +138,7 @@ public: TS_ASSERT_EQUALS(output->getAxis(1)->spectraNo(256), 257); TS_ASSERT_EQUALS(output->getAxis(1)->spectraNo(257), 258); - std::set<detid_t> ids_from_map = output->getSpectrum(257)->getDetectorIDs(); + auto ids_from_map = output->getSpectrum(257)->getDetectorIDs(); IDetector_const_sptr det_from_ws = output->getDetector(257); TS_ASSERT_EQUALS(ids_from_map.size(), 1); TS_ASSERT_EQUALS(*ids_from_map.begin(), 602); diff --git a/Framework/DataHandling/test/LoadMuonNexus2Test.h b/Framework/DataHandling/test/LoadMuonNexus2Test.h index 91b610cc310699fbf7851fa5360edfa52302456c..061e768cebac77130a1ec8031ba04a31d4744951 100644 --- a/Framework/DataHandling/test/LoadMuonNexus2Test.h +++ b/Framework/DataHandling/test/LoadMuonNexus2Test.h @@ -38,7 +38,7 @@ public: // Test one to one mapping, for example spectra 6 has only 1 pixel TS_ASSERT_EQUALS(output->getSpectrum(6)->getDetectorIDs().size(), 1); - std::set<detid_t> detectorgroup = output->getSpectrum(99)->getDetectorIDs(); + auto detectorgroup = output->getSpectrum(99)->getDetectorIDs(); TS_ASSERT_EQUALS(detectorgroup.size(), 1); TS_ASSERT_EQUALS(*detectorgroup.begin(), 100); } diff --git a/Framework/DataHandling/test/LoadNexusLogsTest.h b/Framework/DataHandling/test/LoadNexusLogsTest.h index ab451ae3cc2a4915658d0308d3091ef2554631ba..e341122050bfdf3f2dc751be77b81dda5e02fd07 100644 --- a/Framework/DataHandling/test/LoadNexusLogsTest.h +++ b/Framework/DataHandling/test/LoadNexusLogsTest.h @@ -163,7 +163,8 @@ public: TSM_ASSERT("Period log should be an int time series property", periodLog); std::vector<int> periodValues = periodLog->valuesAsVector(); - std::set<int> uniquePeriods(periodValues.begin(), periodValues.end()); + std::unordered_set<int> uniquePeriods(periodValues.begin(), + periodValues.end()); TSM_ASSERT_EQUALS("Should have 4 periods in total", 4, uniquePeriods.size()); } diff --git a/Framework/DataObjects/src/GroupingWorkspace.cpp b/Framework/DataObjects/src/GroupingWorkspace.cpp index d4a44681a06820954f0f8c24351d1f293dc60e3a..1d63636fd0e36987863112a851749855e051634b 100644 --- a/Framework/DataObjects/src/GroupingWorkspace.cpp +++ b/Framework/DataObjects/src/GroupingWorkspace.cpp @@ -58,7 +58,7 @@ void GroupingWorkspace::makeDetectorIDToGroupMap( int group = static_cast<int>(this->readY(wi)[0]); if (group == 0) group = -1; - std::set<detid_t> detIDs = this->getDetectorIDs(wi); + auto detIDs = this->getDetectorIDs(wi); for (auto detID : detIDs) { detIDToGroup[detID] = group; if (group > ngroups) @@ -84,7 +84,7 @@ void GroupingWorkspace::makeDetectorIDToGroupVector( int group = static_cast<int>(this->readY(wi)[0]); if (group == 0) group = -1; - std::set<detid_t> detIDs = this->getDetectorIDs(wi); + auto detIDs = this->getDetectorIDs(wi); for (auto detID : detIDs) { if (detID < 0) // if you need negative detector ids, use the other function diff --git a/Framework/DataObjects/test/GroupingWorkspaceTest.h b/Framework/DataObjects/test/GroupingWorkspaceTest.h index f9227b6a36f6f1023336996a5db592d1470a389f..6576262247655a23de169fde520c2bff3756488d 100644 --- a/Framework/DataObjects/test/GroupingWorkspaceTest.h +++ b/Framework/DataObjects/test/GroupingWorkspaceTest.h @@ -38,7 +38,7 @@ public: TS_ASSERT_EQUALS(ws->blocksize(), 1); TS_ASSERT_EQUALS(ws->getInstrument()->getName(), "basic"); // Name of the test instrument - std::set<detid_t> dets = ws->getSpectrum(0)->getDetectorIDs(); + auto dets = ws->getSpectrum(0)->getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); // Set the group numbers @@ -72,7 +72,7 @@ public: TS_ASSERT_EQUALS(cloned->blocksize(), 1); TS_ASSERT_EQUALS(cloned->getInstrument()->getName(), "basic"); // Name of the test instrument - std::set<detid_t> dets = cloned->getSpectrum(0)->getDetectorIDs(); + auto dets = cloned->getSpectrum(0)->getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); // Set the group numbers diff --git a/Framework/DataObjects/test/SpecialWorkspace2DTest.h b/Framework/DataObjects/test/SpecialWorkspace2DTest.h index a9ee4305c129b0f02700adec3bf3c4baafeb3081..5124ceea1f5c361d72ca731cd454566d54ef81c5 100644 --- a/Framework/DataObjects/test/SpecialWorkspace2DTest.h +++ b/Framework/DataObjects/test/SpecialWorkspace2DTest.h @@ -65,7 +65,7 @@ public: TS_ASSERT_EQUALS(ws->blocksize(), 1); TS_ASSERT_EQUALS(ws->getInstrument()->getName(), "basic"); // Name of the test instrument - const std::set<detid_t> &dets = ws->getSpectrum(0)->getDetectorIDs(); + const auto &dets = ws->getSpectrum(0)->getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*(ws->getDetectorIDs(0).begin()), 1); diff --git a/Framework/DataObjects/test/Workspace2DTest.h b/Framework/DataObjects/test/Workspace2DTest.h index f83d5c4aa8d2bf8adb136254276aef5c0ab6a9ce..40a15223b5ba715f46a7b668776e7e7f5510f6dc 100644 --- a/Framework/DataObjects/test/Workspace2DTest.h +++ b/Framework/DataObjects/test/Workspace2DTest.h @@ -301,7 +301,7 @@ public: CPUTimer tim; for (size_t i = 0; i < ws1->getNumberHistograms(); i++) { const ISpectrum *spec = ws1->getSpectrum(i); - const std::set<detid_t> &detIDs = spec->getDetectorIDs(); + const auto &detIDs = spec->getDetectorIDs(); detid_t oneDetId = *detIDs.begin(); UNUSED_ARG(oneDetId) } diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/SymmetryElementFactory.h b/Framework/Geometry/inc/MantidGeometry/Crystal/SymmetryElementFactory.h index 172642a9dff47403d8292ce2480724f18a74095a..7be58070cdadfcdc560abbde28197352e18f90c7 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/SymmetryElementFactory.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/SymmetryElementFactory.h @@ -8,7 +8,7 @@ #include "MantidKernel/RegistrationHelper.h" #include <boost/make_shared.hpp> -#include <set> +#include <unordered_set> namespace Mantid { namespace Geometry { @@ -270,7 +270,7 @@ protected: const SymmetryElement_sptr &prototype); std::vector<AbstractSymmetryElementGenerator_sptr> m_generators; - std::set<std::string> m_generatorNames; + std::unordered_set<std::string> m_generatorNames; std::map<std::string, SymmetryElement_sptr> m_prototypes; private: diff --git a/Framework/Geometry/src/Instrument/Component.cpp b/Framework/Geometry/src/Instrument/Component.cpp index 0a60284bdd6683f27f559290d9216fdaad2cfad5..f089dd4ad8bc66df5aaf9f21792d389285091783 100644 --- a/Framework/Geometry/src/Instrument/Component.cpp +++ b/Framework/Geometry/src/Instrument/Component.cpp @@ -447,7 +447,7 @@ Component::getParameterNamesByComponent() const { if (!m_map) return retVal; - std::set<std::string> names = m_map->names(this); + auto names = m_map->names(this); for (const auto &name : names) { retVal.insert( std::pair<std::string, ComponentID>(name, this->getComponentID())); diff --git a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp index 9440587a284187893b3d4ee4e3eed34ff0f48528..4136d9d8f5179fc70b21ba8a247426a9f4f617c0 100644 --- a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp +++ b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp @@ -29,6 +29,7 @@ #include <Poco/SAX/AttributesImpl.h> #include <boost/make_shared.hpp> +#include <unordered_set> using namespace Mantid; using namespace Mantid::Kernel; @@ -2398,7 +2399,8 @@ void InstrumentDefinitionParser::adjust( // added // to pElem, and these <component>'s are deleted after loop - std::set<Element *> allComponentInType; // used to hold <component>'s found + std::unordered_set<Element *> + allComponentInType; // used to hold <component>'s found std::vector<std::string> allLocationName; // used to check if loc names unique for (unsigned long i = 0; i < numLocation; i++) { Element *pLoc = static_cast<Element *>(pNL->item(i)); @@ -2471,8 +2473,8 @@ void InstrumentDefinitionParser::adjust( } // delete all <component> found in pElem - std::set<Element *>::iterator it; - for (it = allComponentInType.begin(); it != allComponentInType.end(); ++it) + for (auto it = allComponentInType.begin(); it != allComponentInType.end(); + ++it) pElem->removeChild(*it); } diff --git a/Framework/Geometry/src/Instrument/ParameterMap.cpp b/Framework/Geometry/src/Instrument/ParameterMap.cpp index b8bb9a01eb377ce40c6796e0486b6700d8ec4360..3bab8f20c1669249d3d0e26bfd5de9c50f631503 100644 --- a/Framework/Geometry/src/Instrument/ParameterMap.cpp +++ b/Framework/Geometry/src/Instrument/ParameterMap.cpp @@ -1045,7 +1045,7 @@ void ParameterMap::copyFromParameterMap(const IComponent *oldComp, const IComponent *newComp, const ParameterMap *oldPMap) { - std::set<std::string> oldParameterNames = oldPMap->names(oldComp); + auto oldParameterNames = oldPMap->names(oldComp); for (const auto &oldParameterName : oldParameterNames) { Parameter_sptr thisParameter = oldPMap->get(oldComp, oldParameterName); // Insert the fetched parameter in the m_map diff --git a/Framework/Geometry/test/GroupTransformationTest.h b/Framework/Geometry/test/GroupTransformationTest.h index 19140461a04e3816990afb6fc1bbbe6213020166..e583286acb052eadbc62e08dbb1767e9090624d0 100644 --- a/Framework/Geometry/test/GroupTransformationTest.h +++ b/Framework/Geometry/test/GroupTransformationTest.h @@ -8,6 +8,8 @@ #include "MantidGeometry/Crystal/SpaceGroupFactory.h" #include "MantidGeometry/Crystal/ProductOfCyclicGroups.h" +#include <unordered_set> + using namespace Mantid::Geometry; using namespace Mantid::Kernel; @@ -47,7 +49,7 @@ public: * 3. 2-fold rotation || z * 4. Mirror plane perpendicular to z. */ - std::set<std::string> elements; + std::unordered_set<std::string> elements; std::vector<SymmetryOperation> ops = transformed.getSymmetryOperations(); for (auto op = ops.begin(); op != ops.end(); ++op) { SymmetryElement_sptr el = diff --git a/Framework/Geometry/test/ParametrizedComponentTest.h b/Framework/Geometry/test/ParametrizedComponentTest.h index b9120c7a335946ab2dc947f69dc8e1ae9bfb73d8..288b31caf89a78c4ff01d5a853e8ff1093aa2720 100644 --- a/Framework/Geometry/test/ParametrizedComponentTest.h +++ b/Framework/Geometry/test/ParametrizedComponentTest.h @@ -126,7 +126,7 @@ public: void testThatCorrectParametersAreListed() { Component *paramComp = createSingleParameterizedComponent(); - std::set<std::string> paramNames = paramComp->getParameterNames(); + auto paramNames = paramComp->getParameterNames(); TS_ASSERT_EQUALS(paramNames.size(), 4); checkBaseParameterNamesExist(paramNames); @@ -141,7 +141,7 @@ public: Component *grandchild = new Component(m_childTwoComp, m_paramMap.get()); // Parent - std::set<std::string> paramNames = parent->getParameterNames(); + auto paramNames = parent->getParameterNames(); TS_ASSERT_EQUALS(paramNames.size(), 4); checkBaseParameterNamesExist(paramNames); // Child @@ -165,7 +165,7 @@ public: void testThatNonRecursiveParameterSearchReturnsOnlyComponentParameters() { createParameterizedTree(); Component *child = new Component(m_childOneComp, m_paramMap.get()); - std::set<std::string> paramNames = child->getParameterNames(false); + auto paramNames = child->getParameterNames(false); TS_ASSERT_EQUALS(paramNames.size(), 1); TS_ASSERT_DIFFERS(paramNames.find(m_strName + "_child1"), paramNames.end()); diff --git a/Framework/Geometry/test/ReflectionConditionTest.h b/Framework/Geometry/test/ReflectionConditionTest.h index ba8a2582881d160185ea962ae026cc953743472b..58875720487a3e13c50dd7a87cd2d7e6722f9e97 100644 --- a/Framework/Geometry/test/ReflectionConditionTest.h +++ b/Framework/Geometry/test/ReflectionConditionTest.h @@ -5,7 +5,7 @@ #include "MantidKernel/System.h" #include "MantidKernel/Timer.h" #include <cxxtest/TestSuite.h> -#include <set> +#include <unordered_set> using namespace Mantid::Geometry; @@ -46,7 +46,7 @@ public: } void test_ReflectionConditionSymbols() { - std::set<std::string> centeringSymbols; + std::unordered_set<std::string> centeringSymbols; centeringSymbols.insert("P"); centeringSymbols.insert("A"); centeringSymbols.insert("B"); diff --git a/Framework/ICat/src/CatalogAlgorithmHelper.cpp b/Framework/ICat/src/CatalogAlgorithmHelper.cpp index 5eec3b819923de059ff7db0b54572fb78805971b..dd603e19251635b48ddde8c3ac6f1e85eb9665e9 100644 --- a/Framework/ICat/src/CatalogAlgorithmHelper.cpp +++ b/Framework/ICat/src/CatalogAlgorithmHelper.cpp @@ -2,6 +2,7 @@ #include <json/reader.h> #include <json/value.h> +#include <set> namespace Mantid { namespace ICat { diff --git a/Framework/Kernel/inc/MantidKernel/DataService.h b/Framework/Kernel/inc/MantidKernel/DataService.h index 3b63696a23c170dc3e82ee9d4e4828151a94e407..8799b46714d9bf8b5d30cec0ca95811453000367 100644 --- a/Framework/Kernel/inc/MantidKernel/DataService.h +++ b/Framework/Kernel/inc/MantidKernel/DataService.h @@ -13,6 +13,7 @@ #include "MantidKernel/Logger.h" #include "MantidKernel/Exception.h" #include "MantidKernel/ConfigService.h" +#include <unordered_set> namespace Mantid { namespace Kernel { @@ -400,13 +401,13 @@ public: } /// Get the names of the data objects stored by the service - std::set<std::string> getObjectNames() const { + std::unordered_set<std::string> getObjectNames() const { if (showingHiddenObjects()) return getObjectNamesInclHidden(); Poco::Mutex::ScopedLock _lock(m_mutex); - std::set<std::string> names; + std::unordered_set<std::string> names; for (svc_constit it = datamap.begin(); it != datamap.end(); ++it) { if (!isHiddenDataServiceObject(it->first)) { names.insert(it->first); @@ -416,10 +417,10 @@ public: } /// Get the names of the data objects stored by the service - std::set<std::string> getObjectNamesInclHidden() const { + std::unordered_set<std::string> getObjectNamesInclHidden() const { Poco::Mutex::ScopedLock _lock(m_mutex); - std::set<std::string> names; + std::unordered_set<std::string> names; for (svc_constit it = datamap.begin(); it != datamap.end(); ++it) { names.insert(it->first); } diff --git a/Framework/Kernel/inc/MantidKernel/IPropertyManager.h b/Framework/Kernel/inc/MantidKernel/IPropertyManager.h index dbfaa5cab13978a8aa59957d67c9345a748b5b2c..30312d07b263fad913cfaa3d120d516192eed640 100644 --- a/Framework/Kernel/inc/MantidKernel/IPropertyManager.h +++ b/Framework/Kernel/inc/MantidKernel/IPropertyManager.h @@ -7,7 +7,7 @@ #include "MantidKernel/PropertyWithValue.h" #include "MantidKernel/OptionalBool.h" #include <vector> -#include <set> +#include <unordered_set> namespace Json { class Value; @@ -79,8 +79,8 @@ public: */ virtual void setPropertiesWithSimpleString( const std::string &propertiesString, - const std::set<std::string> & - ignoreProperties = std::set<std::string>()) = 0; + const std::unordered_set<std::string> & + ignoreProperties = std::unordered_set<std::string>()) = 0; /** Sets all the declared properties from a string. @param propertiesJson :: A string of name = value pairs formatted @@ -90,8 +90,8 @@ public: */ virtual void setProperties(const std::string &propertiesJson, - const std::set<std::string> & - ignoreProperties = std::set<std::string>()) = 0; + const std::unordered_set<std::string> & + ignoreProperties = std::unordered_set<std::string>()) = 0; /** Sets all the declared properties from a json object @param jsonValue :: A json name value pair collection @@ -100,8 +100,8 @@ public: */ virtual void setProperties(const ::Json::Value &jsonValue, - const std::set<std::string> & - ignoreProperties = std::set<std::string>()) = 0; + const std::unordered_set<std::string> & + ignoreProperties = std::unordered_set<std::string>()) = 0; /** Sets property value from a string @param name :: Property name diff --git a/Framework/Kernel/inc/MantidKernel/ListValidator.h b/Framework/Kernel/inc/MantidKernel/ListValidator.h index dae06ff2adb93696175364e101c541288676d046..d5c80a5ab55214e55a1cd4bf6e23dd536248c450 100644 --- a/Framework/Kernel/inc/MantidKernel/ListValidator.h +++ b/Framework/Kernel/inc/MantidKernel/ListValidator.h @@ -11,6 +11,7 @@ #include <vector> #include <set> #include <map> +#include <unordered_set> namespace Mantid { namespace Kernel { @@ -52,6 +53,12 @@ public: explicit ListValidator(const std::set<TYPE> &values) : TypedValidator<TYPE>(), m_allowedValues(values.begin(), values.end()) {} + /** Constructor + * @param values :: An unordered set of values consisting of the valid values + */ + explicit ListValidator(const std::unordered_set<TYPE> &values) + : TypedValidator<TYPE>(), m_allowedValues(values.begin(), values.end()) {} + /** Constructor * @param values :: A vector of the valid values * @param aliases :: Optional aliases for the valid values. diff --git a/Framework/Kernel/inc/MantidKernel/NexusDescriptor.h b/Framework/Kernel/inc/MantidKernel/NexusDescriptor.h index f46774eebf53aea807b0107ba22d4e8e51cdeb7f..d4c8f2c0c744f7d3393d00c67e3aef92a23bb4bb 100644 --- a/Framework/Kernel/inc/MantidKernel/NexusDescriptor.h +++ b/Framework/Kernel/inc/MantidKernel/NexusDescriptor.h @@ -5,7 +5,7 @@ #include "MantidKernel/DllConfig.h" #include <map> -#include <set> +#include <unordered_set> #include <string> #include <utility> @@ -115,7 +115,7 @@ private: /// First entry name/type std::pair<std::string, std::string> m_firstEntryNameType; /// Root attributes - std::set<std::string> m_rootAttrs; + std::unordered_set<std::string> m_rootAttrs; /// Map of full path strings to types. Can check if path exists quickly std::map<std::string, std::string> m_pathsToTypes; diff --git a/Framework/Kernel/inc/MantidKernel/PropertyManager.h b/Framework/Kernel/inc/MantidKernel/PropertyManager.h index 9a3893fdb3ddffe0dd3727e166d1d6068bdacee4..afc7bfa4dc7b7e87acc4a7664c426978affe8c7c 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyManager.h +++ b/Framework/Kernel/inc/MantidKernel/PropertyManager.h @@ -75,21 +75,22 @@ public: // Sets all the declared properties from void setProperties(const std::string &propertiesJson, - const std::set<std::string> &ignoreProperties = - std::set<std::string>()) override; + const std::unordered_set<std::string> &ignoreProperties = + std::unordered_set<std::string>()) override; void setProperties(const std::string &propertiesJson, IPropertyManager *targetPropertyManager, - const std::set<std::string> &ignoreProperties); + const std::unordered_set<std::string> &ignoreProperties); void setProperties(const ::Json::Value &jsonValue, - const std::set<std::string> &ignoreProperties = - std::set<std::string>()) override; - void setProperties( - const ::Json::Value &jsonValue, IPropertyManager *targetPropertyManager, - const std::set<std::string> &ignoreProperties = std::set<std::string>()); - void - setPropertiesWithSimpleString(const std::string &propertiesString, - const std::set<std::string> &ignoreProperties = - std::set<std::string>()) override; + const std::unordered_set<std::string> &ignoreProperties = + std::unordered_set<std::string>()) override; + void setProperties(const ::Json::Value &jsonValue, + IPropertyManager *targetPropertyManager, + const std::unordered_set<std::string> &ignoreProperties = + std::unordered_set<std::string>()); + void setPropertiesWithSimpleString( + const std::string &propertiesString, + const std::unordered_set<std::string> &ignoreProperties = + std::unordered_set<std::string>()) override; void setPropertyValue(const std::string &name, const std::string &value) override; void setPropertyOrdinal(const int &index, const std::string &value) override; diff --git a/Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h b/Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h index e926017973cfad4c52d06973940b84f2c986b67f..8fd7aa924c2a1fa5cce34c1fc3419ff3cae0e31d 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h +++ b/Framework/Kernel/inc/MantidKernel/PropertyManagerOwner.h @@ -61,19 +61,19 @@ public: // Sets all the declared properties from void setProperties(const std::string &propertiesJson, - const std::set<std::string> &ignoreProperties = - std::set<std::string>()) override; + const std::unordered_set<std::string> &ignoreProperties = + std::unordered_set<std::string>()) override; // Sets all the declared properties from a json object void setProperties(const ::Json::Value &jsonValue, - const std::set<std::string> &ignoreProperties = - std::set<std::string>()) override; + const std::unordered_set<std::string> &ignoreProperties = + std::unordered_set<std::string>()) override; // sets all the declared properties using a simple string format - void - setPropertiesWithSimpleString(const std::string &propertiesString, - const std::set<std::string> &ignoreProperties = - std::set<std::string>()) override; + void setPropertiesWithSimpleString( + const std::string &propertiesString, + const std::unordered_set<std::string> &ignoreProperties = + std::unordered_set<std::string>()) override; void setPropertyValue(const std::string &name, const std::string &value) override; diff --git a/Framework/Kernel/src/CompositeValidator.cpp b/Framework/Kernel/src/CompositeValidator.cpp index 770bbdc0261f37bf6c4ce59beb59a66d46492c57..b87ecc4f290104bb1ed23eca042d291e5ac90418 100644 --- a/Framework/Kernel/src/CompositeValidator.cpp +++ b/Framework/Kernel/src/CompositeValidator.cpp @@ -1,4 +1,5 @@ #include "MantidKernel/CompositeValidator.h" +#include <unordered_set> using namespace Mantid::Kernel; @@ -11,13 +12,13 @@ CompositeValidator::CompositeValidator() : IValidator(), m_children() {} CompositeValidator::~CompositeValidator() { m_children.clear(); } /** - * The allowed values for the composite vaidator. This returns + * The allowed values for the composite validator. This returns * the intersection of the allowedValues for the child validators * @return */ std::vector<std::string> CompositeValidator::allowedValues() const { - std::set<std::string> elem_unique; - std::multiset<std::string> elem_all; + std::unordered_set<std::string> elem_unique; + std::unordered_multiset<std::string> elem_all; // how many validators return non-empty list of allowed values int n_combinations(0); for (const auto &itr : m_children) { @@ -36,7 +37,7 @@ std::vector<std::string> CompositeValidator::allowedValues() const { auto im = elem_all.find(its); elem_all.erase(im); } - std::set<std::string> rez; + std::unordered_set<std::string> rez; for (const auto &im : elem_all) { rez.insert(im); } diff --git a/Framework/Kernel/src/LibraryManager.cpp b/Framework/Kernel/src/LibraryManager.cpp index 94a777034466932bbdcd11af854c3589a85a0802..7ba649cb5f235bf07a74d18ddf4459acd3d2e5f7 100644 --- a/Framework/Kernel/src/LibraryManager.cpp +++ b/Framework/Kernel/src/LibraryManager.cpp @@ -10,6 +10,7 @@ #include <Poco/DirectoryIterator.h> #include <boost/algorithm/string.hpp> #include <boost/make_shared.hpp> +#include <unordered_set> namespace Mantid { namespace Kernel { @@ -80,7 +81,7 @@ int LibraryManagerImpl::OpenAllLibraries(const std::string &filePath, * @return True if the library should be skipped */ bool LibraryManagerImpl::skip(const std::string &filename) { - static std::set<std::string> excludes; + static std::unordered_set<std::string> excludes; static bool initialized(false); if (!initialized) { std::string excludeStr = diff --git a/Framework/Kernel/src/PropertyManager.cpp b/Framework/Kernel/src/PropertyManager.cpp index 303b452b393ea7084250e8eafa57b3795bf34ffd..f5aabcf7e43b0b5f9804b4fcbf514f494f860241 100644 --- a/Framework/Kernel/src/PropertyManager.cpp +++ b/Framework/Kernel/src/PropertyManager.cpp @@ -217,7 +217,7 @@ void PropertyManager::declareProperty(Property *p, const std::string &doc) { */ void PropertyManager::setProperties( const std::string &propertiesJson, - const std::set<std::string> &ignoreProperties) { + const std::unordered_set<std::string> &ignoreProperties) { setProperties(propertiesJson, this, ignoreProperties); } //----------------------------------------------------------------------------------------------- @@ -235,7 +235,7 @@ void PropertyManager::setProperties( */ void PropertyManager::setProperties( const std::string &propertiesJson, IPropertyManager *targetPropertyManager, - const std::set<std::string> &ignoreProperties) { + const std::unordered_set<std::string> &ignoreProperties) { ::Json::Reader reader; ::Json::Value jsonValue; @@ -254,7 +254,7 @@ void PropertyManager::setProperties( */ void PropertyManager::setProperties( const ::Json::Value &jsonValue, - const std::set<std::string> &ignoreProperties) { + const std::unordered_set<std::string> &ignoreProperties) { setProperties(jsonValue, this, ignoreProperties); } @@ -269,7 +269,7 @@ void PropertyManager::setProperties( */ void PropertyManager::setProperties( const ::Json::Value &jsonValue, IPropertyManager *targetPropertyManager, - const std::set<std::string> &ignoreProperties) { + const std::unordered_set<std::string> &ignoreProperties) { if (jsonValue.type() == ::Json::ValueType::objectValue) { // Some algorithms require Filename to be set first do that here @@ -302,7 +302,7 @@ void PropertyManager::setProperties( */ void PropertyManager::setPropertiesWithSimpleString( const std::string &propertiesString, - const std::set<std::string> &ignoreProperties) { + const std::unordered_set<std::string> &ignoreProperties) { ::Json::Value propertyJson; // Split up comma-separated properties typedef boost::tokenizer<boost::char_separator<char>> tokenizer; diff --git a/Framework/Kernel/src/PropertyManagerOwner.cpp b/Framework/Kernel/src/PropertyManagerOwner.cpp index 08ad8bd11c33515b1a3be70c3554ef1a019cda52..318325b6a72bbf5e65730b533481c4cde3717620 100644 --- a/Framework/Kernel/src/PropertyManagerOwner.cpp +++ b/Framework/Kernel/src/PropertyManagerOwner.cpp @@ -53,7 +53,7 @@ void PropertyManagerOwner::declareProperty(Property *p, */ void PropertyManagerOwner::setProperties( const std::string &propertiesJson, - const std::set<std::string> &ignoreProperties) { + const std::unordered_set<std::string> &ignoreProperties) { m_properties->setProperties(propertiesJson, this, ignoreProperties); } @@ -64,7 +64,7 @@ void PropertyManagerOwner::setProperties( */ void PropertyManagerOwner::setProperties( const ::Json::Value &jsonValue, - const std::set<std::string> &ignoreProperties) { + const std::unordered_set<std::string> &ignoreProperties) { m_properties->setProperties(jsonValue, this, ignoreProperties); } @@ -76,7 +76,7 @@ void PropertyManagerOwner::setProperties( */ void PropertyManagerOwner::setPropertiesWithSimpleString( const std::string &propertiesString, - const std::set<std::string> &ignoreProperties) { + const std::unordered_set<std::string> &ignoreProperties) { m_properties->setPropertiesWithSimpleString(propertiesString, ignoreProperties); } diff --git a/Framework/Kernel/test/InstrumentInfoTest.h b/Framework/Kernel/test/InstrumentInfoTest.h index 5f7ba970bef478af4e9731849d5feb4ec2fb0f18..d859873ddbae3baf3862ac085a123d9c7b367467 100644 --- a/Framework/Kernel/test/InstrumentInfoTest.h +++ b/Framework/Kernel/test/InstrumentInfoTest.h @@ -124,10 +124,12 @@ public: TS_ASSERT_EQUALS(inst.liveListener(), "AListener"); TS_ASSERT_EQUALS(inst.liveDataAddress(), "myinst.facility.gov:99"); auto techniques = inst.techniques(); - auto tech_it = techniques.begin(); + auto tech_it_end = techniques.end(); TS_ASSERT_EQUALS(techniques.size(), 2); - TS_ASSERT_EQUALS(*tech_it, "Doing Stuff"); - TS_ASSERT_EQUALS(*++tech_it, "Measuring Stuff"); + TSM_ASSERT_DIFFERS("Techniques should contain 'Doing Stuff'", + techniques.find("Doing Stuff"), tech_it_end) + TSM_ASSERT_DIFFERS("Techniques should contain 'Measuring Stuff'", + techniques.find("Measuring Stuff"), tech_it_end) TS_ASSERT_EQUALS(&inst.facility(), fac); std::stringstream ss; diff --git a/Framework/LiveData/src/LiveDataAlgorithm.cpp b/Framework/LiveData/src/LiveDataAlgorithm.cpp index b6b391094fb6080e4211299fae2a6a924451438f..dccf0728f75c16f0c9185b97949c85e14ed4c381 100644 --- a/Framework/LiveData/src/LiveDataAlgorithm.cpp +++ b/Framework/LiveData/src/LiveDataAlgorithm.cpp @@ -9,6 +9,7 @@ #include "boost/tokenizer.hpp" #include <boost/algorithm/string/trim.hpp> +#include <unordered_set> using namespace Mantid::Kernel; using namespace Mantid::API; @@ -241,7 +242,7 @@ IAlgorithm_sptr LiveDataAlgorithm::makeAlgorithm(bool postProcessing) { IAlgorithm_sptr alg = this->createChildAlgorithm(algoName); // Skip some of the properties when setting - std::set<std::string> ignoreProps; + std::unordered_set<std::string> ignoreProps; ignoreProps.insert("InputWorkspace"); ignoreProps.insert("OutputWorkspace"); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/AccumulateMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/AccumulateMD.h index b2d5f228a73d5ef1e1cb88e26788ff5289efd3fb..787c47475950bcfa7390aff3adaa1eeee6083420 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/AccumulateMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/AccumulateMD.h @@ -51,7 +51,7 @@ getHistoricalDataSources(const API::WorkspaceHistory &ws_history, /// historical data sources void MANTID_MDALGORITHMS_DLL insertDataSources(const std::string &data_sources, - std::set<std::string> &historical_data_sources); + std::unordered_set<std::string> &historical_data_sources); /// Test if a file with the given full path name exists bool fileExists(const std::string &filename); diff --git a/Framework/MDAlgorithms/src/AccumulateMD.cpp b/Framework/MDAlgorithms/src/AccumulateMD.cpp index eae50b905b07d3af70da7d7c96bf4681fce40a92..ad54b693b290996e9cb9e157863ddaf99bcf165c 100644 --- a/Framework/MDAlgorithms/src/AccumulateMD.cpp +++ b/Framework/MDAlgorithms/src/AccumulateMD.cpp @@ -142,7 +142,7 @@ getHistoricalDataSources(const WorkspaceHistory &ws_history, const std::string &create_alg_name, const std::string &accumulate_alg_name) { // Using a set so we only insert unique names - std::set<std::string> historical_data_sources; + std::unordered_set<std::string> historical_data_sources; // Get previously added data sources from DataSources property of the original // call of CreateMD and any subsequent calls of AccumulateMD @@ -175,8 +175,9 @@ getHistoricalDataSources(const WorkspaceHistory &ws_history, * sources * @param historical_data_sources :: set of data sources */ -void insertDataSources(const std::string &data_sources, - std::set<std::string> &historical_data_sources) { +void insertDataSources( + const std::string &data_sources, + std::unordered_set<std::string> &historical_data_sources) { // Split the property string into a vector of data sources std::vector<std::string> data_split; boost::split(data_split, data_sources, boost::is_any_of(",")); diff --git a/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp b/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp index 648336646630b9aa86837bf49ccf97671155208b..bc5896fc2d36ed391656df69b587d406e21b278b 100644 --- a/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp +++ b/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp @@ -190,7 +190,7 @@ void ConvertToDiffractionMDWorkspace::convertEventList(int workspaceIndex, DataObjects::MDBoxBase<DataObjects::MDLeanEvent<3>, 3> *box = ws->getBox(); // Get the position of the detector there. - const std::set<detid_t> &detectors = el.getDetectorIDs(); + const auto &detectors = el.getDetectorIDs(); if (!detectors.empty()) { // Get the detector (might be a detectorGroup for multiple detectors) // or might return an exception if the detector is not in the instrument diff --git a/Framework/MDAlgorithms/test/AccumulateMDTest.h b/Framework/MDAlgorithms/test/AccumulateMDTest.h index 4f412cd7b9ce6b0a7d619ac1e614d1bde1298dcc..a92680b2e974dd347d62ca91d7430a4080393480 100644 --- a/Framework/MDAlgorithms/test/AccumulateMDTest.h +++ b/Framework/MDAlgorithms/test/AccumulateMDTest.h @@ -191,12 +191,11 @@ public: void test_insert_data_sources() { std::string data_sources = "test1,test2,test3"; - std::set<std::string> data_sources_set; + std::unordered_set<std::string> data_sources_set; Mantid::MDAlgorithms::insertDataSources(data_sources, data_sources_set); // Check set contains "test1", "test2" and "test3" - std::set<std::string>::iterator iter; - iter = data_sources_set.find("test1"); + auto iter = data_sources_set.find("test1"); TS_ASSERT(iter != data_sources_set.end()); iter = data_sources_set.find("test2"); @@ -208,12 +207,11 @@ public: void test_insert_data_sources_with_whitespace() { std::string data_sources = " test1,test2 , test3"; - std::set<std::string> data_sources_set; + std::unordered_set<std::string> data_sources_set; Mantid::MDAlgorithms::insertDataSources(data_sources, data_sources_set); // Check set contains "test1", "test2" and "test3" - std::set<std::string>::iterator iter; - iter = data_sources_set.find("test1"); + auto iter = data_sources_set.find("test1"); TS_ASSERT(iter != data_sources_set.end()); iter = data_sources_set.find("test2"); diff --git a/Framework/MatlabAPI/src/MatlabInterface.cpp b/Framework/MatlabAPI/src/MatlabInterface.cpp index 9982d17ae5e251831ca9c1362330dea29a171189..928e9f54b4e9a739ef7c63c081e6d0a2794da971 100644 --- a/Framework/MatlabAPI/src/MatlabInterface.cpp +++ b/Framework/MatlabAPI/src/MatlabInterface.cpp @@ -670,11 +670,11 @@ void CreateSimpleAPIHelper(const std::string &algName, mfile << "No"; mfile << ", Direction: " << Mantid::Kernel::Direction::asText(prop->direction()); // << ", "; - std::set<std::string> allowed = prop->allowedValues(); + auto allowed = prop->allowedValues(); if (!allowed.empty()) { mfile << ", Allowed values: "; - std::set<std::string>::const_iterator sIter = allowed.begin(); - std::set<std::string>::const_iterator sEnd = allowed.end(); + auto sIter = allowed.begin(); + auto sEnd = allowed.end(); for (; sIter != sEnd;) { mfile << (*sIter); if (++sIter != sEnd) @@ -778,13 +778,10 @@ int CreateSimpleAPI(int, mxArray **, int nrhs, const mxArray *prhs[]) { * @returns An integer indicating success/failure */ int ListWorkspaces(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { - std::set<std::string> wkspNames = - AnalysisDataService::Instance().getObjectNames(); - std::set<std::string>::const_iterator sEnd = wkspNames.end(); + auto wkspNames = AnalysisDataService::Instance().getObjectNames(); // print the list of names using mexPrintf - for (std::set<std::string>::const_iterator sIter = wkspNames.begin(); - sIter != sEnd; ++sIter) { - mexPrintf((*sIter).c_str()); + for (auto const &wksp_name : wkspNames) { + mexPrintf(wksp_name.c_str()); mexPrintf("\n"); } return 0; diff --git a/Framework/Nexus/src/NexusFileIO.cpp b/Framework/Nexus/src/NexusFileIO.cpp index ab98903e37e9471ec3840a5e91fa0e1ea8c17a5b..94984b503dfdcefad66994b87fab3b002e663e25 100644 --- a/Framework/Nexus/src/NexusFileIO.cpp +++ b/Framework/Nexus/src/NexusFileIO.cpp @@ -919,7 +919,7 @@ int NexusFileIO::writeEventList(const DataObjects::EventList &el, NXopengroup(fileID, group_name.c_str(), "NXdata"); // Copy the detector IDs to an array. - const std::set<detid_t> &dets = el.getDetectorIDs(); + const auto &dets = el.getDetectorIDs(); // Write out the detector IDs if (!dets.empty()) { diff --git a/Framework/PythonInterface/inc/MantidPythonInterface/kernel/DataServiceExporter.h b/Framework/PythonInterface/inc/MantidPythonInterface/kernel/DataServiceExporter.h index 90679c67007c4a433a9654ac8c4b214633f45354..7c0e12b27d43e7edced73ced754fa6f80705d654 100644 --- a/Framework/PythonInterface/inc/MantidPythonInterface/kernel/DataServiceExporter.h +++ b/Framework/PythonInterface/inc/MantidPythonInterface/kernel/DataServiceExporter.h @@ -176,10 +176,8 @@ template <typename SvcType, typename SvcPtrType> struct DataServiceExporter { */ static boost::python::object getObjectNamesAsList(SvcType &self) { boost::python::list names; - const std::set<std::string> keys = self.getObjectNames(); - std::set<std::string>::const_iterator iend = keys.end(); - for (std::set<std::string>::const_iterator itr = keys.begin(); itr != iend; - ++itr) { + const auto keys = self.getObjectNames(); + for (auto itr = keys.begin(); itr != keys.end(); ++itr) { names.append(*itr); } assert(names.attr("__len__")() == keys.size()); diff --git a/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h b/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h index 5edfb1350b1d5b65645a66db80189565512bbb8f..6eb73727b2f13a811a226155fa207018f0929b05 100644 --- a/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h +++ b/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h @@ -91,7 +91,7 @@ private: Mantid::Geometry::MDHistoDimension_sptr makeDimension(NeXus::File *fin, int index, int length); - std::set<std::string> populateSpecialMap(); + std::unordered_set<std::string> populateSpecialMap(); void addMetaData(NeXus::File *fin, Mantid::API::Workspace_sptr ws, Mantid::API::ExperimentInfo_sptr info); diff --git a/Framework/SINQ/src/LoadFlexiNexus.cpp b/Framework/SINQ/src/LoadFlexiNexus.cpp index 3ebf97dfeaa3ea3ff568f61e88120c632a5724b4..e7d8e13e95d0e449b1246d24dcd6332ee5fdaf91 100644 --- a/Framework/SINQ/src/LoadFlexiNexus.cpp +++ b/Framework/SINQ/src/LoadFlexiNexus.cpp @@ -339,7 +339,7 @@ void LoadFlexiNexus::addMetaData(NeXus::File *fin, Workspace_sptr ws, * load all the extras into the Run information */ Run &r = info->mutableRun(); - std::set<std::string> specialMap = populateSpecialMap(); + auto specialMap = populateSpecialMap(); for (it = dictionary.begin(); it != dictionary.end(); ++it) { if (specialMap.find(it->first) == specialMap.end()) { // not in specials! @@ -366,8 +366,8 @@ void LoadFlexiNexus::addMetaData(NeXus::File *fin, Workspace_sptr ws, } } } -std::set<std::string> LoadFlexiNexus::populateSpecialMap() { - std::set<std::string> specialMap; +std::unordered_set<std::string> LoadFlexiNexus::populateSpecialMap() { + std::unordered_set<std::string> specialMap; specialMap.insert("title"); specialMap.insert("data"); diff --git a/Framework/SINQ/test/PoldiFitPeaks1D2Test.h b/Framework/SINQ/test/PoldiFitPeaks1D2Test.h index 35fbec1cc249f38f5f47758afc1a36845b5b3002..6d57b9ca2099e0d544105d58430377909bc4f2f2 100644 --- a/Framework/SINQ/test/PoldiFitPeaks1D2Test.h +++ b/Framework/SINQ/test/PoldiFitPeaks1D2Test.h @@ -98,7 +98,7 @@ public: TS_ASSERT_EQUALS(fitPeaks1D.propertyCount(), 8); std::vector<Property *> properties = fitPeaks1D.getProperties(); - std::set<std::string> names; + std::unordered_set<std::string> names; for (size_t i = 0; i < properties.size(); ++i) { names.insert(properties[i]->name()); diff --git a/Framework/SINQ/test/PoldiFitPeaks1DTest.h b/Framework/SINQ/test/PoldiFitPeaks1DTest.h index 452d6472c3987e074ea2ba878042f6b2cca616c4..5fef57ec078c66f53a436b0b1deb7d2812a552b7 100644 --- a/Framework/SINQ/test/PoldiFitPeaks1DTest.h +++ b/Framework/SINQ/test/PoldiFitPeaks1DTest.h @@ -100,7 +100,7 @@ public: TS_ASSERT_EQUALS(fitPeaks1D.propertyCount(), 6); std::vector<Property *> properties = fitPeaks1D.getProperties(); - std::set<std::string> names; + std::unordered_set<std::string> names; for (size_t i = 0; i < properties.size(); ++i) { names.insert(properties[i]->name()); diff --git a/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp b/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp index feefdddd7f417fb7830600255113275fa85b27bd..5997a26ab258b7a8f9c831439f7db38471cdc23d 100644 --- a/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp +++ b/Framework/ScriptRepository/src/ScriptRepositoryImpl.cpp @@ -8,6 +8,8 @@ #include "MantidKernel/NetworkProxy.h" #include "MantidKernel/ProxyInfo.h" #include <utility> +#include <unordered_set> + using Mantid::Kernel::DateAndTime; using Mantid::Kernel::Logger; using Mantid::Kernel::ConfigService; @@ -1482,7 +1484,7 @@ void ScriptRepositoryImpl::parseDownloadedEntries(Repository &repo) { std::string filename = std::string(local_repository).append(".local.json"); std::vector<std::string> entries_to_delete; Repository::iterator entry_it; - std::set<std::string> folders_of_deleted; + std::unordered_set<std::string> folders_of_deleted; try { Json::Value pt = readJsonFile(filename, "Error reading .local.json file"); @@ -1530,7 +1532,7 @@ void ScriptRepositoryImpl::parseDownloadedEntries(Repository &repo) { if (entries_to_delete.size() > 0) { // clear the auto_update flag from the folders if the user deleted files - BOOST_FOREACH (const std::string &folder, folders_of_deleted) { + for (const auto &folder : folders_of_deleted) { if (!pt.isMember(folder)) continue; diff --git a/MantidPlot/src/Mantid/MantidUI.cpp b/MantidPlot/src/Mantid/MantidUI.cpp index 2c910595fb1b0c7fddcc374124efabb0498b688d..ad0c59bf71bfa095769a03083652e6171ef0e2c5 100644 --- a/MantidPlot/src/Mantid/MantidUI.cpp +++ b/MantidPlot/src/Mantid/MantidUI.cpp @@ -342,9 +342,9 @@ void MantidUI::saveSettings() const QStringList MantidUI::getWorkspaceNames() { QStringList sl; - std::set<std::string> sv = Mantid::API::AnalysisDataService::Instance().getObjectNames(); - for (std::set<std::string>::const_iterator it = sv.begin(); it != sv.end(); ++it) - sl<<QString::fromStdString(*it); + auto sv = Mantid::API::AnalysisDataService::Instance().getObjectNames(); + for (const auto &name : sv) + sl<<QString::fromStdString(name); return sl; } diff --git a/MantidPlot/src/Mantid/MantidUI.h b/MantidPlot/src/Mantid/MantidUI.h index 408780738324e77f43d57e965f303c816cd89aae..5f07217253b52070460107bcaa1f8709ea5f0886 100644 --- a/MantidPlot/src/Mantid/MantidUI.h +++ b/MantidPlot/src/Mantid/MantidUI.h @@ -28,6 +28,7 @@ #include <QProgressDialog> #include <QMap> #include <QMutex> +#include <unordered_map> //---------------------------------- // Forward declarations @@ -570,7 +571,7 @@ private: QMap<std::string,int> m_DAE_map; // Stores dependent mdi windows. If the 'key' window closes, all 'value' ones must be closed as well. - std::multimap<MdiSubWindow*,MdiSubWindow*> m_mdiDependency; + std::unordered_multimap<MdiSubWindow*,MdiSubWindow*> m_mdiDependency; QMdiSubWindow *m_vatesSubWindow; ///< Holder for the Vates interface sub-window //prevents some repeated code realtating to log names diff --git a/MantidPlot/src/PythonScript.cpp b/MantidPlot/src/PythonScript.cpp index 7453f5b3397cbc91256c9edd09e512ee7f3783af..ef4158b60c25c2bc902aeb91320e254549c6e4c5 100644 --- a/MantidPlot/src/PythonScript.cpp +++ b/MantidPlot/src/PythonScript.cpp @@ -698,7 +698,7 @@ bool PythonScript::executeString() if(!result) { emit_error(); - // If a script was aborted we both raise a KeyboardInterrupt and + // If a script was aborted we both raise a KeyboardInterrupt and // call Algorithm::cancel to make sure we capture it. The doubling // can leave an interrupt in the pipeline so we clear it was we've // got the error info out @@ -926,8 +926,7 @@ void PythonScript::postDeleteHandle(const std::string& wsName) */ void PythonScript::clearADSHandle() { - std::set<std::string>::const_iterator iend = m_workspaceHandles.end(); - for( std::set<std::string>::const_iterator itr = m_workspaceHandles.begin(); itr != iend; ) + for( auto itr = m_workspaceHandles.cbegin(); itr != m_workspaceHandles.cend(); ) { // This also erases the element from current set. The standard says that erase only invalidates // iterators of erased elements so we need to increment the iterator and get back the previous value diff --git a/MantidQt/API/inc/MantidQtAPI/InterfaceFactory.h b/MantidQt/API/inc/MantidQtAPI/InterfaceFactory.h index 96265d85f96a8383c9e79665d92c42f08202d48a..dae2a6d3b5cf65e65b439c8ee35440641a437de6 100644 --- a/MantidQt/API/inc/MantidQtAPI/InterfaceFactory.h +++ b/MantidQt/API/inc/MantidQtAPI/InterfaceFactory.h @@ -172,11 +172,9 @@ template<typename TYPE> void UserSubWindowFactoryImpl::saveAliasNames(const std::string & realName) { std::set<std::string> aliases = TYPE::aliases(); - std::set<std::string>::const_iterator iend = aliases.end(); - for( std::set<std::string>::const_iterator itr = aliases.begin(); itr != iend; - ++itr ) + for(const auto &alias_std_str : aliases) { - QString alias = QString::fromStdString(*itr); + QString alias = QString::fromStdString(alias_std_str); if( m_aliasLookup.contains(alias) ) { if( m_badAliases.contains(alias) ) diff --git a/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisResultTableTab.cpp b/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisResultTableTab.cpp index 07138d8b6585bfbfca189ddeb86a85ddebeda70d..dc5c80466ec404d3c0bff96c0a953f9bfb077c96 100644 --- a/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisResultTableTab.cpp +++ b/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisResultTableTab.cpp @@ -307,7 +307,7 @@ QStringList MuonAnalysisResultTableTab::getIndividualFitWorkspaces() { QStringList workspaces; - std::set<std::string> allWorkspaces = AnalysisDataService::Instance().getObjectNames(); + auto allWorkspaces = AnalysisDataService::Instance().getObjectNames(); for(auto it = allWorkspaces.begin(); it != allWorkspaces.end(); it++) { diff --git a/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainViewPresenter.cpp b/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainViewPresenter.cpp index 6dd6052ecec74de4f95b2329e86ca2235262c391..78b14169ffb7593d6acd13fdbcb74180dc99eb13 100644 --- a/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainViewPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/Reflectometry/ReflMainViewPresenter.cpp @@ -177,10 +177,8 @@ ReflMainViewPresenter::ReflMainViewPresenter( Mantid::API::AnalysisDataServiceImpl &ads = Mantid::API::AnalysisDataService::Instance(); - std::set<std::string> items; - items = ads.getObjectNames(); - for (auto it = items.begin(); it != items.end(); ++it) { - const std::string name = *it; + auto items = ads.getObjectNames(); + for (auto const &name : items) { Workspace_sptr ws = ads.retrieve(name); if (isValidModel(ws)) diff --git a/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp b/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp index b1f757295539c2892ab5ed9d6a7176f02f61d1fc..bc6d68f1ff407bedbbfdd6d935efb42707653c8c 100644 --- a/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp +++ b/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp @@ -1463,11 +1463,11 @@ bool SANSRunWindow::workspaceExists(const QString &ws_name) const { * @returns A list of the currently available workspaces */ QStringList SANSRunWindow::currentWorkspaceList() const { - std::set<std::string> ws_list = + auto ws_list = AnalysisDataService::Instance().getObjectNames(); - std::set<std::string>::const_iterator iend = ws_list.end(); + auto iend = ws_list.end(); QStringList current_list; - for (std::set<std::string>::const_iterator itr = ws_list.begin(); itr != iend; + for (auto itr = ws_list.begin(); itr != iend; ++itr) { current_list.append(QString::fromStdString(*itr)); } @@ -3664,9 +3664,9 @@ void SANSRunWindow::resetGeometryDetailsBox() { void SANSRunWindow::cleanup() { Mantid::API::AnalysisDataServiceImpl &ads = Mantid::API::AnalysisDataService::Instance(); - std::set<std::string> workspaces = ads.getObjectNames(); - std::set<std::string>::const_iterator iend = workspaces.end(); - for (std::set<std::string>::const_iterator itr = workspaces.begin(); + auto workspaces = ads.getObjectNames(); + auto iend = workspaces.end(); + for (auto itr = workspaces.begin(); itr != iend; ++itr) { QString name = QString::fromStdString(*itr); if (name.endsWith("_raw") || name.endsWith("_nxs")) { diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/CatalogSearch.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/CatalogSearch.h index e1cc2314bb847e29b2f61d1c52a29ea6b58652f7..b518db5b06ee0e9ac88c71061c40020a9bbcda98 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/CatalogSearch.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/CatalogSearch.h @@ -111,9 +111,9 @@ namespace MantidQt /// Updates the dataFile text boxes with relevant info about the selected dataFile. void updateDataFileLabels(QTableWidgetItem* item); /// Obtain all file extensions from the provided column (dataFileResults -> File name). - std::set<std::string> getDataFileExtensions(Mantid::API::Column_sptr column); + std::unordered_set<std::string> getDataFileExtensions(Mantid::API::Column_sptr column); /// Add the list of file extensions to the "Filter type..." drop-down. - void populateDataFileType(const std::set<std::string> &extensions); + void populateDataFileType(const std::unordered_set<std::string> &extensions); /// Disable the download button if user can access the files locally from the archives. void disableDownloadButtonIfArchives(int row); diff --git a/MantidQt/MantidWidgets/src/CatalogSearch.cpp b/MantidQt/MantidWidgets/src/CatalogSearch.cpp index e167dd5e63439a387315eeffe40e0a9ebc5ab271..1930ad929a2c871f2272451d5256337d4d45b90a 100644 --- a/MantidQt/MantidWidgets/src/CatalogSearch.cpp +++ b/MantidQt/MantidWidgets/src/CatalogSearch.cpp @@ -968,7 +968,7 @@ namespace MantidQt // Obtain the list of extensions of all dataFiles for the chosen investigation. // "File name" is the first column of "dataFileResults" so we make use of it. - std::set<std::string> extensions = getDataFileExtensions(workspace.get()->getColumn(headerIndexByName(dataFileTable, "Name"))); + auto extensions = getDataFileExtensions(workspace.get()->getColumn(headerIndexByName(dataFileTable, "Name"))); // Populate the "Filter type..." combo-box with all possible file extensions. populateDataFileType(extensions); @@ -1057,9 +1057,9 @@ namespace MantidQt * @param column :: The fileName column in the dataFile workspace. * @return A set containing all file extensions. */ - std::set<std::string> CatalogSearch::getDataFileExtensions(Mantid::API::Column_sptr column) + std::unordered_set<std::string> CatalogSearch::getDataFileExtensions(Mantid::API::Column_sptr column) { - std::set<std::string> extensions; + std::unordered_set<std::string> extensions; // For every filename in the column... for (unsigned row = 0; row < column->size(); row++) @@ -1075,11 +1075,11 @@ namespace MantidQt /** * Add the list of file extensions to the "Filter type..." drop-down. */ - void CatalogSearch::populateDataFileType(const std::set<std::string> &extensions) + void CatalogSearch::populateDataFileType(const std::unordered_set<std::string> &extensions) { - for( std::set<std::string>::const_iterator iter = extensions.begin(); iter != extensions.end(); ++iter) + for(const auto &extension : extensions) { - m_icatUiForm.dataFileFilterCombo->addItem(QString::fromStdString("." + *iter)); + m_icatUiForm.dataFileFilterCombo->addItem(QString::fromStdString("." + extension)); } } diff --git a/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp b/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp index 15bed28f07e341420080682b1ce558c60a49593a..7f3b60b8aa8cbdfe3341c042d2a37d45a9338bd0 100644 --- a/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp +++ b/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp @@ -1688,8 +1688,8 @@ void FitPropertyBrowser::populateWorkspaceNames() //QStringList tmp = m_appWindow->mantidUI->getWorkspaceNames(); QStringList tmp; - std::set<std::string> sv = Mantid::API::AnalysisDataService::Instance().getObjectNames(); - for (std::set<std::string>::const_iterator it = sv.begin(); it != sv.end(); ++it) + auto sv = Mantid::API::AnalysisDataService::Instance().getObjectNames(); + for (auto it = sv.begin(); it != sv.end(); ++it) { tmp<<QString::fromStdString(*it); } diff --git a/MantidQt/MantidWidgets/src/InstrumentSelector.cpp b/MantidQt/MantidWidgets/src/InstrumentSelector.cpp index 166517650604f66b075470347321144ab20ea21c..c0433af448ba45da6505edf703091ec55e4da7f0 100644 --- a/MantidQt/MantidWidgets/src/InstrumentSelector.cpp +++ b/MantidQt/MantidWidgets/src/InstrumentSelector.cpp @@ -14,6 +14,7 @@ #include <Poco/NotificationCenter.h> #include <Poco/AutoPtr.h> #include <Poco/NObserver.h> +#include <set> namespace { @@ -180,18 +181,16 @@ namespace MantidWidgets m_currentFacility = &(mantidSettings.getFacility(mantidSettings.getFacilityNames()[0])); } - const std::vector<InstrumentInfo> & instruments = m_currentFacility->instruments(); - std::vector<InstrumentInfo>::const_iterator iend = instruments.end(); + const auto &instruments = m_currentFacility->instruments(); std::set<std::string> alphabetizedNames; - for( std::vector<InstrumentInfo>::const_iterator itr = instruments.begin(); itr != iend; ++itr ) + for( auto itr = instruments.cbegin(); itr != instruments.cend(); ++itr ) { alphabetizedNames.insert(itr->name()); } - std::set<std::string>::const_iterator namesEnd = alphabetizedNames.end(); - for( std::set<std::string>::const_iterator itr = alphabetizedNames.begin(); itr != namesEnd; ++itr ) + for(const auto &name_std_str : alphabetizedNames) { - QString name = QString::fromStdString(*itr); - std::string prefix = m_currentFacility->instrument(*itr).shortName(); + QString name = QString::fromStdString(name_std_str); + std::string prefix = m_currentFacility->instrument(name_std_str).shortName(); QString shortName = QString::fromStdString(prefix); this->addItem(name, QVariant(shortName)); } diff --git a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentActor.cpp b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentActor.cpp index 2928c281ab2158ed1388a11a9ba22989197f605a..4b0614b53c7eda9b1061d0d5bba70f4c00c1ad15 100644 --- a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentActor.cpp +++ b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentActor.cpp @@ -685,7 +685,7 @@ namespace MantidQt try { // Find if the detector is masked - const std::set<detid_t>& dets = sharedWorkspace->getSpectrum(wi)->getDetectorIDs(); + const auto &dets = sharedWorkspace->getSpectrum(wi)->getDetectorIDs(); bool masked = false; if (mask) diff --git a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetMaskTab.cpp b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetMaskTab.cpp index 8e590e6c3f434b94d7c8af95a99f1add7b23010e..105e340c78f473f8ecef24e7f17d37ee5a3f2931 100644 --- a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetMaskTab.cpp +++ b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetMaskTab.cpp @@ -985,7 +985,7 @@ namespace MantidQt std::string InstrumentWidgetMaskTab::generateMaskWorkspaceName(bool temp) const { if (temp) return "__MaskTab_MaskWorkspace"; - std::set<std::string> wsNames = Mantid::API::AnalysisDataService::Instance().getObjectNames(); + auto wsNames = Mantid::API::AnalysisDataService::Instance().getObjectNames(); int maxIndex = 0; const std::string baseName = "MaskWorkspace"; for (auto name = wsNames.begin(); name != wsNames.end(); ++name) diff --git a/MantidQt/MantidWidgets/src/SaveWorkspaces.cpp b/MantidQt/MantidWidgets/src/SaveWorkspaces.cpp index 1a611ae0e0187c035f81b9a1c3922a15c4ab4cf2..0abc6145c5c32b49500e2288858ede744013a625 100644 --- a/MantidQt/MantidWidgets/src/SaveWorkspaces.cpp +++ b/MantidQt/MantidWidgets/src/SaveWorkspaces.cpp @@ -87,8 +87,8 @@ void SaveWorkspaces::setupLine1(QHBoxLayout * const lineOne) void SaveWorkspaces::setupLine2(QHBoxLayout * const lineTwo, const QHash<const QCheckBox * const, QString> & defSavs) { m_workspaces = new QListWidget(); - std::set<std::string> ws = AnalysisDataService::Instance().getObjectNames(); - std::set<std::string>::const_iterator it = ws.begin(), wsEnd = ws.end(); + auto ws = AnalysisDataService::Instance().getObjectNames(); + auto it = ws.begin(), wsEnd = ws.end(); for( ; it != wsEnd; ++it) { Workspace *wksp = FrameworkManager::Instance().getWorkspace(*it); diff --git a/MantidQt/MantidWidgets/src/SlicingAlgorithmDialog.cpp b/MantidQt/MantidWidgets/src/SlicingAlgorithmDialog.cpp index 7a157fe63bee473e6c1d792bbd550a4cfa696e94..16f7d598731d73cc8e7652592ffb834763f4befa 100644 --- a/MantidQt/MantidWidgets/src/SlicingAlgorithmDialog.cpp +++ b/MantidQt/MantidWidgets/src/SlicingAlgorithmDialog.cpp @@ -64,9 +64,8 @@ namespace MantidQt //Configure workspace selector ui.workspace_selector->setValidatingAlgorithm(m_algName); ui.workspace_selector->clear(); - typedef std::set<std::string> WorkspaceNames; - WorkspaceNames names = AnalysisDataService::Instance().getObjectNames(); - WorkspaceNames::iterator it = names.begin(); + auto names = AnalysisDataService::Instance().getObjectNames(); + auto it = names.begin(); while(it != names.end()) { IMDEventWorkspace_sptr ws = boost::dynamic_pointer_cast<IMDEventWorkspace>(AnalysisDataService::Instance().retrieve(*it)); diff --git a/MantidQt/MantidWidgets/src/UserFunctionDialog.cpp b/MantidQt/MantidWidgets/src/UserFunctionDialog.cpp index 8696d3cefafdf322d24dd0082da7e8a75d9e8149..3f78d7986f2422cefa000606cec61a58e1bcc7a8 100644 --- a/MantidQt/MantidWidgets/src/UserFunctionDialog.cpp +++ b/MantidQt/MantidWidgets/src/UserFunctionDialog.cpp @@ -215,8 +215,8 @@ void UserFunctionDialog::checkParameters(QString& expr) { return; } - std::set<std::string> vars1 = e1.getVariables(); - std::set<std::string> vars2 = e2.getVariables(); + auto vars1 = e1.getVariables(); + auto vars2 = e2.getVariables(); vars1.erase("x"); vars2.erase("x"); @@ -277,10 +277,10 @@ void UserFunctionDialog::updateFunction() m_uiForm.leParams->setText(""); return; } - std::set<std::string> vars = e.getVariables(); + auto vars = e.getVariables(); vars.erase("x"); QString params; - for(std::set<std::string>::iterator it=vars.begin();it!=vars.end();++it) + for(auto it=vars.begin();it!=vars.end();++it) { if (it != vars.begin()) { diff --git a/MantidQt/MantidWidgets/src/WorkspaceSelector.cpp b/MantidQt/MantidWidgets/src/WorkspaceSelector.cpp index 93e2207b19170eb953952493ab483e017457e894..01e9e6bdc4f4277bb910383bef25f43581b52bfd 100644 --- a/MantidQt/MantidWidgets/src/WorkspaceSelector.cpp +++ b/MantidQt/MantidWidgets/src/WorkspaceSelector.cpp @@ -305,7 +305,7 @@ void WorkspaceSelector::refresh() clear(); if ( m_optional ) addItem(""); auto& ads = Mantid::API::AnalysisDataService::Instance(); - std::set<std::string> items; + std::unordered_set<std::string> items; if ( showHiddenWorkspaces() ) { items = ads.getObjectNamesInclHidden(); @@ -315,7 +315,7 @@ void WorkspaceSelector::refresh() items = ads.getObjectNames(); } - for ( std::set<std::string>::iterator it = items.begin(); it != items.end(); ++it ) + for ( auto it = items.begin(); it != items.end(); ++it ) { QString name = QString::fromStdString(*it); if ( checkEligibility( name, ads.retrieve(*it) ) ) diff --git a/MantidQt/SliceViewer/src/QPeaksTableModel.cpp b/MantidQt/SliceViewer/src/QPeaksTableModel.cpp index e33322a1a5d4fddf1e59840f01ad83d89b362c9c..33707353adb809e05b3a7b2d6cfba77d897c50a8 100644 --- a/MantidQt/SliceViewer/src/QPeaksTableModel.cpp +++ b/MantidQt/SliceViewer/src/QPeaksTableModel.cpp @@ -343,7 +343,7 @@ namespace MantidQt // hide some columns based on the techniques { // shrink variable scope - std::set<std::string> techniques = instrInfo.techniques(); + auto techniques = instrInfo.techniques(); // required for showing final and delta energy const std::string IGS("TOF Indirect Geometry Spectroscopy"); // required for showing initial and delta energy diff --git a/MantidQt/SpectrumViewer/src/MatrixWSDataSource.cpp b/MantidQt/SpectrumViewer/src/MatrixWSDataSource.cpp index 6b43d9fa93d095570b93135fe047b85066e37b08..894333a90197ca7c2506aa84335fde70107b2909 100644 --- a/MantidQt/SpectrumViewer/src/MatrixWSDataSource.cpp +++ b/MantidQt/SpectrumViewer/src/MatrixWSDataSource.cpp @@ -285,7 +285,7 @@ std::vector<std::string> MatrixWSDataSource::getInfoList(double x, double y) { SVUtils::PushNameValue( x_label, 8, 3, x, list ); } - std::set<detid_t> ids = spec->getDetectorIDs(); + auto ids = spec->getDetectorIDs(); if ( !ids.empty() ) { list.emplace_back("Det ID"); diff --git a/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h b/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h index 5fed9582d6a2f285ecd599db18a6a4813d098b69..7bea189e9af5b015438a78cf83204c7cc1a4f72c 100644 --- a/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h +++ b/Vates/VatesSimpleGui/ViewWidgets/inc/MantidVatesSimpleGuiViewWidgets/MdViewerWidget.h @@ -114,7 +114,7 @@ protected slots: void switchViews(ModeControlWidget::Views v); /// Triggered when panel is changed. void panelChanged(); - /// On rebin + /// On rebin void onRebin(std::string algorithmType); /// On unbin void onUnbin(); @@ -218,12 +218,12 @@ private: /// Reset the current view to the appropriate initial view. void resetCurrentView(int workspaceType, const std::string& instrumentName); /// Render rebinned workspace - pqPipelineSource* prepareRebinnedWorkspace(const std::string rebinnedWorkspaceName, std::string sourceType); + pqPipelineSource* prepareRebinnedWorkspace(const std::string rebinnedWorkspaceName, std::string sourceType); /// Handle drag and drop of peaks workspcaes void handleDragAndDropPeaksWorkspaces(QEvent* e, QString text, QStringList& wsNames); /// Set up the default color for the background of the view. void setColorForBackground(); - /// Set the color map + /// Set the color map void setColorMap(); /// Render the original workspace pqPipelineSource* renderOriginalWorkspace(const std::string originalWorkspaceName); diff --git a/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp b/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp index a91d1152065705e9a5ea81f316209b1e6cbd5fa2..d8bd3a126a437db6e26c5816f6fcab71cb5352cb 100644 --- a/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp +++ b/Vates/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp @@ -893,7 +893,7 @@ QString MdViewerWidget::getViewForInstrument(const std::string& instrumentName) QString associatedView; try { - const std::set<std::string> techniques = Mantid::Kernel::ConfigService::Instance().getInstrument(instrumentName).techniques(); + const auto techniques = Mantid::Kernel::ConfigService::Instance().getInstrument(instrumentName).techniques(); if (techniques.count("Single Crystal Diffraction") > 0 ) { @@ -924,13 +924,13 @@ QString MdViewerWidget::getViewForInstrument(const std::string& instrumentName) * @param keyword A keyword * @returns True if the keyword is contained in at least one technique else false. */ -bool MdViewerWidget::checkIfTechniqueContainsKeyword(const std::set<std::string>& techniques, const std::string& keyword) const +bool MdViewerWidget::checkIfTechniqueContainsKeyword(const std::set<std::string> &techniques, const std::string &keyword) const { boost::regex pattern( "(.*)" + keyword + "(.*)"); - for (std::set<std::string>::iterator it = techniques.begin(); it != techniques.end(); ++it) + for (auto const &technique : techniques) { - if (boost::regex_match(*it, pattern)) + if (boost::regex_match(technique, pattern)) { return true; } diff --git a/docs/source/algorithms/RenameWorkspace-v1.rst b/docs/source/algorithms/RenameWorkspace-v1.rst index 74200ee4331950c5e8bbda2da55c24ed4f0046a6..188bc5458874842129092ffc6ccab639c3be4a8d 100644 --- a/docs/source/algorithms/RenameWorkspace-v1.rst +++ b/docs/source/algorithms/RenameWorkspace-v1.rst @@ -36,6 +36,7 @@ Usage print "*********************************************************************" print "{0:20}|{1:>20}|{2:>20}|".format("Existing WS names: ",myWs.name(),mon_ws.name()) obj_inADS = AnalysisDataService.getObjectNames() + obj_inADS.sort() print "{0:20}|{1:>6}| With Names: |{2:>20}|{3:>20}|".format("Exist in ADS: ",len(obj_inADS),obj_inADS[0],obj_inADS[1]) # NameA = RenameWorkspace(myWs) @@ -43,6 +44,7 @@ Usage print "***** After simple rename:" print "{0:20}|{1:>20}|{2:>20}|".format("Existing WS names: ",NameA.name(),mon_ws.name()) obj_inADS = AnalysisDataService.getObjectNames() + obj_inADS.sort() print "{0:20}|{1:>6}| With Names: |{2:>20}|{3:>20}|".format("Exist in ADS: ",len(obj_inADS),obj_inADS[0],obj_inADS[1]) print "Old pointer to myWs refers to workspace with new name: ",myWs.name() @@ -53,6 +55,7 @@ Usage # print "{0:20}|{1:>20}|{2:>20}|".format("Existing WS names: ",NameB.name(),mon_ws.name()) obj_inADS = AnalysisDataService.getObjectNames() + obj_inADS.sort() print "{0:20}|{1:>6}| With Names: |{2:>20}|{3:>20}|".format("Exist in ADS: ",len(obj_inADS),obj_inADS[0],obj_inADS[1]) # mon_ws1 = NameB.getMonitorWorkspace() diff --git a/docs/source/algorithms/RenameWorkspaces-v1.rst b/docs/source/algorithms/RenameWorkspaces-v1.rst index 99c0c80d2f72b26ab78c00b19d452d9d22669d20..5ff7482af4c4a29a682462aea7ef7a1cacd2a422 100644 --- a/docs/source/algorithms/RenameWorkspaces-v1.rst +++ b/docs/source/algorithms/RenameWorkspaces-v1.rst @@ -43,11 +43,15 @@ Usage for name in names: CreateWorkspace([0], [0], OutputWorkspace=name) - print 'Workspaces in the ADS _before_ renaming:', mtd.getObjectNames() + ws_before_rename = mtd.getObjectNames() + ws_before_rename.sort() + print 'Workspaces in the ADS _before_ renaming:', ws_before_rename RenameWorkspaces(names, WorkspaceNames=['new_ws1', 'new_ws2', 'new_ws3']) - print 'Workspaces in the ADS _after_ renaming:', mtd.getObjectNames() + ws_after_rename = mtd.getObjectNames() + ws_after_rename.sort() + print 'Workspaces in the ADS _after_ renaming:', ws_after_rename Output: @@ -69,11 +73,15 @@ Output: for name in names: CreateWorkspace([0], [0], OutputWorkspace=name) - print 'Workspaces in the ADS _before_ renaming:', mtd.getObjectNames() + ws_before_rename = mtd.getObjectNames() + ws_before_rename.sort() + print 'Workspaces in the ADS _before_ renaming:', ws_before_rename RenameWorkspaces(names, Prefix='new_', Suffix='_name') - print 'Workspaces in the ADS _after_ renaming:', mtd.getObjectNames() + ws_after_rename = mtd.getObjectNames() + ws_after_rename.sort() + print 'Workspaces in the ADS _after_ renaming:', ws_after_rename Output: