mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
AK: Add Vector::prepend() overload for multiple items
Much like with Vector::append(), you may want to append multiple items in one go. It's actually more important to do this for prepending, because you don't want to copy the rest of items further each time.
This commit is contained in:
parent
97b3035c14
commit
d62346c0b1
Notes:
sideshowbarker
2024-07-19 01:17:52 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/d62346c0b1e Pull-request: https://github.com/SerenityOS/serenity/pull/4130 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/awesomekling
1 changed files with 10 additions and 0 deletions
10
AK/Vector.h
10
AK/Vector.h
|
@ -447,6 +447,16 @@ public:
|
||||||
m_size += other_size;
|
m_size += other_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void prepend(const T* values, size_t count)
|
||||||
|
{
|
||||||
|
if (!count)
|
||||||
|
return;
|
||||||
|
grow_capacity(size() + count);
|
||||||
|
TypedTransfer<T>::move(slot(count), slot(0), m_size);
|
||||||
|
TypedTransfer<T>::copy(slot(0), values, count);
|
||||||
|
m_size += count;
|
||||||
|
}
|
||||||
|
|
||||||
void append(const T* values, size_t count)
|
void append(const T* values, size_t count)
|
||||||
{
|
{
|
||||||
if (!count)
|
if (!count)
|
||||||
|
|
Loading…
Reference in a new issue