Alfredo Braunstein wrote:
Abdelrazak Younes <[EMAIL PROTECTED]> writes:
Good idea, specially because what we have now is: "slow iteration as a list,
slow insertion as a vector"
Not really, what we have now is "fast iteration as a vector, fast
Why? RandomAccessList::iterator is a std::list::iterator...
Right but operator[] is fast. There was a fast iterator version once
though but I don't know where it went...
insertion as a list"...
We have O(n) insertions/deletions like std::vector, std::list speed is O(1)
We use vector as the container for list::iterator not for the Paragraph
itself. insertion/deletion of an iterator in a vector is cheap (fixed
size element) so O(n) is OK. Insertion/deletion of a Paragraph is not
cheap, hence the list container choice.
The only problem could be if we assume list-type iterator stability on
insertion. Not many cases (if any) I presume, but hard to catch.
What do you mean, that we need the stability or that it is hard to find where we
use it?
Both I guess. That being said, I am not religious about that, you can
get rid of it if you find a proper replacement AFAIAC; but I don't think
there is a need to optimize anything here. There is a lot more
inefficient stuff in the source code.
Abdel.