diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-07 15:52:11 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-07 15:52:11 +0100 |
commit | 8425ea971a97bca1039fbbb8ad76a5f18c097536 (patch) | |
tree | 84062f344861f7a9d0eb530aee10744b5bf7d63b /AK | |
parent | b4df33e45386ff38677d9537a539efafd10fcfbb (diff) | |
download | serenity-8425ea971a97bca1039fbbb8ad76a5f18c097536.zip |
GTextEditor: Start working on editing, starting with inserting newlines.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Vector.h | 14 |
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) { |