mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
AK: Add Vector::prepend(T&&)
This commit is contained in:
parent
a377e8d3f5
commit
6a8695e759
Notes:
sideshowbarker
2024-07-19 11:20:27 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/6a8695e7592
1 changed files with 6 additions and 7 deletions
13
AK/Vector.h
13
AK/Vector.h
|
@ -385,15 +385,14 @@ public:
|
|||
append(T(value));
|
||||
}
|
||||
|
||||
void prepend(T&& value)
|
||||
{
|
||||
insert(0, move(value));
|
||||
}
|
||||
|
||||
void prepend(const T& value)
|
||||
{
|
||||
grow_capacity(size() + 1);
|
||||
for (int i = size(); i > 0; --i) {
|
||||
new (slot(i)) T(move(at(i - 1)));
|
||||
at(i - 1).~T();
|
||||
}
|
||||
new (slot(0)) T(value);
|
||||
++m_size;
|
||||
insert(0, value);
|
||||
}
|
||||
|
||||
void prepend(Vector&& other)
|
||||
|
|
Loading…
Add table
Reference in a new issue