<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>哈希 on My Blog</title>
    <link>http://localhost:1313/tags/%E5%93%88%E5%B8%8C/</link>
    <description>Recent content from My Blog</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    
    <managingEditor>3453434429@qq.com (ArenBase)</managingEditor>
    <webMaster>3453434429@qq.com (ArenBase)</webMaster>
    
    <copyright>本博客所有文章除特别声明外，均采用 BY-NC-SA 许可协议。转载请注明出处！</copyright>
    
    <lastBuildDate>Wed, 18 Mar 2026 00:00:00 +0000</lastBuildDate>
    
    
    <atom:link href="http://localhost:1313/tags/%E5%93%88%E5%B8%8C/index.xml" rel="self" type="application/rss&#43;xml" />
    

    
    

    <item>
      <title>哈希表unordered_map或者map查询规范</title>
      <link>http://localhost:1313/post/%E5%93%88%E5%B8%8C%E8%A1%A8unordered_map%E6%88%96%E8%80%85map%E6%9F%A5%E8%AF%A2%E8%A7%84%E8%8C%83/</link>
      <pubDate>Wed, 18 Mar 2026 00:00:00 &#43;0000</pubDate>
      <author>3453434429@qq.com (ArenBase)</author>
      <guid>http://localhost:1313/post/%E5%93%88%E5%B8%8C%E8%A1%A8unordered_map%E6%88%96%E8%80%85map%E6%9F%A5%E8%AF%A2%E8%A7%84%E8%8C%83/</guid>
      <description>
        <![CDATA[<h1>哈希表unordered_map或者map查询规范</h1><p>作者：ArenBase（3453434429@qq.com）</p>
        
          <h2 id="总结优先使用方法1进行哈希表的查找">
<a class="header-anchor" href="#%e6%80%bb%e7%bb%93%e4%bc%98%e5%85%88%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%951%e8%bf%9b%e8%a1%8c%e5%93%88%e5%b8%8c%e8%a1%a8%e7%9a%84%e6%9f%a5%e6%89%be"></a>
总结：优先使用方法1进行哈希表的查找
</h2><h3 id="方法1">
<a class="header-anchor" href="#%e6%96%b9%e6%b3%951"></a>
方法1：
</h3><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-fallback" data-lang="fallback"><span class="line"><span class="cl">auto it = myMap.find(2); // 查找键为2的元素
</span></span><span class="line"><span class="cl">if (it != myMap.end()) {
</span></span><span class="line"><span class="cl">    std::cout &lt;&lt; &#34;Found: &#34; &lt;&lt; it-&gt;second &lt;&lt; std::endl;
</span></span><span class="line"><span class="cl">}
</span></span></code></pre></div><h4 id="原因">
<a class="header-anchor" href="#%e5%8e%9f%e5%9b%a0"></a>
原因：
</h4><p>使用<code>find()</code>函数，它执行纯查找操作，不修改容器。如果键不存在，返回<code>end()</code>迭代器，您可以安全地检查并处理未找到的情况，而不会影响<code>unordered_map</code>的状态。这是一种高效且无副作用的做法。</p>
        
        <hr><p>本文2026-03-18首发于<a href='http://localhost:1313/'>My Blog</a>，最后修改于2026-03-18</p>]]>
      </description>
      
        <category>C&#43;&#43;</category>
      
    </item>
    
  </channel>
</rss>
