Table of Contents Further implementation of hash buckets introduce keyofValue Iterator insert return value operator[ ] key cannot be modified Simulation implementation keyofValue code Iterator who is first Convert ordinary iterator to const iterator const *this problem code insert and erase Convert const iterator to normal iterator key cannot be modified Full version code unordered […]
Tag: unordered
[C++ unordered_set, unordered_map]
Directory 1. Hash 1.1 Hash–open hashing 1.2 Hash–Closed Hash 1.3 Hash optimization 2. unordered_set, unordered_map 2.1 Framework construction of unordered_set and unordered_map 2.2 Iterators of unordered_set and unordered_map 2.2.1 Construction of ordinary iterators 2.2.2 Encapsulation of ordinary iterators 2.2.3 Unordered_set encapsulation of ordinary iterators 2.2.4 Unordered_map encapsulation of ordinary iterators 2.3 The Keys of unordered_set […]
C++ – unordered series of associative containers and hashes
1. unordered series associative containers 2. Hash principle 3. Unordered_map simulation implementation 1. unordered series associative containers unordered_map is an associative container that stores key-value pairs. Their types can be different. Unlike map, unordered_map does not perform a specific sorting of key values. Its bottom layer uses hash, and the hash values are the same. […]
[unordered_map/unordered_set] is implemented by [Hash/Hash] simulation (hand-shredded iterator)
Article directory 1. Iterator analysis 2.Detail processing 3. Complete code 3.1HashTable.h 3.2unordered_set.h 3.3unordered_map.h 3.4Test.cpp 1. Iterator analysis 2.Detail processing The following two articles are the author’s painstaking efforts Those who want to understand this article uuPlease check it yourself Detailed implementation of hashing/hashing Hash/Hash – Hash Table [Ideas to Structure] [==revision==] Detailed processing of hand-shredded […]
Encapsulate unordered_map and unordered_set
Previously, map and set were encapsulated with red-black trees. Now we need to use hash to encapsulate unordered_map and unordered_set (to simplify the names, they will be called u_map and u_set from now on).u_map and u_set were used when learning map I have learned about it, but I only know that it is disordered. I […]
(unordered) map and set encapsulation (underlying red-black tree)
map and set encapsulation Article directory map and set encapsulation Design issues (know why) Why encapsulate iterator? Why introduce the template parameters Self Ref Ptr? Why are you trying to convert from non_const to const instead of const to non_const? How to solve Why is it said that const can be added? Const can be […]
unordered_map and unordered_set simulation implementation
The reason why the unordered series of associative containers are more efficient is that they use a hash structure at the bottom. 1. Hash 1.1 Hash concept Construct a storage structure, and use a certain function (hashFunc) to establish a one-to-one mapping relationship between the storage location of the element and its key code. Then […]
[C++] Encapsulation of unordered_set and unordered_map
Personal homepage: Ordinary Xiao Su Learning motto: Fate gives you a low starting point. It wants to see you make a wonderful comeback, rather than letting you fall into despair. Although the road under your feet is difficult, I can still walk. Compared with being born towards the sun , I want to try to […]
<C++> STL_unordered_set/map
1.unordered series associative containers In C++98, STL provides a series of associative containers with a red-black tree structure at the bottom. The query efficiency can reach O(logN), that is, in the worst case, the height of the red-black tree needs to be compared times. When the tree When there are very many nodes in the […]
Processing of structures in unordered_map and map as key values
1. When the structure in unordered_map is key There are two ways to deal with this. Method 1 overloads operator”()” and “operator==” operators inside the structure; method 2 overloads “operator==” outside the structure. At the same time, the hash template is used to specialize the Student (structure defined in this example) type; the two specific […]