<?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[Struct Vektor durchsuchen]]></title><description><![CDATA[<p>Tagchen,</p>
<p>wie man im Titel wohl erkennen kann, möchte ich einen Struct Vektor durchsuchen, das Problem dabei ist das ich keine Ahnung habe wie ich das anstellen soll...</p>
<p>Ich habe schon viele Antworten im Internet gefunden, dort wird gesagt ich müsste mir eine eigene Funktion schreiben die das suchen für mich übernimmt, leider waren die Erklärungen nicht ausreichend, sodass ich es nicht wirklich vestanden habe. (Anfänger und so ._.)</p>
<p>Wäre vielleicht jemand so nett mir zu erklären wie ich das ganze anstelle?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/317042/struct-vektor-durchsuchen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Jul 2026 10:31:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/317042.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 May 2013 11:03:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 11:03:25 GMT]]></title><description><![CDATA[<p>Tagchen,</p>
<p>wie man im Titel wohl erkennen kann, möchte ich einen Struct Vektor durchsuchen, das Problem dabei ist das ich keine Ahnung habe wie ich das anstellen soll...</p>
<p>Ich habe schon viele Antworten im Internet gefunden, dort wird gesagt ich müsste mir eine eigene Funktion schreiben die das suchen für mich übernimmt, leider waren die Erklärungen nicht ausreichend, sodass ich es nicht wirklich vestanden habe. (Anfänger und so ._.)</p>
<p>Wäre vielleicht jemand so nett mir zu erklären wie ich das ganze anstelle?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2325993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2325993</guid><dc:creator><![CDATA[djeurissen]]></dc:creator><pubDate>Sat, 25 May 2013 11:03:25 GMT</pubDate></item><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 11:10:19 GMT]]></title><description><![CDATA[<p>Sag doch erstmal was du suchen möchtest.</p>
<p>Hast du einen vector mit einfachen Werten und suchst die Position an der der Wert x eingefügt wurde?<br />
Oder hast du einen vector mit Personendaten und suchst den Eintrag von Heinz Müller um sein Geburtsdatum nachzuschlagen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2325998</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2325998</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Sat, 25 May 2013 11:10:19 GMT</pubDate></item><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 11:17:10 GMT]]></title><description><![CDATA[<p>Was ist ein Struct Vektor?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2326001</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2326001</guid><dc:creator><![CDATA[out]]></dc:creator><pubDate>Sat, 25 May 2013 11:17:10 GMT</pubDate></item><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 11:31:10 GMT]]></title><description><![CDATA[<p>Ich habe eben einen Struct und in diesem struct sind 3 Datentypen (2x int, 1x bool).<br />
Nun möchte ich den Vektor durchsuchen und prüfen ob es einen integer(nennen wir ihn mal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f635.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--dizzy_face"
      title="X)"
      alt="😵"
    /> mit dem Wert 15 gibt, wenn ja dann möchte ich die Position des Structs mit dem Integer X zurückbekommen.<br />
Ich möchte eben prüfen ob ein Struct bestimmte Werte hat und dann dessen Position zurückbekommen.</p>
<p>Edit: Es kann zudem sein das es mehrere integer mit dem Wert 15 gibt, sobald ich eben einen Struct mit dem Wert 15 gefunden habe, prüfe ich noch die anderen Datentypen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2326003</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2326003</guid><dc:creator><![CDATA[djeurissen]]></dc:creator><pubDate>Sat, 25 May 2013 11:31:10 GMT</pubDate></item><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 11:34:56 GMT]]></title><description><![CDATA[<p>Unter Verwendung von <code>auto</code> (C++11), Lambda-Ausdrücken (C++11) und <code>std::find_if()</code> -- schlage wenn nötig auf <a href="http://www.cppreference.com" rel="nofollow">www.cppreference.com</a> nach:</p>
<pre><code>struct X
{
    int i,j;
    bool b;
};

std::vector&lt;X&gt; xs;
auto itr = std::find_if(xs.begin(), xs.end(), [] (X x) { return x.i == 15; });
</code></pre>
<p>Du kannst natürlich auch eine einfache Schleife schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2326007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2326007</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sat, 25 May 2013 11:34:56 GMT</pubDate></item><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 11:42:09 GMT]]></title><description><![CDATA[<p>So geht's:</p>
<p><a href="http://ideone.com/Tr1DTb" rel="nofollow">http://ideone.com/Tr1DTb</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2326010</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2326010</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Sat, 25 May 2013 11:42:09 GMT</pubDate></item><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 11:48:22 GMT]]></title><description><![CDATA[<p>Ethon schrieb:</p>
<blockquote>
<p>So geht's:</p>
<p>[von Ideone]</p>
<pre><code>// Den Vergleichsoperator implementieren damit ein Wert mit einer Zahl
    // verglichen werden kann.
    bool operator==(int zahl)
    {
        return zahl1 == zahl;
    }
</code></pre>
</blockquote>
<p>Der <code>operator==</code> ist ein ziemlicher Hack, der nur für diese Suche nützlich ist. Wir wollen gar nicht Gleichheit, sondern nach einem bestimmten Kriterium suchen.</p>
<p>Genau deshalb gibts <code>std::find_if()</code> . Wenn der Fall mehrmals auftritt, kann man statt eines Lambda-Ausdrucks auch eine Funktion bzw. einen Funktor schreiben...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2326013</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2326013</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sat, 25 May 2013 11:48:22 GMT</pubDate></item><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 12:38:00 GMT]]></title><description><![CDATA[<p>Also irgendwas mache ich falsch ich bekomme immer wieder C:\Dokumente und<br />
&quot;'itr' does not name a type&quot; zurück, aber alles ist gleich, mal abgesehen vom Namen des Vektors...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2326034</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2326034</guid><dc:creator><![CDATA[djeurissen]]></dc:creator><pubDate>Sat, 25 May 2013 12:38:00 GMT</pubDate></item><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 12:41:58 GMT]]></title><description><![CDATA[<p>Ja, dein Compiler kann wohl kein C++11.<br />
Musst du entweder aktivieren (Compilerabhängig, welchen hast du?) oder &quot;altes&quot; C++ verwenden:</p>
<pre><code>bool i_is_15(your_struct x)
{return x.i == 15;}
...
std::vector&lt;your_struct&gt;::iterator iter = std::find_if(vec.begin(), vec.end(), i_is_15);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2326036</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2326036</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sat, 25 May 2013 12:41:58 GMT</pubDate></item><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 12:44:01 GMT]]></title><description><![CDATA[<p>Ich benutze Codeblocks als Compiler, vielleicht kennt den ja jemand XD...<br />
Wie kann ich dort den C++11 aktzivieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2326039</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2326039</guid><dc:creator><![CDATA[djeurissen]]></dc:creator><pubDate>Sat, 25 May 2013 12:44:01 GMT</pubDate></item><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 12:49:18 GMT]]></title><description><![CDATA[<p>djeurissen schrieb:</p>
<blockquote>
<p>Ich benutze Codeblocks als Compiler, vielleicht kennt den ja jemand XD...<br />
Wie kann ich dort den C++11 aktzivieren?</p>
</blockquote>
<p>Rechtsklick auf das Projekt -&gt; Properties -&gt; Project Build Options -&gt; Unter Compilerflags &quot;Have g++ following the comming C++0x ...&quot; auswählen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2326042</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2326042</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Sat, 25 May 2013 12:49:18 GMT</pubDate></item><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 12:55:19 GMT]]></title><description><![CDATA[<p>Bzw. für C++11 ein neues Flag mit <code>-std=c++11</code> erstellen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2326044</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2326044</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sat, 25 May 2013 12:55:19 GMT</pubDate></item><item><title><![CDATA[Reply to Struct Vektor durchsuchen on Sat, 25 May 2013 13:33:02 GMT]]></title><description><![CDATA[<p>Codeblocks ist übrigens eine IDE, der Compiler ist der gcc. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2326058</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2326058</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sat, 25 May 2013 13:33:02 GMT</pubDate></item></channel></rss>