当前位置:网站首页>Usage of STL map
Usage of STL map
2022-06-25 06:36:00 【Zhiyuan in the rain 943】
map It's mapping , You can map any primitive type to any other primitive type .
map Several characteristics of , The key value inside is unique , If there is a repetition, the previous one will be overwritten .
And if you traverse the access , The container will automatically sort from small to large .
Catalog
2.map Access to elements within a container
3.map Analysis of commonly used functions
1.map Definition
map<typename 1, typename 2> mp;
Building in front key, Value after value.
2.map Access to elements within a container
(1). By subscript , take key As a subscript .
(2). By iterator map<typename 1, typename 2>::iterator it;
So you can get the iterator it.
And then use it->first Access key ,it->second Access value .
3.map Analysis of commonly used functions
(1) find(key), The direct return key value is key The iterator of the map of If we can't find a way back end().
(2) erase()
It can be an iterator , It can also be a key , It can also be an interval .
(3) size() The return is map The logarithm of the mapping .
(4) clear() Empty map All elements in
(5) count(), You can count the number of times a key value appears , So it can be used to determine whether there is a key .
4. Yan Shen
It can be used unordered_map To replace map, Replace with a hash map Internal red black tree implementation , But at the expense of sorting , Faster than map faster .
边栏推荐
- ACWING/2004. Misspelling
- Metauniverse in 2022: robbing people, burning money and breaking through the experience boundary
- ctfshow-misc
- Arm instructions and others
- ACWING/2004. 错字
- Detailed explanation of @jsoninclude annotation in Jackson
- ACWING/2004. 錯字
- Zhinai's database
- [kicad image] download and installation
- Global and Chinese kaolin market operation scale and investment development proposal report 2022
猜你喜欢

Comparison test of mono 120W high power class D power amplifier chip cs8683-tpa3116

How to realize the stable output of 3.3v/3.6v (1.2-5v) voltage of lithium battery by using the voltage rise and fall chip cs5517

Cs5092 5V USB input boost two section lithium battery charging management IC, SOT23-6 miniature package

Cs8126t 3.1w mono ultra low EMI unfiltered class D audio power amplifier IC

ctfshow-misc

You can see the classification of SQL injection. SQL injection point /sql injection type /sql injection has several /sql injection point classifications

アルマ / 炼金妹

cos(a+b)=cosa*cosb-sina*sinb的推导过程

At the age of 26, I was transferred to software testing with zero foundation. Now I have successfully entered the job with a monthly salary of 12K. However, no one understands my bitterness

Cannot activate inspection type when SAP retail uses transaction code mm41 to create commodity master data?
随机推荐
[short time energy] short time energy of speech signal based on MATLAB [including Matlab source code 1719]
3-7sql injection website instance step 3: attack type and attack strategy
How to record a database [closed] - how to document a database [closed]
Zero foundation wants to learn web security, how to get started?
How to realize hierarchical management of application and hardware in embedded projects
Detailed explanation of @jsoninclude annotation in Jackson
Analysis report on demand scale and Supply Prospect of global and Chinese thermal insulation materials market during the 14th Five Year Plan period 2022-2028
[no title] dream notes 2022-02-20
百度地图——入门教程
What does cardinality mean in set
How to configure log4j to only keep log files for the last seven days?
How to create a handy vs Code?
ACWING2013. 三条线
レレ / 蕾蕾
At the age of 26, I was transferred to software testing with zero foundation. Now I have successfully entered the job with a monthly salary of 12K. However, no one understands my bitterness
IQ debugging of Hisilicon platform ISP and image (1)
Wechat applet authorization login + mobile phone sending verification code +jwt verification interface (laravel8+php)
SAP QM executes the transaction code qp01, and the system reports an error -material type food is not defined for task list type Q-
Query process of MySQL secondary index
Cs5092 5V USB input boost two section lithium battery charging management IC, SOT23-6 miniature package