From c7fe1592821539f94e18d91ef376ef643fe6042e Mon Sep 17 00:00:00 2001
From: Matthew D Jones <matthew.d.jones@tessella.com>
Date: Thu, 18 Feb 2016 16:46:09 +0000
Subject: [PATCH] Re #15287 Use unordered_set

---
 Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h | 2 +-
 Framework/Algorithms/src/CreateGroupingWorkspace.cpp     | 2 +-
 Framework/Algorithms/src/FilterEvents.cpp                | 5 +----
 Framework/Algorithms/src/GeneratePeaks.cpp               | 6 ++----
 .../Algorithms/src/PDDetermineCharacterizations.cpp      | 2 +-
 Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp | 4 ++--
 Framework/Algorithms/src/SumSpectra.cpp                  | 9 +++------
 .../CurveFitting/src/Algorithms/SplineSmoothing.cpp      | 9 ++++-----
 Framework/CurveFitting/test/IPeakFunctionIntensityTest.h | 4 ++--
 Framework/DataHandling/test/LoadNexusLogsTest.h          | 2 +-
 Framework/Kernel/inc/MantidKernel/ConfigService.h        | 3 ++-
 Framework/Kernel/inc/MantidKernel/NexusDescriptor.h      | 3 ++-
 Framework/Kernel/src/CompositeValidator.cpp              | 4 ++--
 Framework/Kernel/src/LibraryManager.cpp                  | 2 +-
 14 files changed, 25 insertions(+), 32 deletions(-)

diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h b/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h
index 162021480db..abb94aad878 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/CreateGroupingWorkspace.cpp b/Framework/Algorithms/src/CreateGroupingWorkspace.cpp
index e731536b5ae..c6c6aea93ce 100644
--- a/Framework/Algorithms/src/CreateGroupingWorkspace.cpp
+++ b/Framework/Algorithms/src/CreateGroupingWorkspace.cpp
@@ -417,7 +417,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 0a918580912..768c3746019 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);
diff --git a/Framework/Algorithms/src/GeneratePeaks.cpp b/Framework/Algorithms/src/GeneratePeaks.cpp
index b5b4d043d5a..c58a2773ff0 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,9 @@ 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/PDDetermineCharacterizations.cpp b/Framework/Algorithms/src/PDDetermineCharacterizations.cpp
index 7347441ff8f..ec4d16655d5 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/SpecularReflectionAlgorithm.cpp b/Framework/Algorithms/src/SpecularReflectionAlgorithm.cpp
index 532424b9cdb..13fda3bbc94 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 713199aa9f0..d033e2da155 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/CurveFitting/src/Algorithms/SplineSmoothing.cpp b/Framework/CurveFitting/src/Algorithms/SplineSmoothing.cpp
index 9cc5d65aa7a..94137137b58 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/IPeakFunctionIntensityTest.h b/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h
index b90b0a561e5..66c3e167245 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/test/LoadNexusLogsTest.h b/Framework/DataHandling/test/LoadNexusLogsTest.h
index ab451ae3cc2..c6293fff79e 100644
--- a/Framework/DataHandling/test/LoadNexusLogsTest.h
+++ b/Framework/DataHandling/test/LoadNexusLogsTest.h
@@ -163,7 +163,7 @@ 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/Kernel/inc/MantidKernel/ConfigService.h b/Framework/Kernel/inc/MantidKernel/ConfigService.h
index 5f3a4d619ce..408c332001b 100644
--- a/Framework/Kernel/inc/MantidKernel/ConfigService.h
+++ b/Framework/Kernel/inc/MantidKernel/ConfigService.h
@@ -9,6 +9,7 @@
 #include "MantidKernel/ProxyInfo.h"
 #include <vector>
 #include <map>
+#include <unordered_set>
 #include <set>
 
 #include <Poco/Notification.h>
@@ -307,7 +308,7 @@ private:
   WrappedObject<Poco::Util::SystemConfiguration> *m_pSysConfig;
 
   /// A set of property keys that have been changed
-  mutable std::set<std::string> m_changed_keys;
+  mutable std::unordered_set<std::string> m_changed_keys;
 
   /// A map storing string/key pairs where the string denotes a path
   /// that could be relative in the user properties file
diff --git a/Framework/Kernel/inc/MantidKernel/NexusDescriptor.h b/Framework/Kernel/inc/MantidKernel/NexusDescriptor.h
index f46774eebf5..8d9e53fa70c 100644
--- a/Framework/Kernel/inc/MantidKernel/NexusDescriptor.h
+++ b/Framework/Kernel/inc/MantidKernel/NexusDescriptor.h
@@ -6,6 +6,7 @@
 
 #include <map>
 #include <set>
+#include <unordered_set>
 #include <string>
 #include <utility>
 
@@ -115,7 +116,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/src/CompositeValidator.cpp b/Framework/Kernel/src/CompositeValidator.cpp
index 06d35a022ec..b87ecc4f290 100644
--- a/Framework/Kernel/src/CompositeValidator.cpp
+++ b/Framework/Kernel/src/CompositeValidator.cpp
@@ -17,7 +17,7 @@ CompositeValidator::~CompositeValidator() { m_children.clear(); }
  * @return
  */
 std::vector<std::string> CompositeValidator::allowedValues() const {
-  std::set<std::string> elem_unique;
+  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);
@@ -37,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 94a77703446..2481ed6e304 100644
--- a/Framework/Kernel/src/LibraryManager.cpp
+++ b/Framework/Kernel/src/LibraryManager.cpp
@@ -80,7 +80,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 =
-- 
GitLab