Commit ed83c290 authored by Matthew D Jones's avatar Matthew D Jones
Browse files

Re #15287 Remove explicit use of std::set by using auto

parent e24e9368
......@@ -99,16 +99,13 @@ 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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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)
}
......
......@@ -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
......
......@@ -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()) {
......
......@@ -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)
......
......@@ -288,7 +288,7 @@ void MatrixWSDataSource::getInfoList( double x,
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");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment