<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[std::map Zugriff auf Element über Iterator?]]></title><description><![CDATA[<p>Hallo,<br />
ich habe z.B. folgende Map:</p>
<pre><code class="language-cpp">map&lt;string, int&gt; myMap;
</code></pre>
<p>Um ein Element der Map abzufragen, prüfen ich vorher mit myMap.find(&quot;xy&quot;) ob dieses Element überhaupt existiert, und lasse mir dann mittels myMap(&quot;xy&quot;) den Wert ausgeben.</p>
<p>Somit muss die Map bei Vorhandensein zweimal durchsucht werden, obwohl ich die Position doch eigentlich beim find() schon habe.</p>
<p>Ist es möglich den Inhalt eines Map-Containers auch direkt über den Iterator abzufragen?</p>
<p>Gruß<br />
Thomas</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/206249/std-map-zugriff-auf-element-über-iterator</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 07:03:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/206249.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 22 Feb 2008 16:22:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std::map Zugriff auf Element über Iterator? on Fri, 22 Feb 2008 16:22:57 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe z.B. folgende Map:</p>
<pre><code class="language-cpp">map&lt;string, int&gt; myMap;
</code></pre>
<p>Um ein Element der Map abzufragen, prüfen ich vorher mit myMap.find(&quot;xy&quot;) ob dieses Element überhaupt existiert, und lasse mir dann mittels myMap(&quot;xy&quot;) den Wert ausgeben.</p>
<p>Somit muss die Map bei Vorhandensein zweimal durchsucht werden, obwohl ich die Position doch eigentlich beim find() schon habe.</p>
<p>Ist es möglich den Inhalt eines Map-Containers auch direkt über den Iterator abzufragen?</p>
<p>Gruß<br />
Thomas</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461071</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461071</guid><dc:creator><![CDATA[Thomas_123]]></dc:creator><pubDate>Fri, 22 Feb 2008 16:22:57 GMT</pubDate></item><item><title><![CDATA[Reply to std::map Zugriff auf Element über Iterator? on Fri, 22 Feb 2008 16:35:20 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<pre><code class="language-cpp">map&lt;string, int&gt;::iterator it = myMap.find(&quot;xy&quot;);
if( it != myMap.end())
  int test = it-&gt;second;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1461078</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461078</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Fri, 22 Feb 2008 16:35:20 GMT</pubDate></item><item><title><![CDATA[Reply to std::map Zugriff auf Element über Iterator? on Fri, 22 Feb 2008 16:48:26 GMT]]></title><description><![CDATA[<p>Alles klar, Danke!<br />
Sieht nur etwas putzig aus wenn man eine Struktur o.Ä. als Elemente der Map hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461089</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461089</guid><dc:creator><![CDATA[Thomas_123]]></dc:creator><pubDate>Fri, 22 Feb 2008 16:48:26 GMT</pubDate></item><item><title><![CDATA[Reply to std::map Zugriff auf Element über Iterator? on Fri, 22 Feb 2008 18:27:38 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">map&lt;string, struktur&gt;::iterator it = myMap.find(&quot;xy&quot;);
if( it != myMap.end()) {
  struktur&amp; elem = it-&gt;second;
  int test = elem.member();
  // ...
}
</code></pre>
<p>Und schon ist's nicht mehr putzig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461161</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461161</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Fri, 22 Feb 2008 18:27:38 GMT</pubDate></item></channel></rss>