Lars,

I had look at the patch... Seems that the Paragraph::next and 
Paragraph::previous are still in use. How do you plan to remove them? I 
suppose that once you have encapsulated them inside the iterator and 
removed all uses from the rest of the code that it will be an easy 
matter to remove them from the Paragraph class.

However, I am still curious as to why LyX is full of Iterator-this and 
Iterator-that classes, when the STL provides iterators for all of it's 
containers. Wouldn't it be more sensible to use an STL list, vector or 
even deque to contain the Paragraph pointers? Even better, use an STL 
container of reference counted paragraph pointers, eg

typedef vector<shared_ptr<Paragraph> > ParagraphList;

Of course, your choice of vector or list depends on what iterator 
properties you want; vector gives you random access, whereas list only 
gives you bidirectional iterators (this is all we are currently using).

The shared pointer approach here works because it's the container that 
contains the shared pointer, not the paragraphs.

The problem with this is that paragraph methods which iterate will need 
to be changed to accept iterator arguments, as they cannot reference 
Paragraph::next to do the iterating any more. (But this is a cleanup 
that needed to happen anyway.)

Using a vector like this would require all of the changes to the code to 
be made in one go, as it would require removing Paragraph::next and 
Paragraph::previous when the implementation starts, so the changeover 
would be less graceful.

Benefit of this approach is that we have fewer custom container and 
iterator classes to write and maintain (and remember).

Ben.

Lars Gullik Bjønnes wrote:

>I have begin leffling with the paragraph-linked-list rewrite, part of
>this is of course to remove the Paragraph::next and
>Paragraph::previous.
>
>I have introduced a new class ParagraphList with accompanying
>Iterator.
>
>So far I have only the header file for this, and have converted class
>buffer to use it (the attached diff).
>
>I'd like to have some comments on if this approach seems sound. (It
>surely is a _lot_ of work.)
>
Yes, but I'm glad to see that it's starting. I could probably help a bit 
here with some creative grepping or sed scripts...

Reply via email to