STL source code analysis 07-summary of the time complexity of common containers

map set multimap multiset

The above four containers are implemented using red-black trees, and the complexity of the corresponding operations is:

Insert: O(logN)

View: O(logN)

Delete: O(logN)

 

hash_map hash_set hash_multimap hash_multiset

The above four containers are implemented using hash tables, and the time complexity of the corresponding operations is:

Insertion: O(1) worst is O(N)

View: O(1) The worst is O(N)

Delete: O(1) worst is O(N)

 

Guess you like

Origin blog.csdn.net/www_dong/article/details/114049115