Maps are associative, andvectors,lists,anddeque are sequential in type.
Map: Underlying mechanism rb-tree(red-black tree), automatic ordering of elements, key-value pairs.
Vector: operates in a similar way to array, with dynamic space growth. is a continuous space that supports random access.
Advantages:
? Memory is dynamically growing and does not require a specified memory size.
? Support for random access, i.e. support [] and vector.at ().
Disadvantages:
? Internal Insert delete operation is inefficient.
? push and popare only available at the end of the vector .
List: The use of space is absolutely accurate, not a waste of it. Deleting inserts is simple, but does not support random access. Bidirectional linear list.
Advantages:
? Easy to insert and remove.
? Can be push,popon both ends.
Cons: cannot be accessed randomly.
Deque: Continuity space for bidirectional openings. The insertion and deletion of elements are made at each end of the tail.
Advantages:
? Random access.
? Easy to insert and remove.
? Can be push,popon both ends.
Cons: Internal implementation is complex and less efficient. Sort, etc. not applicable.
Summary of Use occasions:
? Requires efficient access, not in terms of insertion and deletion efficiency, using vectors.
? It takes a lot of insertions and deletions, doesn't care about access, uses list.
? Care access, and both ends of the data are inserted and deleted, using deque.
? Key-value pairs, one-to-one mapping, using map.
Summary of C + + technical Issues-7th: map, vector, list, deque each use occasion