mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
AK: Add Vector::prepend().
This commit is contained in:
parent
73c70e5d2e
commit
d31b47b371
Notes:
sideshowbarker
2024-07-19 14:41:27 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d31b47b371b
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…
Reference in New Issue
Block a user