summaryrefslogtreecommitdiff
path: root/AK/Vector.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-16 17:56:18 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-16 17:57:00 +0100
commitd2046e79cfd915429b4755ef8e1338a1baa7815f (patch)
treeb591f6c919582101e4632442ba43937dea4a8610 /AK/Vector.h
parent52d1822c3cf51c969d9a1bafc435470c993485d4 (diff)
downloadserenity-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.h8
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)