Lists Vs Vectors

are lists in general faster than vectors?
In general, no.

std::vector<> is the preferred sequence container.

There would be specific situations where a std::list<> could be faster or would be more suitable. For instance, if insertions or deletions in the middle of the sequence is the common use case. If we need to hold references or pointers to elements in the container across insertions or deletions. If we need strong exception guarantees in case of failure.
Last edited on
Vectors tends to slow down as the size increases... due to relocation of whole memory.. search is faster ..
lists can have fast insertions .. O(1) at the end and begining.. but sequential lookup.. by various techniques you can have a fast lookup/insertions in the middle in lists.. try to use some supplimentry data structure with lists to make it fast.. this can make it much faster than a vector..
Topic archived. No new replies allowed.