Add checking versions of iterator movement functions

This commit is contained in:
Josh Holtrop 2016-11-02 21:27:13 -04:00
parent dcba852712
commit e545336c51
2 changed files with 32 additions and 0 deletions

View File

@ -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;
}

View File

@ -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);