-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
25 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,9 @@ | |
🔵 使用需加上头文件:#include <map> | ||
2 创建map容器 1️⃣ 调用 map 容器类的默认构造函数。(若默认指定了 std 命令空间,则 std:: 可省略) | ||
1 std::map<std::string, int> map1; 2️⃣ 在创建 map 容器的同时,进行初始化。 | ||
1 std::map<std::string, int> map1 {{"语文",90} , {"数学",100}}; 3️⃣ 利用先前已创建好的 map 容器和拷贝构造函数,再创建一个新的 map 容器。 | ||
1 std::map<std::string, int> map1 { {"语文",90} , {"数学",100} }; 3️⃣ 利用先前已创建好的 map 容器和拷贝构造函数,再创建一个新的 map 容器。 | ||
1 std::map<std::string, int> newMap(map1); 4️⃣ 通过迭代器,取已建 map 容器中指定区域内的键值对,创建并初始化新的 map 容器。 | ||
1 2 std::map<std::string, int> map1 {{"语文",90} , {"数学",100}}; std::map<std::string, int> newMap(++map1." /> | ||
1 2 std::map<std::string, int> map1 { {"语文",90} , {"数学",100} }; std::map<std::string, int> newMap(++map1." /> | ||
<meta property="og:type" content="article" /> | ||
<meta property="og:url" content="https://imcaicai.github.io/stlmap%E5%AE%B9%E5%99%A8%E7%94%A8%E6%B3%95/" /><meta property="og:image" content="https://imcaicai.github.io/img/avatar.jpg"/><meta property="article:section" content="posts" /> | ||
<meta property="article:published_time" content="2023-03-14T15:56:24+08:00" /> | ||
|
@@ -29,9 +29,9 @@ | |
🔵 使用需加上头文件:#include <map> | ||
2 创建map容器 1️⃣ 调用 map 容器类的默认构造函数。(若默认指定了 std 命令空间,则 std:: 可省略) | ||
1 std::map<std::string, int> map1; 2️⃣ 在创建 map 容器的同时,进行初始化。 | ||
1 std::map<std::string, int> map1 {{"语文",90} , {"数学",100}}; 3️⃣ 利用先前已创建好的 map 容器和拷贝构造函数,再创建一个新的 map 容器。 | ||
1 std::map<std::string, int> map1 { {"语文",90} , {"数学",100} }; 3️⃣ 利用先前已创建好的 map 容器和拷贝构造函数,再创建一个新的 map 容器。 | ||
1 std::map<std::string, int> newMap(map1); 4️⃣ 通过迭代器,取已建 map 容器中指定区域内的键值对,创建并初始化新的 map 容器。 | ||
1 2 std::map<std::string, int> map1 {{"语文",90} , {"数学",100}}; std::map<std::string, int> newMap(++map1."/> | ||
1 2 std::map<std::string, int> map1 { {"语文",90} , {"数学",100} }; std::map<std::string, int> newMap(++map1."/> | ||
<meta name="application-name" content="菜菜的秘密花园"> | ||
<meta name="apple-mobile-web-app-title" content="菜菜的秘密花园"><meta name="theme-color" content="#ffffff"><meta name="msapplication-TileColor" content="#da532c"><link rel="icon" href="/img/avatar.jpg"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"><link rel="manifest" href="/site.webmanifest"><link rel="canonical" href="https://imcaicai.github.io/stlmap%E5%AE%B9%E5%99%A8%E7%94%A8%E6%B3%95/" /><link rel="prev" href="https://imcaicai.github.io/stlset%E5%AE%B9%E5%99%A8%E7%94%A8%E6%B3%95/" /><link rel="stylesheet" href="/css/style.min.css"><link rel="preload" href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'"> | ||
<noscript><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css"></noscript><link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/animate.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'"> | ||
|
@@ -44,7 +44,7 @@ | |
"mainEntityOfPage": { | ||
"@type": "WebPage", | ||
"@id": "https:\/\/imcaicai.github.io\/stlmap%E5%AE%B9%E5%99%A8%E7%94%A8%E6%B3%95\/" | ||
},"image": ["https:\/\/imcaicai.github.io\/img\/avatar.jpg"],"genre": "posts","keywords": "C\u002b\u002b, STL, map","wordcount": 124 , | ||
},"image": ["https:\/\/imcaicai.github.io\/img\/avatar.jpg"],"genre": "posts","keywords": "C\u002b\u002b, STL, map","wordcount": 128 , | ||
"url": "https:\/\/imcaicai.github.io\/stlmap%E5%AE%B9%E5%99%A8%E7%94%A8%E6%B3%95\/","datePublished": "2023-03-14T15:56:24+08:00","dateModified": "2023-03-14T15:56:24+08:00","license": "This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.","publisher": { | ||
"@type": "Organization", | ||
"name": "xxxx","logo": "https:\/\/imcaicai.github.io\/img\/avatar.jpg"},"author": { | ||
|
@@ -138,7 +138,7 @@ <h2 class="toc-title">Contents</h2> | |
<div class="toc-content" id="toc-content-auto"></div> | ||
</div><article class="page single"><h1 class="single-title animate__animated animate__flipInX">【STL】map容器用法</h1><div class="post-meta"> | ||
<div class="post-meta-line"><span class="post-author"><a href="/" title="Author" rel="author" class="author"><i class="fas fa-user-circle fa-fw" aria-hidden="true"></i>菜菜</a></span> <span class="post-category">included in <a href="/categories/c++/"><i class="far fa-folder fa-fw" aria-hidden="true"></i>C++</a></span></div> | ||
<div class="post-meta-line"><i class="far fa-calendar-alt fa-fw" aria-hidden="true"></i> <time datetime="2023-03-14">2023-03-14</time> <i class="fas fa-pencil-alt fa-fw" aria-hidden="true"></i> 124 words | ||
<div class="post-meta-line"><i class="far fa-calendar-alt fa-fw" aria-hidden="true"></i> <time datetime="2023-03-14">2023-03-14</time> <i class="fas fa-pencil-alt fa-fw" aria-hidden="true"></i> 128 words | ||
<i class="far fa-clock fa-fw" aria-hidden="true"></i> One minute <span id="/stlmap%E5%AE%B9%E5%99%A8%E7%94%A8%E6%B3%95/" class="leancloud_visitors" data-flag-title="【STL】map容器用法"> | ||
<i class="far fa-eye fa-fw" aria-hidden="true"></i> <span class=leancloud-visitors-count></span> views | ||
</span> </div> | ||
|
@@ -175,7 +175,7 @@ <h2 id="2-创建map容器">2 创建map容器</h2> | |
<pre class="chroma"><code><span class="lnt">1 | ||
</span></code></pre></td> | ||
<td class="lntd"> | ||
<pre class="chroma"><code class="language-c++" data-lang="c++"><span class="n">std</span><span class="o">::</span><span class="n">map</span><span class="o"><</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="p">,</span> <span class="kt">int</span><span class="o">></span> <span class="n">map1</span> <span class="p">{{</span><span class="s">"语文"</span><span class="p">,</span><span class="mi">90</span><span class="p">}</span> <span class="p">,</span> <span class="p">{</span><span class="s">"数学"</span><span class="p">,</span><span class="mi">100</span><span class="p">}};</span> | ||
<pre class="chroma"><code class="language-c++" data-lang="c++"><span class="n">std</span><span class="o">::</span><span class="n">map</span><span class="o"><</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="p">,</span> <span class="kt">int</span><span class="o">></span> <span class="n">map1</span> <span class="p">{</span> <span class="p">{</span><span class="s">"语文"</span><span class="p">,</span><span class="mi">90</span><span class="p">}</span> <span class="p">,</span> <span class="p">{</span><span class="s">"数学"</span><span class="p">,</span><span class="mi">100</span><span class="p">}</span> <span class="p">};</span> | ||
</code></pre></td></tr></table> | ||
</div> | ||
</div><p>3️⃣ 利用先前已创建好的 map 容器和拷贝构造函数,再创建一个新的 map 容器。</p> | ||
|
@@ -194,7 +194,7 @@ <h2 id="2-创建map容器">2 创建map容器</h2> | |
</span><span class="lnt">2 | ||
</span></code></pre></td> | ||
<td class="lntd"> | ||
<pre class="chroma"><code class="language-c++" data-lang="c++"><span class="n">std</span><span class="o">::</span><span class="n">map</span><span class="o"><</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="p">,</span> <span class="kt">int</span><span class="o">></span> <span class="n">map1</span> <span class="p">{{</span><span class="s">"语文"</span><span class="p">,</span><span class="mi">90</span><span class="p">}</span> <span class="p">,</span> <span class="p">{</span><span class="s">"数学"</span><span class="p">,</span><span class="mi">100</span><span class="p">}};</span> | ||
<pre class="chroma"><code class="language-c++" data-lang="c++"><span class="n">std</span><span class="o">::</span><span class="n">map</span><span class="o"><</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="p">,</span> <span class="kt">int</span><span class="o">></span> <span class="n">map1</span> <span class="p">{</span> <span class="p">{</span><span class="s">"语文"</span><span class="p">,</span><span class="mi">90</span><span class="p">}</span> <span class="p">,</span> <span class="p">{</span><span class="s">"数学"</span><span class="p">,</span><span class="mi">100</span><span class="p">}</span> <span class="p">};</span> | ||
<span class="n">std</span><span class="o">::</span><span class="n">map</span><span class="o"><</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="p">,</span> <span class="kt">int</span><span class="o">></span> <span class="n">newMap</span><span class="p">(</span><span class="o">++</span><span class="n">map1</span><span class="p">.</span><span class="n">begin</span><span class="p">(),</span> <span class="n">map1</span><span class="p">.</span><span class="n">end</span><span class="p">());</span> | ||
</code></pre></td></tr></table> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters