一般来说,当你不关心你正在使用什么类型的顺序容器时使用vector,但如果你在容器中的任何地方进行了很多插入或擦除操作,而非只在末尾,那就使用list。 或者如果你需要随机访问,那么你会想要vector,而不是list。
http://www.cs.northwestern.edu/~riesbeck/programming/c++/stl-summary.html
Container Types: ================ Container: Forward Container Reverse Container Random Access Container Sequence Front Insert Sequence Back Insert Sequence Associative Container Simple Associative Container Pair Associative Container Sorted Associative Container Multiple Associative Container Container Types mapped to Standard Containers ============================================= std::vector: Sequence Back Sequence Forward/Reverse/Random Container std::deque: Sequence Front/Back Sequence Forward/Reverse/Random Container std::list: Sequence Front/Back Sequence Forward/Reverse Container std::set: Sorted/Simple/Unique Associative Container Forward Container std::map: Sorted/Pair/Unique Associative Container Forward Container std::multiset: Sorted/Simple/Multiple Associative Container Forward Container std::multimap: Sorted/Pair/Multiple Associative Container Forward Container