I know this forum is supposed to be for non-programming topics, but I thought this would go better in the Lounge than General C++ Programming (considering that said sub-forum has become much like the Beginners forum).
Which STL Sequence Container do you use the most, and why? For me, I like using deques due to the fact that I don't have to iterate through a long list to get to segments of data I need in the deque, and I don't need to deal with massive memory shifts whenever I insert something without reserving enough space beforehand. This is quite handy for me, considering the programming I do.
Also, while I could care less that the C++ standard requests that I use vectors by default, I still don't care too much.
This is quite handy for me, considering the programming I do.
Isn't that the key point? I haven't used all the stl containers so I guess I don't have a full opinion but from what I do know you use the most appropriate contianer for that particular task. So doesn't that make the question somewhat pointless?
EDIT** I apologise, I misread the "STL Sequence Container", but I guess my point still applies to an extent...
Which STL Sequence Container do you use the most, and why?
As mcleano said, it depends on what you want to do. In general, there are two things that you can't have together: fast access and fast modification.
There are cases where this is not a problem.... For example, let's say you want to load some records from a database, then let the user see them and then have him choose some for more processing. You could load the data from the file to a list of records (no fear for vector resizing...), after your'done, create a vector of record pointers (or list<record>::iterators) that point to the loaded data ;) Have the user make his picks (vector fast random access) and push them back to a new container (be it something that will help with the further processing). We have no problem here because the access and modification processes of our data are isolated from each other.
But there are cases where you want both fast access and fast modification at the same time... I guess you could hack your way to the desired result, again depending on which of the two you want more...
std::vector and std::[w]string. I find that data structures are read from more often than are written to, so optimizing for access gives better average performance than optimizing for modification. std::vectors also have the advantage that they guarantee that &v[1]==&v[0]+1, which means that they can be used to interact with code that's unaware of them (e.g. std::istream::read(), or anything else that uses buffers). I've never found a case where I needed to remove chunks of data from the middle of the structure very often, except when managing resources, in which case I'll use a list since I'll have to iterate over the structure to find pointers, anyway, or a vector of pointers+null pointers if I want to give out handles rather than proper pointers (give the user less power and responsibility).
Excepting std::strings, I tend to use std::vector for relatively small sequences and std::deque for very large sequences. (But I do not limit myself to them, as helios explained, each sequence container has distinct properties which may make one more useful in a given context.)