Jean-Marc Lasgouttes wrote:

> The code that initializes the iterators looks a bit ugly, but it can
> be
> - factored out somewhere in bufferview.C
> - probably improved by someone who is better at STL than I am.
> 
> I think it works, and would be interested by some testing. I believe
> the bruteFind function is exactly equivalent to what it was.

I have some questions/points for you...

+ // Unsafe if .find() can return .end()
  CoordCache::InnerParPosCache const & cache =
    theCoords.getParPos().find(cursor.bottom().text())->second;
  // Get an iterator on the first paragraph in the cache
  DocIterator it(inset);
  it.push_back(CursorSlice(inset));
+ // Do you need to check whether it.pit() == 0 after assignment?
  it.pit() = cache.begin()->first;

  // Get an iterator after the last paragraph in the cache
  DocIterator et(inset);
  et.push_back(CursorSlice(inset));
+ // What happens if cache.empty()? Is it guaranteed not to be if
+ // .find() above does not return .end() ?
  et.pit() = boost::prior(cache.end())->first;

  // Is it possible for et.pit() to be zero and
  // et.lastpit() to be non-zero?
  if (et.pit() >= et.lastpit())
+   // Given that doc_iterator_end(inset) is identical to
+   // DocIterator(inset), why not be consistent?
    et = doc_iterator_end(inset);
  else
    ++et.pit();

-- 
Angus

Reply via email to