Add GapBuffer::erase()
This commit is contained in:
1 parent
57d525ae44
commit
92b3e888b5
3 files changed
+56
No files matched your search
@@ -33,6 +33,23 @@ void GapBuffer::insert(size_t position, const uint8_t * data, size_t length)
|
||||
m_size += length;
|
||||
}
|
||||
|
||||
void GapBuffer::erase(size_t position, size_t length)
|
||||
{
|
||||
if ((position < m_size) && ((position + length) <= m_size))
|
||||
{
|
||||
if ((position + length) == m_gap_position)
|
||||
{
|
||||
m_gap_position -= length;
|
||||
m_size -= length;
|
||||
}
|
||||
else
|
||||
{
|
||||
move_gap(position);
|
||||
m_size -= length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string GapBuffer::get_string()
|
||||
{
|
||||
compact();
|
||||
|
||||
@@ -46,6 +46,16 @@ public:
|
||||
*/
|
||||
void insert(size_t position, const uint8_t * data, size_t length);
|
||||
|
||||
/**
|
||||
* Erase data from the gap buffer.
|
||||
*
|
||||
* @param position
|
||||
* Position in the gap buffer to erase data from.
|
||||
* @param length
|
||||
* Length of the data to erase.
|
||||
*/
|
||||
void erase(size_t position, size_t length);
|
||||
|
||||
/**
|
||||
* Get the contents of the gap buffer as a string.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user