[Please do not mail me a copy of your followup]
nor...@example.com spake the secret code
<Q8Wix.1$FC...@fx23.iad> thusly:
>Stroustrup's talk (mentioned in another thread somewhere in this newsgroup)
>made me want to revisit the decision to use lists.
>
>I'm wondering if in this specific domain (an editor), lists are in fact the
>better choice over vectors as the holder-of-all-lines?
There are two kinds of forces at work here: design and performance.
The design forces revolve around the readability of your code. Is
there any benefit to comprehension in choosing one container over
another? For std::list<std::string> vs. std::vector<std::string>,
there probably isn't going to be much difference in comprehension in
choosing one over the other. This is particularly true if your code is
making use of iterators and a typedef for the container. In other
words, if you have code like:
typedef std::list<std::string> line_container_t;
void munge_lines(line_container_t::iterator begin,
line_container_t::iterator end)
{
// do stuff with lines through iterators
}
Then switching from list to vector is just a matter of changing the
typedef and possibly adjusting a few places where you directly interact
with list specific members.
The performance forces are how fast the code runs. This can only be
determined by running your code against some sort of test case and
measuring the results. The surprising thing about all these talks in
the past few years at C++ conferences over "list vs. vector" or "map
vs. vector" is that the performance analysis shows that vector does
much, much better than most people expect. This appears to be true for
both short lists and long lists, short vectors and long vectors.
The costs for traversing up the computer memory hierarchy have been
getting bigger over time. Whereas before a cache miss was undesirable
but tolerable, today it can absolutely kill your performance.
<
https://en.wikipedia.org/wiki/Memory_hierarchy>
--
"The Direct3D Graphics Pipeline" free book <
http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <
http://computergraphicsmuseum.org>
The Terminals Wiki <
http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <
http://legalizeadulthood.wordpress.com>