- Mastering C++ Programming
- Jeganathan Swaminathan
- 204字
- 2021-07-02 18:28:51
Associative containers
Associative containers store data in a sorted fashion, unlike the sequence containers. Hence, the order in which the data is inserted will not be retained by the associative containers. Associative containers are highly efficient in searching a value with O( log n ) runtime complexity. Every time a new value gets added to the container, the container will reorder the values stored internally if required.
The STL supports the following types of associative containers:
- Set
- Map
- Multiset
- Multimap
- Unordered set
- Unordered multiset
- Unordered map
- Unordered multimap
Associative containers organize the data as key-value pairs. The data will be sorted based on the key for random and faster access. Associative containers come in two flavors:
- Ordered
- Unordered
The following associative containers come under ordered containers, as they are ordered/sorted in a particular fashion. Ordered associative containers generally use some form of Binary Search Tree (BST); usually, a red-black tree is used to store the data:
- Set
- Map
- Multiset
- Multimap
The following associative containers come under unordered containers, as they are not ordered in any particular fashion and they use hash tables:
- Unordered Set
- Unordered Map
- Unordered Multiset
- Unordered Multimap
Let's understand the previously mentioned containers with examples in the following subsections.
- HTML5移動Web開發技術
- Building a RESTful Web Service with Spring
- Python測試開發入門與實踐
- 游戲程序設計教程
- Visual Basic程序設計習題解答與上機指導
- 高級語言程序設計(C語言版):基于計算思維能力培養
- 深入RabbitMQ
- Nginx實戰:基于Lua語言的配置、開發與架構詳解
- SQL經典實例(第2版)
- 51單片機C語言開發教程
- Python+Tableau數據可視化之美
- Python 3.7從入門到精通(視頻教學版)
- Mastering AWS Security
- Python計算機視覺和自然語言處理
- Learning Splunk Web Framework