Merge pull request #6873 from akva2/replace_erase_remove

replace erase-remove idiom with std::erase[_if]
This commit is contained in:
Bård Skaflestad authored and GitHub committed 2026-02-24 13:05:21 +01:00
commit 79eb2a0d8f
4 files changed
+13 -20

No files matched your search

+4 -4
View File
@@ -65,10 +65,10 @@ std::size_t colorGraphWelshPowell(const Graph& graph,
}
// forbidden vertices will be colored next for coloring
using Vertex = typename Graph::VertexDescriptor;
auto newEnd = std::remove_if(orderedVertices.begin(),
orderedVertices.end(),
[&forbidden](const Vertex& vertex) { return !forbidden[vertex]; });
orderedVertices.resize(newEnd - orderedVertices.begin());
std::erase_if(orderedVertices,
[&forbidden](const Vertex& vertex)
{ return !forbidden[vertex]; });
return noColored;
}
@@ -290,9 +290,7 @@ getLocalWells(const int timeStepIdx) const
auto w = std::vector<Well>{};
auto wnames = this->schedule().wellNames(timeStepIdx);
wnames.erase(std::remove_if(wnames.begin(), wnames.end(),
this->not_on_process_),
wnames.end());
std::erase_if(wnames, this->not_on_process_);
w.reserve(wnames.size());
@@ -1748,10 +1746,7 @@ getMaxWellConnections() const
auto wellConnections = std::vector<std::vector<int>>{};
auto schedule_wells = this->schedule().wellNames();
schedule_wells.erase(std::remove_if(schedule_wells.begin(),
schedule_wells.end(),
this->not_on_process_),
schedule_wells.end());
std::erase_if(schedule_wells, this->not_on_process_);
wellConnections.reserve(schedule_wells.size());
+5 -7
View File
@@ -508,14 +508,12 @@ recalculateGradientAndUpdateData_(GradPairItr& grad_itr,
updateGradVector_(name, other_grads, grad->grad);
}
else {
auto new_end = std::remove_if(other_grads.begin(), other_grads.end(), [&name](const GradPair& pair)
{
return (name==pair.first);
}
);
if (new_end != other_grads.end()) {
const auto orig_size = other_grads.size();
std::erase_if(other_grads,
[&name](const GradPair& pair)
{ return name == pair.first; });
if (orig_size != other_grads.size()) {
this->deleteGrad_(name, !increase);
other_grads.erase(new_end, other_grads.end());
}
}
}
+2 -2
View File
@@ -61,8 +61,8 @@ struct Fixture
std::string trimString(const std::string& input)
{
std::string result(input);
result.erase(std::remove(result.begin(), result.end(), ' '), result.end());
result.erase(std::remove(result.begin(), result.end(), '\n'), result.end());
std::erase(result, ' ');
std::erase(result, '\n');
return result;
}