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: https://github.com/SerenityOS/serenity/commit/2e6fc13b1e9 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>
|
||||
constexpr bool any_of(Container&& container, auto const& predicate)
|
||||
{
|
||||
for (auto&& entry : container) {
|
||||
if (predicate(entry))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return any_of(container.begin(), container.end(), predicate);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue