mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
AK: Add Vector::prepend(T&&)
This commit is contained in:
parent
a377e8d3f5
commit
6a8695e759
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));
|
append(T(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void prepend(T&& value)
|
||||||
|
{
|
||||||
|
insert(0, move(value));
|
||||||
|
}
|
||||||
|
|
||||||
void prepend(const T& value)
|
void prepend(const T& value)
|
||||||
{
|
{
|
||||||
grow_capacity(size() + 1);
|
insert(0, value);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepend(Vector&& other)
|
void prepend(Vector&& other)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue