DisplayBuffer: overload atom_containing with a version taking an iterator to search start

This commit is contained in:
Maxime Coste 2011-10-23 20:26:30 +00:00
parent ad6ee464f4
commit fffa405bfd
2 changed files with 9 additions and 2 deletions

View File

@ -88,10 +88,16 @@ DisplayBuffer::iterator DisplayBuffer::insert(iterator where, const DisplayAtom&
DisplayBuffer::iterator DisplayBuffer::atom_containing(const BufferIterator& where) DisplayBuffer::iterator DisplayBuffer::atom_containing(const BufferIterator& where)
{ {
for (iterator it = m_atoms.begin(); it != m_atoms.end(); ++it) return atom_containing(where, m_atoms.begin());
}
DisplayBuffer::iterator DisplayBuffer::atom_containing(const BufferIterator& where,
iterator start)
{
for (iterator it = start; it != m_atoms.end(); ++it)
{ {
if (it->end() > where) if (it->end() > where)
return it; return it->begin() <= where ? it : end();
} }
return end(); return end();
} }

View File

@ -113,6 +113,7 @@ public:
const_iterator end() const { return m_atoms.end(); } const_iterator end() const { return m_atoms.end(); }
iterator atom_containing(const BufferIterator& where); iterator atom_containing(const BufferIterator& where);
iterator atom_containing(const BufferIterator& where, iterator start);
const DisplayAtom& front() const { return m_atoms.front(); } const DisplayAtom& front() const { return m_atoms.front(); }
const DisplayAtom& back() const { return m_atoms.back(); } const DisplayAtom& back() const { return m_atoms.back(); }