mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-25 10:48:53 +00: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
Notes:
sideshowbarker
2024-07-18 07:23:01 +09:00
Author: https://github.com/ldm5180
Commit: 2e6fc13b1e
Pull-request: https://github.com/SerenityOS/serenity/pull/9006
Reviewed-by: https://github.com/AtkinsSJ ✅
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…
Add table
Add a link
Reference in a new issue