mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Add Span::reverse()
It works like Vector::reverse().
This commit is contained in:
parent
e9dda2a5f8
commit
bda162fc0d
Notes:
sideshowbarker
2024-07-17 20:19:08 +09:00
Author: https://github.com/nico Commit: https://github.com/SerenityOS/serenity/commit/bda162fc0d Pull-request: https://github.com/SerenityOS/serenity/pull/21853 Reviewed-by: https://github.com/InusualZ
1 changed files with 6 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue