Commit 016f6eb3 authored by Matthew Bowles's avatar Matthew Bowles
Browse files

add handling of empty vector to removePeaks Re #19472

parent 8669bc7d
......@@ -154,18 +154,19 @@ void PeaksWorkspace::removePeak(const int peakNum) {
* @param badPeaks peaks to be removed
*/
void PeaksWorkspace::removePeaks(const std::vector<int> &badPeaks) {
if (badPeaks.size() == 0)
return;
int i = 0;
auto first = peaks.begin();
auto end = peaks.end();
auto result = first;
for (Peak p : peaks) {
for (; first < end; ++first, ++i) {
// if index of peak is not in badPeaks
if (std::find(badPeaks.begin(), badPeaks.end(), i) == badPeaks.end()) {
// include in result
*result = std::move(*first);
++result;
}
++first;
++i;
}
// erase peaks outside of result
peaks.erase(result, peaks.end());
......
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