mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 09:21:57 -05:00
AK/Span: Add a method to check if a Span is filled with a value
This commit is contained in:
parent
06d4672564
commit
176999e20c
1 changed files with 10 additions and 0 deletions
10
AK/Span.h
10
AK/Span.h
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue