Add checking versions of iterator movement functions
This commit is contained in:
parent
dcba852712
commit
e545336c51
@ -40,6 +40,21 @@ void GapBuffer::Iterator::forward()
|
||||
}
|
||||
}
|
||||
|
||||
bool GapBuffer::Iterator::check_forward()
|
||||
{
|
||||
if (valid())
|
||||
{
|
||||
Iterator i2 = *this;
|
||||
i2.forward();
|
||||
if (i2.valid())
|
||||
{
|
||||
m_offset = i2.m_offset;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GapBuffer::Iterator::back()
|
||||
{
|
||||
if (valid())
|
||||
@ -56,3 +71,18 @@ void GapBuffer::Iterator::back()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GapBuffer::Iterator::check_back()
|
||||
{
|
||||
if (valid())
|
||||
{
|
||||
Iterator i2 = *this;
|
||||
i2.back();
|
||||
if (i2.valid())
|
||||
{
|
||||
m_offset = i2.m_offset;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -23,7 +23,9 @@ public:
|
||||
return m_offset < m_gap_buffer->size();
|
||||
}
|
||||
void forward();
|
||||
bool check_forward();
|
||||
void back();
|
||||
bool check_back();
|
||||
uint8_t * address() const
|
||||
{
|
||||
return m_gap_buffer->address(m_offset);
|
||||
|
Loading…
x
Reference in New Issue
Block a user