haisayu
2022-04-18 10:20:03 +08:00
conclusion
to conclude, we can get some facts about each data structure:
- std::vector is insanely faster than std::list to find an element
- std::vector always performs 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 large elements very well, especially for sorting or inserting in the front
these are the simple conclusions on usage of each data structure:
- for number crunching : use std::vector
- for linear search : use std::vector
- for random insert/remove : use std::list (if data size very small (< 64b on my computer), use std::vector)
- for big data size : use std::list (not if intended for searching)
你给的链接说的挺清楚了。不同场景不一样。