- 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.
- 程序員面試白皮書
- Kali Linux Web Penetration Testing Cookbook
- 劍指JVM:虛擬機實踐與性能調優
- INSTANT FreeMarker Starter
- Java EE框架整合開發入門到實戰:Spring+Spring MVC+MyBatis(微課版)
- Twilio Best Practices
- PyTorch自然語言處理入門與實戰
- NativeScript for Angular Mobile Development
- Python進階編程:編寫更高效、優雅的Python代碼
- Java程序設計與實踐教程(第2版)
- C# 8.0核心技術指南(原書第8版)
- Python圖形化編程(微課版)
- 小型編譯器設計實踐
- HTML+CSS+JavaScript編程入門指南(全2冊)
- HTML5 Game Development by Example:Beginner's Guide(Second Edition)