Here is the summary from an interesting performance benchmark article which comparing vector and list int C++11
Conclusion for vector<> VS deque<> VS list<>:
To conclude, we can get some facts about each data structure:
- std::list is very very slow to iterate through the collection due to its very poor spatial locality.
- std::vector and std::deque perform always faster than std::list with very small data
- std::list handles very well large elements
- std::deque performs better than a std::vector for inserting at random positions (especially at the front, which is constant time)
- std::deque and std::vector do not support very well data types with high cost of copy/assignment
This draw simple conclusions on usage of each data structure:
- Number crunching: use std::vector or std::deque
- Linear search: use std::vector or std::deque
- Random Insert/Remove: use std::list (if data size very small (< 64B on my computer), use std::deque)
- Big data size: use std::list (not if intended for searching)
- Non-trivial data type: use std::list
- Push to front: use std::deque or std::list
Updated conclusion for vector<> VS list<>:
Reference:
- std::vector is insanely faster than std::list to find an element
- std::vector performs always faster than std::list with very small data
- std::vector is always faster to push elements at the back than std::list
- std::list handles very well large elements, especially for sorting or inserting in the front
This draw simple conclusions on usage of each data structure:
- Number crunching: use std::vector
- Linear search: use std::vector
- Random Insert/Remove: use std::list (if data size very small (< 64B on my computer), use std::vector)
- Big data size: use std::list (not if intended for searching)
http://www.baptiste-wicht.com/2012/11/cpp-benchmark-vector-vs-list/
http://www.baptiste-wicht.com/2012/12/cpp-benchmark-vector-list-deque/