summaryrefslogtreecommitdiff
path: root/AK/Vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'AK/Vector.h')
-rw-r--r--AK/Vector.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/AK/Vector.h b/AK/Vector.h
index a44bfadf7c..13ffb4df64 100644
--- a/AK/Vector.h
+++ b/AK/Vector.h
@@ -159,6 +159,20 @@ public:
m_impl->remove(index);
}
+ void insert(int index, T&& value)
+ {
+ ASSERT(index <= size());
+ if (index == size())
+ return append(move(value));
+ ensure_capacity(size() + 1);
+ ++m_impl->m_size;
+ for (int i = size() - 1; i > index; --i) {
+ new (m_impl->slot(i)) T(move(m_impl->at(i - 1)));
+ m_impl->at(i - 1).~T();
+ }
+ new (m_impl->slot(index)) T(move(value));
+ }
+
Vector& operator=(const Vector<T>& other)
{
if (this != &other) {