diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-11-16 17:56:18 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-11-16 17:57:00 +0100 |
commit | d2046e79cfd915429b4755ef8e1338a1baa7815f (patch) | |
tree | b591f6c919582101e4632442ba43937dea4a8610 /AK/Vector.h | |
parent | 52d1822c3cf51c969d9a1bafc435470c993485d4 (diff) | |
download | serenity-d2046e79cfd915429b4755ef8e1338a1baa7815f.zip |
Add a DoubleBuffer thingy to allow TTY read/write to be interleaved.
I feel like this concept might be useful in more places. It's very naive
right now and uses dynamically growing buffers. It should really use static
size buffers and never kmalloc().
Diffstat (limited to 'AK/Vector.h')
-rw-r--r-- | AK/Vector.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/AK/Vector.h b/AK/Vector.h index 8824e10a46..d52cea64e2 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -188,6 +188,14 @@ public: ++m_impl->m_size; } + void append(const T* values, size_t count) + { + ensureCapacity(size() + count); + for (size_t i = 0; i < count; ++i) + new (m_impl->slot(m_impl->m_size + i)) T(values[i]); + m_impl->m_size += count; + } + void ensureCapacity(size_t neededCapacity) { if (capacity() >= neededCapacity) |