mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK/Vector: Add Vector::reverse()
method
This reverses the contents of the vector in-place.
This commit is contained in:
parent
a339b73fc2
commit
27f28998b1
Notes:
sideshowbarker
2024-07-18 03:46:29 +09:00
Author: https://github.com/mustafaquraish Commit: https://github.com/SerenityOS/serenity/commit/27f28998b10 Pull-request: https://github.com/SerenityOS/serenity/pull/10052 Reviewed-by: https://github.com/BenWiederhake ✅ Reviewed-by: https://github.com/bgianfo ✅
1 changed files with 6 additions and 0 deletions
|
@ -746,6 +746,12 @@ public:
|
|||
return {};
|
||||
}
|
||||
|
||||
void reverse()
|
||||
{
|
||||
for (size_t i = 0; i < size() / 2; ++i)
|
||||
AK::swap(at(i), at(size() - i - 1));
|
||||
}
|
||||
|
||||
private:
|
||||
void reset_capacity()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue