- 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.
- 國際大學(xué)生程序設(shè)計競賽中山大學(xué)內(nèi)部選拔真題解(二)
- Design Principles for Process:driven Architectures Using Oracle BPM and SOA Suite 12c
- 深入理解Django:框架內(nèi)幕與實(shí)現(xiàn)原理
- Julia機(jī)器學(xué)習(xí)核心編程:人人可用的高性能科學(xué)計算
- 匯編語言程序設(shè)計(第2版)
- 快速念咒:MySQL入門指南與進(jìn)階實(shí)戰(zhàn)
- Python Data Science Cookbook
- 寫給大家看的Midjourney設(shè)計書
- JQuery風(fēng)暴:完美用戶體驗(yàn)
- Mastering Clojure
- 虛擬現(xiàn)實(shí):引領(lǐng)未來的人機(jī)交互革命
- Visual FoxPro數(shù)據(jù)庫程序設(shè)計
- ArcGIS Blueprints
- 深度剖析ApacheDubbo核心技術(shù)內(nèi)幕
- Abaqus GUI程序開發(fā)指南(Python語言)