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

This commit is contained in:
implicitfield authored and Tim Schumacher committed 2024-06-29 19:16:08 +02:00
1 parent 06d4672564
commit 176999e20c
1 file changed
+10
+10
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())