stl containers brief

1.vector:

Dynamic continuous array, when space allocation, reassign double the space for storage, insertion and deletion of data movement will cause subsequent data copy

 

2.list:

Two-way circular list, non-contiguous space

 

3.map:

Red-black tree, log levels, spatial memory consumption O (N)

Insert: recursive layers increases, the rotation up to 2 times, 3 case

Delete: Recursive 1 layer increases, the rotation up to 3 times, 4 case 

 

4.set:

Red-black tree, log levels, spatial memory consumption O (N)

Consistent with the map, but it is the key value store

 

5.multimap:

Consistent with the map, but allow duplicate key (_M_insert_equal)

 

6.multiset:

Basically the same set, but allows duplicate key (_M_insert_equal)

 

7.hashmap:

Hash table, vector when the barrel, to resolve the conflict list

 

8.hashset:

With hashmap, the same value and key

 

9.hash_multimap:

Hashmap consistent with, but allow duplicate key (insert_equal)

 

10.hash_multiset:

 

 

Consistent hashset, simply allow duplicate key (insert_equal)

 

 

 

Published 140 original articles · won praise 28 · views 180 000 +

Guess you like

Origin blog.csdn.net/qq_16097611/article/details/78880303