mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-21 10:05:32 +00:00
AK: Add Vector::prepend(T&&)
This commit is contained in:
parent
a377e8d3f5
commit
6a8695e759
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…
Reference in a new issue