<?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[Element aus Container löschen]]></title><description><![CDATA[<p>Servus,</p>
<p>ich finde kein Äquivalent zu Javas mylist.remove( thisstring );<br />
Wie wird das in C++ effizient gemacht - muss ich da erst einen Iterator und den Index holen und dann mit erase das Objekt zum Index löschen?</p>
<p>Vielen Dank falls jemand ein Codesnippet oder einen Link hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/282332/element-aus-container-löschen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 08:56:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/282332.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 18 Feb 2011 08:27:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Element aus Container löschen on Fri, 18 Feb 2011 08:27:30 GMT]]></title><description><![CDATA[<p>Servus,</p>
<p>ich finde kein Äquivalent zu Javas mylist.remove( thisstring );<br />
Wie wird das in C++ effizient gemacht - muss ich da erst einen Iterator und den Index holen und dann mit erase das Objekt zum Index löschen?</p>
<p>Vielen Dank falls jemand ein Codesnippet oder einen Link hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2022595</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2022595</guid><dc:creator><![CDATA[Jay1980]]></dc:creator><pubDate>Fri, 18 Feb 2011 08:27:30 GMT</pubDate></item><item><title><![CDATA[Reply to Element aus Container löschen on Fri, 18 Feb 2011 08:31:45 GMT]]></title><description><![CDATA[<p>Hallo Jay1980,</p>
<p>der Link sollte dein Vorhaben lösen.<br />
<a href="http://en.wikipedia.org/wiki/Erase-remove_idiom" rel="nofollow">http://en.wikipedia.org/wiki/Erase-remove_idiom</a></p>
<p>so long,<br />
Chris</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2022598</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2022598</guid><dc:creator><![CDATA[pchris]]></dc:creator><pubDate>Fri, 18 Feb 2011 08:31:45 GMT</pubDate></item><item><title><![CDATA[Reply to Element aus Container löschen on Fri, 18 Feb 2011 08:32:40 GMT]]></title><description><![CDATA[<p>Mit <code>erase()</code> , siehe <a href="http://www.cplusplus.com" rel="nofollow">www.cplusplus.com</a>.</p>
<p>Ja, dazu brauchst du einen Iterator, den du dir mit <code>std::find()</code> suchen kannst. Bei mehreren Vorkommen kannst du auch <code>std::remove()</code> anwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2022600</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2022600</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 18 Feb 2011 08:32:40 GMT</pubDate></item><item><title><![CDATA[Reply to Element aus Container löschen on Fri, 18 Feb 2011 08:32:56 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Was für eine Liste ist das denn? std::list<a href="std::string" rel="nofollow">std::string</a>?<br />
Du must den string logischerweise erst finden bevor du ihn löschen kannst. Er könnte schließlich auch mehrfach vorkommen.<br />
Es gibt dafür find, erase und remove. Das kann man alles schön kombinieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2022601</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2022601</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Fri, 18 Feb 2011 08:32:56 GMT</pubDate></item><item><title><![CDATA[Reply to Element aus Container löschen on Fri, 18 Feb 2011 08:34:10 GMT]]></title><description><![CDATA[<p>Ah so gings:<br />
remove( mylist.begin(), mylist.end(), mystring );</p>
<p>Oh, ich las die ganzen vorherigen schnellen Antworten nicht, bevor ich dies postete - was ist von meinem Ansatz zu halten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2022602</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2022602</guid><dc:creator><![CDATA[Jay1980]]></dc:creator><pubDate>Fri, 18 Feb 2011 08:34:10 GMT</pubDate></item><item><title><![CDATA[Reply to Element aus Container löschen on Fri, 18 Feb 2011 08:33:52 GMT]]></title><description><![CDATA[<p>Jay1980 schrieb:</p>
<blockquote>
<p>Ah so gings:<br />
remove( mylist.begin(), mylist.end(), mystring );</p>
</blockquote>
<p>Nein, das entfernt <code>mystring</code> nicht aus dem Container. Schau dir pchris' Link an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2022603</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2022603</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 18 Feb 2011 08:33:52 GMT</pubDate></item><item><title><![CDATA[Reply to Element aus Container löschen on Fri, 18 Feb 2011 11:37:53 GMT]]></title><description><![CDATA[<p>Jay1980 schrieb:</p>
<blockquote>
<p>ich finde kein Äquivalent zu Javas mylist.remove( thisstring );</p>
</blockquote>
<p>Doch, das funktioniert genau so auch in C++ (TR1? C++0x?)</p>
<pre><code>std::list&lt;std::string&gt; mylist = { &quot;dum&quot;, &quot;di&quot;, &quot;dum&quot; };
std::cout &lt;&lt; mylist.size() &lt;&lt; std::endl;
mylist.remove(&quot;dum&quot;);
std::cout &lt;&lt; mylist.size() &lt;&lt; std::endl;
</code></pre>
<p>Die Konsolenausgabe:</p>
<pre><code>3
1
</code></pre>
<p>mfg, NRWsoft</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2022687</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2022687</guid><dc:creator><![CDATA[NRWsoft]]></dc:creator><pubDate>Fri, 18 Feb 2011 11:37:53 GMT</pubDate></item><item><title><![CDATA[Reply to Element aus Container löschen on Fri, 18 Feb 2011 11:39:14 GMT]]></title><description><![CDATA[<p>Stimmt, <code>std::list</code> hat ja hier eine Spezialbehandlung, die ich immer vergesse. Guter Hinweis! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p><code>std::list::remove()</code> existiert schon in C++98.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2022689</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2022689</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 18 Feb 2011 11:39:14 GMT</pubDate></item></channel></rss>