mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:57:45 +00:00
AK: Add Vector::prepend().
This commit is contained in:
parent
73c70e5d2e
commit
d31b47b371
1 changed files with 11 additions and 0 deletions
11
AK/Vector.h
11
AK/Vector.h
|
@ -222,6 +222,17 @@ public:
|
|||
++m_impl->m_size;
|
||||
}
|
||||
|
||||
void prepend(const T& value)
|
||||
{
|
||||
ensure_capacity(size() + 1);
|
||||
for (int i = size(); i > 0; --i) {
|
||||
new (m_impl->slot(i)) T(move(at(i - 1)));
|
||||
at(i - 1).~T();
|
||||
}
|
||||
new (m_impl->slot(0)) T(value);
|
||||
++m_impl->m_size;
|
||||
}
|
||||
|
||||
void append(const T* values, int count)
|
||||
{
|
||||
if (!count)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue