mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
AK/Span: Add a method to check if a Span is filled with a value
This commit is contained in:
1 parent
06d4672564
commit
176999e20c
1 file changed
+10
@@ -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())
|
||||
|
||||
Reference in new issue
Block a user