"Jerry Coffin" <jcoffin@taeus.com> wrote in message
news:MPG.1f1b55daf4d9a8ec989888@news.sunsite.dk...
In article <1152484630.095003.112820@75g2000cwc.googlegroups.com>,
junw2000@gmail.com says...
These are useful a lot less often than they might initially appear.
In fact, I'm pretty sure in the 10 years (or so) since I first
started using (then pre-standard) STL, I haven't run into a single
situation where I put an std::list to real use. I've had a couple
that might have been close calls, and I can _imagine_ some where
they'd make but it hasn't arisen in real use for me yet.
Not to disagree with your comments, but I sometimes use
a list instead of a vector when I don't need to access by
index and I don't know the size ahead of time.
Since vectors maintain contiguous memory, push_backs
can cause a lot of copying if you can't reserve ahead
of time. This is just my opinion.
At the office we constantly have discussions
about this but I find that using lists can reduce
memory fragmentation. This is sometimes worth
the overhead of the doubly linked list. It needs
benchmarking though.
If I can reserve the size or if I need to access by
index, I will use a vector. If I can't reserve the
size and don't need to access by index it depends.
"most" purposes. Certainly there are cases where the copying upon
provide a significant performance edge over lists.