HiveBrain v1.2.0
Get Started
← Back to all entries
principlecppCritical

vector vs. list in STL

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
listvectorstl

Problem

I noticed in Effective STL that


vector is the type of sequence that
should be used by default.

What's does it mean? It seems that ignore the efficiency vector can do anything.

Could anybody offer me a scenario where vector is not a feasible option but list must be used?

Solution

Situations where you want to insert a lot of items into anywhere but the end of a sequence repeatedly.

Check out the complexity guarantees for each different type of container:

What are the complexity guarantees of the standard containers?

Context

Stack Overflow Q#2209224, score: 122

Revisions (0)

No revisions yet.