AK: Add Span::reverse()

It works like Vector::reverse().
This commit is contained in:
Nico Weber 2023-11-08 21:24:33 +01:00 committed by Andreas Kling
parent e9dda2a5f8
commit bda162fc0d

View file

@ -276,6 +276,12 @@ public:
return at(index);
}
void reverse()
{
for (size_t i = 0; i < size() / 2; ++i)
AK::swap(at(i), at(size() - i - 1));
}
[[nodiscard]] ALWAYS_INLINE constexpr T& operator[](size_t index)
{
return at(index);