Vector usage scenarios: such as the storage of software history operation records, we often need to view the history records; another example, the last record, the last record, but the record will not be deleted, because the record is a description of the fact.
Use scenarios of deque: For example, in the queuing ticket purchase system, deque can be used for the storage of queued people, which supports fast removal of the head end and fast addition of the tail end. If a vector is used, when the head end is removed, a large amount of data will be moved, which is slow.
Comparison of vector and deque: 3.1 vector.at() is more efficient than deque.at(). For example, vector.at(0) is fixed, but the start position of deque is not fixed. 3.2 If there are a lot of release operations, vector takes less time, which is related to the internal implementation of the two. 3.3 Deque supports fast insertion and fast removal of the head, which is the advantage of deque.
Use scenarios of list: For example, in the storage of bus passengers, passengers may get off at any time, supporting frequent removal and insertion of elements with uncertain locations.
Set usage scenarios: such as the storage of personal score records for games, the storage requirements are arranged in order from high scores to low scores.
Use scenarios of map: For example, storing 100,000 users by ID number, and want to quickly find the corresponding user by ID, the search efficiency of the binary tree is reflected at this time. If it is a vector container, in the worst case, you may have to traverse the entire container to find the user.