AK/Span: Add a method to check if a Span is filled with a value

This commit is contained in:
implicitfield 2024-04-28 22:00:32 +04:00 committed by Tim Schumacher
parent 06d4672564
commit 176999e20c

View file

@ -220,6 +220,16 @@ public:
return false;
}
template<typename V>
[[nodiscard]] constexpr bool filled_with(V const& value) const
{
for (size_t i = 0; i < size(); ++i) {
if (!Traits<RemoveReference<T>>::equals(at(i), value))
return false;
}
return true;
}
[[nodiscard]] constexpr bool starts_with(ReadonlySpan<T> other) const
{
if (size() < other.size())