mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 01:41:59 -05:00
AK: Implement any_of using common implementation
Problem: - `any_of` is implemented in 2 different ways, one for the entire container and a different implementation for a partial container using iterators. Solution: - Follow the "don't repeat yourself" (DRY) idiom and implement the entire container version in terms of the partial version.
This commit is contained in:
parent
8e949c5c91
commit
2e6fc13b1e
1 changed files with 1 additions and 5 deletions
|
@ -24,11 +24,7 @@ constexpr bool any_of(
|
||||||
template<IterableContainer Container>
|
template<IterableContainer Container>
|
||||||
constexpr bool any_of(Container&& container, auto const& predicate)
|
constexpr bool any_of(Container&& container, auto const& predicate)
|
||||||
{
|
{
|
||||||
for (auto&& entry : container) {
|
return any_of(container.begin(), container.end(), predicate);
|
||||||
if (predicate(entry))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue