1.Vector (continuous space storage, you can use the [] Operator) to quickly access random elements, quickly Insert elements at the end, but insert Between the ages of the sequence, it is slow to delete elements, and if the space allocated at the beginning is not enough, there will be a performance overhead for re-allocating larger space and copying.
2.Deque) quick access to random elements, fast insertion of elements at the beginning and end, random insertion, slow deletion of elements, and faster Space reallocation than vector, the original elements do not need to be copied. To sort a deque, copy the deque to the vector first, and then copy it back to deque.
3.List (each element is connected by a linked list) accessing random elements is not as fast as vector, and random inserted elements are faster than vector. Therefore, space is allocated to each element. Therefore, there is no sufficient space and the allocation is re-allocated.
4.The internal elements of the set are unique and stored in a balance tree structure. Therefore, the elements are sorted during traversal and the search speed is relatively high.
5.The key of a map must be unique.
6.The stack adapter must be used with other containers. The default internal container in STL is deque. First, only one exit is available, and traversal is not allowed.
7.Queue is a restricted deque. It is easier to use a list for internal containers. First-in-first-out, traversal not allowed.
Below are some guidelines for selecting the sequence container type
1. If we need to randomly access a container, the vector is much better than the list..
2. If we know the number of elements to be stored, the vectorIt is also a better choice than list.
3. If we need to insert and delete elements at both ends of the container, the list is obviously better than the vector.
4. the vector is better than deque unless we need to insert and delete elements in the container header.
5. If you only insert data elements at the beginning and end of an easy task, select deque.
6. if you only need to insert an element in the middle of the container when reading the input and then randomly access the element, you can consider reading the element into a list container during the input, next, repeat this container to make it suitable for sequential access, and then copy the sorted list container to a vector container.