2021-01-14 22:36:23 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-01-14 22:36:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-07-22 14:41:00 +00:00
|
|
|
#include <AK/Concepts.h>
|
2021-06-11 23:57:46 +00:00
|
|
|
#include <AK/Find.h>
|
2021-01-14 22:36:23 +00:00
|
|
|
#include <AK/Iterator.h>
|
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
|
|
|
template<typename Container, typename ValueType>
|
|
|
|
constexpr bool any_of(
|
|
|
|
const SimpleIterator<Container, ValueType>& begin,
|
|
|
|
const SimpleIterator<Container, ValueType>& end,
|
|
|
|
const auto& predicate)
|
|
|
|
{
|
2021-06-11 23:57:46 +00:00
|
|
|
return find_if(begin, end, predicate) != end;
|
2021-01-14 22:36:23 +00:00
|
|
|
}
|
|
|
|
|
2021-07-22 14:41:00 +00:00
|
|
|
template<IterableContainer Container>
|
|
|
|
constexpr bool any_of(Container&& container, auto const& predicate)
|
|
|
|
{
|
|
|
|
for (auto&& entry : container) {
|
|
|
|
if (predicate(entry))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-14 22:36:23 +00:00
|
|
|
}
|
2021-02-07 10:35:08 +00:00
|
|
|
|
|
|
|
using AK::any_of;
|