>>>>> "Abdelrazak" == Abdelrazak Younes <[EMAIL PROTECTED]> writes:

Abdelrazak> I think a vector of pointers solution would indeed solve a
Abdelrazak> lot of the same problems but I don't think you would gain
Abdelrazak> anything in terms of code size and simplicity. I would
Abdelrazak> even say the contrary.



Abdelrazak> Beside, here is some advantages of having a list compared
Abdelrazak> to a vector of pointer solution. 1) A list is ordered: one
Abdelrazak> paragraph after the other. 

A vector is ordered too.

Abdelrazak> And we inherit list::iterator properties. 

What properties are not in vector?

Abdelrazak> 2) Multiple paragraphs insertion and deletion can be
Abdelrazak> optimized 

Abdelrazak> 3) You don't have to do any memory management (no new, no
Abdelrazak> delete)

We can use smart pointer to handle the deletes (shared_ptr maybe). The
new has to be done indeed.

Abdelrazak> The only advantage I can think of for the vector of
Abdelrazak> pointers solution is that

Abdelrazak>   vector.insert(pos, new Paragraph(par))

Abdelrazak> should be a bit faster than:

Abdelrazak>   list.insert(par)

operator- will be faster too.

JMarc

Reply via email to