replace for loop with std::for_each

release/4.3a0
Varun Agrawal 2025-01-22 11:15:48 -05:00
parent 7ecf978683
commit 49aa510d59
1 changed files with 6 additions and 6 deletions

View File

@ -508,20 +508,20 @@ void DiscreteConditional::removeDiscreteModes(const DiscreteValues& given) {
// Get the leftover DiscreteKey frontals
DiscreteKeys frontals;
for (Key key : this->frontals()) {
std::for_each(this->frontals().begin(), this->frontals().end(), [&](Key key) {
// Check if frontal key exists in given, if not add to new frontals
if (given.count(key) == 0) {
frontals.emplace_back(key, cardinalities_.at(key));
frontals.emplace_back(key, this->cardinalities_.at(key));
}
}
});
// Get the leftover DiscreteKey parents
DiscreteKeys parents;
for (Key key : this->parents()) {
std::for_each(this->parents().begin(), this->parents().end(), [&](Key key) {
// Check if parent key exists in given, if not add to new parents
if (given.count(key) == 0) {
parents.emplace_back(key, cardinalities_.at(key));
parents.emplace_back(key, this->cardinalities_.at(key));
}
}
});
DiscreteKeys allDkeys(frontals);
allDkeys.insert(allDkeys.end(), parents.begin(), parents.end());