<?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[Fragen zum std::sort]]></title><description><![CDATA[<p>Hallo allerseits,</p>
<p>Ich hätte ne kleine Frage zum Sortier Algorithmus. Dazu muss ich leider etwas weiter ausholen, man verziehe mir <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>Ich habe hier eine Methode die ein Bild und eine Zahl übergeben bekommt. Desweiteren habe ich zwei typedefs:</p>
<pre><code>typedef std::pair&lt;int,int&gt; Paar;
typedef std::vector&lt;Paar&gt; PaarListe
</code></pre>
<p>In der Klasse, die das Bild beschreibt, gibt es eine Methode, die mir einen bestimmten Wert aus 2 Pixeln (x,y) berechnet.<br />
Ich soll nun eine Liste von Paaren zückgebene, sortiert nach den höchsten Werten die ich berechnet habe durch die Funktion aus der Bildklasse.</p>
<p>Mein problem ist jetzt, das ich einen Vektor habe der gefüllt ist, mit den Koordinatenpaare (x,y),</p>
<p>Jetzt möchte ich gerne diesen Vector sortieren. Da hab ich mir gedacht, das ich am besten den sort Algorithmus aus der stl verwendetn würde. Nur leider hab ich keine Ahnung wie ich den so bauen kann, das er mir für die beiden Werte aus dem Paar einen Wert berechnet und danach sortiert.</p>
<p>Hat jemand von euch nen Denkanstoß? Wer fragen hat immer her damit, ist etwas schwierig zu erklären ich hoffe man kann es verstehen <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>Gruß<br />
cartel</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/313233/fragen-zum-std-sort</link><generator>RSS for Node</generator><lastBuildDate>Sun, 02 Aug 2026 07:50:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/313233.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 Jan 2013 16:53:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 16:53:06 GMT]]></title><description><![CDATA[<p>Hallo allerseits,</p>
<p>Ich hätte ne kleine Frage zum Sortier Algorithmus. Dazu muss ich leider etwas weiter ausholen, man verziehe mir <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>Ich habe hier eine Methode die ein Bild und eine Zahl übergeben bekommt. Desweiteren habe ich zwei typedefs:</p>
<pre><code>typedef std::pair&lt;int,int&gt; Paar;
typedef std::vector&lt;Paar&gt; PaarListe
</code></pre>
<p>In der Klasse, die das Bild beschreibt, gibt es eine Methode, die mir einen bestimmten Wert aus 2 Pixeln (x,y) berechnet.<br />
Ich soll nun eine Liste von Paaren zückgebene, sortiert nach den höchsten Werten die ich berechnet habe durch die Funktion aus der Bildklasse.</p>
<p>Mein problem ist jetzt, das ich einen Vektor habe der gefüllt ist, mit den Koordinatenpaare (x,y),</p>
<p>Jetzt möchte ich gerne diesen Vector sortieren. Da hab ich mir gedacht, das ich am besten den sort Algorithmus aus der stl verwendetn würde. Nur leider hab ich keine Ahnung wie ich den so bauen kann, das er mir für die beiden Werte aus dem Paar einen Wert berechnet und danach sortiert.</p>
<p>Hat jemand von euch nen Denkanstoß? Wer fragen hat immer her damit, ist etwas schwierig zu erklären ich hoffe man kann es verstehen <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>Gruß<br />
cartel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293071</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293071</guid><dc:creator><![CDATA[cartel]]></dc:creator><pubDate>Thu, 24 Jan 2013 16:53:06 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:04:58 GMT]]></title><description><![CDATA[<pre><code>sort(PaarListe.begin(),PaarListe.end(),[=](Paar a,Paar b){return bild.getPixelWert(a.first,a,second)&gt;bild.getPixelWert(b.first,b.second);});//ungetestet
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2293074</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293074</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:04:58 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:17:38 GMT]]></title><description><![CDATA[<p>Es gibt doch schon einen <code>operator&lt;()</code> für Paar, aka <code>std::pair&lt;int,int&gt;</code> .<br />
Sortier doch einfach: wird erst nach x geordnet, bzw. bei gleichem x nach y.</p>
<p>Ist das nicht sinnvoll?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293080</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:17:38 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:24:03 GMT]]></title><description><![CDATA[<p>Furble Wurble schrieb:</p>
<blockquote>
<p>Es gibt doch schon einen <code>operator&lt;()</code> für Paar, aka <code>std::pair&lt;int,int&gt;</code> .<br />
Sortier doch einfach: wird erst nach x geordnet, bzw. bei gleichem x nach y.</p>
<p>Ist das nicht sinnvoll?</p>
</blockquote>
<p>Hey,<br />
Danke für deine Hilfe. Ja das Problem ist, das ich nicht die Paare sortieren muss, sondern ich hab eine Funktion die bekommt die beiden Werte von einem paar übergeben und berechnet daraus einen Wert. Und nun habe ich 640*840 solcher Paar und dementsprechend viele werte und soll dann die Paare nach ihrem &quot;Wert&quot; sortieren.<br />
Ich hab es jetzzt auch mal so probiert wievolkard beschrieben hat, leider bekomm ich einen Bildschirm voll compilerfehler die ich nicht interpretieren kann <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>// Edit:<br />
So jetzt compiliert er es mir <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="🙂"
    /> Nur bekomm ich beim ausführen einen Segmentation Fault <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293082</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293082</guid><dc:creator><![CDATA[cartel]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:24:03 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:25:09 GMT]]></title><description><![CDATA[<p>cartel schrieb:</p>
<blockquote>
<p>Ich hab es jetzzt auch mal so probiert wievolkard beschrieben hat, leider bekomm ich einen Bildschirm voll compilerfehler die ich nicht interpretieren kann <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
</blockquote>
<p>Dein Compiler versteht vermutlich kein C++11. Wahrscheinlich könnte er schon, du musst es bloß einschalten. Beim GCC geht das zum Beispiel mit der Option -std=c++11 (oder -std=c++0x bei älteren Versionen).</p>
<p>cartel schrieb:</p>
<blockquote>
<p>// Edit:<br />
So jetzt compiliert er es mir <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="🙂"
    /> Nur bekomm ich beim ausführen einen Segmentation Fault <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
</blockquote>
<p>Das liegt an irgendetwas, was du uns noch nicht gezeigt hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293084</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293084</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:25:09 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:25:59 GMT]]></title><description><![CDATA[<p>cartel schrieb:</p>
<blockquote>
<p>Furble Wurble schrieb:</p>
<blockquote>
<p>Es gibt doch schon einen <code>operator&lt;()</code> für Paar, aka <code>std::pair&lt;int,int&gt;</code> .<br />
Sortier doch einfach: wird erst nach x geordnet, bzw. bei gleichem x nach y.</p>
<p>Ist das nicht sinnvoll?</p>
</blockquote>
<p>Hey,<br />
Danke für deine Hilfe. Ja das Problem ist, das ich nicht die Paare sortieren muss, sondern ich hab eine Funktion die bekommt die beiden Werte von einem paar übergeben und berechnet daraus einen Wert. Und nun habe ich 640*840 solcher Paar und dementsprechend viele werte und soll dann die Paare nach ihrem &quot;Wert&quot; sortieren.<br />
Ich hab es jetzzt auch mal so probiert wievolkard beschrieben hat, leider bekomm ich einen Bildschirm voll compilerfehler die ich nicht interpretieren kann <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>// Edit:<br />
So jetzt compiliert er es mir <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="🙂"
    /> Nur bekomm ich beim ausführen einen Segmentation Fault <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
</blockquote>
<p>Du hast nur 640*480.<br />
Hast Du wirklich 840 im Code stehen, wird's vielleicht deswegen nicht klappen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293085</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293085</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:25:59 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:32:39 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>cartel schrieb:</p>
<blockquote>
<p>Furble Wurble schrieb:</p>
<blockquote>
<p>Es gibt doch schon einen <code>operator&lt;()</code> für Paar, aka <code>std::pair&lt;int,int&gt;</code> .<br />
Sortier doch einfach: wird erst nach x geordnet, bzw. bei gleichem x nach y.</p>
<p>Ist das nicht sinnvoll?</p>
</blockquote>
<p>Hey,<br />
Danke für deine Hilfe. Ja das Problem ist, das ich nicht die Paare sortieren muss, sondern ich hab eine Funktion die bekommt die beiden Werte von einem paar übergeben und berechnet daraus einen Wert. Und nun habe ich 640*840 solcher Paar und dementsprechend viele werte und soll dann die Paare nach ihrem &quot;Wert&quot; sortieren.<br />
Ich hab es jetzzt auch mal so probiert wievolkard beschrieben hat, leider bekomm ich einen Bildschirm voll compilerfehler die ich nicht interpretieren kann <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>// Edit:<br />
So jetzt compiliert er es mir <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="🙂"
    /> Nur bekomm ich beim ausführen einen Segmentation Fault <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
</blockquote>
<p>Du hast nur 640*480.<br />
Hast Du wirklich 840 im Code stehen, wird's vielleicht deswegen nicht klappen.</p>
</blockquote>
<p>Hab ich auch zuerst gedacht. Zum glück ist mein Code recht übersichtlich: ich kann ihn ja mal posten:</p>
<pre><code>PaarListe
holeBestePaar(const Image &amp;bild, int num)
{
    	PaarListe paare;
	paare.resize(bild.getWidth()*bild.getHeight());

	for(int i = 0; i &lt; bild.getWidth(); i++) {
	 for(int j = 0;j &lt; bild.getHeight(); j++) {
	 	Paar f;
		f.first = i;
		f.second = j;
		paare.push_back(f);
	 }
	}

	sort(paare.begin(),paare.end(),[=](Paar a,Paar b){return bild.getPixel(a.first,a.second)&gt;bild.getPixel(b.first,b.second);});

    return paare;
}
</code></pre>
<p>Ich hab irgendwie das Gefühl das es daran liegt, wie ich meinen Vector fülle. Ist es richtig die Größe vorher anzugeben? Ich habs auch mal ohne probiert und hatte auch 480*640 Elemente drin. Demnach müsste dies stimmen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293087</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293087</guid><dc:creator><![CDATA[cartel]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:32:39 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:37:17 GMT]]></title><description><![CDATA[<p>kackt</p>
<pre><code>PaarListe
holeBestePaar(const Image &amp;bild, int num)
{
    cout&lt;&lt;&quot;nu kackt er ab&quot;&lt;&lt;endl;
    	PaarListe paare;
//	paare.resize(bild.getWidth()*bild.getHeight());

	for(int i = 0; i &lt; bild.getWidth(); i++) {
	 for(int j = 0;j &lt; bild.getHeight(); j++) {
                bild.getPixel(i,j);
	 }
	}
    cout&lt;&lt;&quot;doch nicht abgekackt&quot;&lt;&lt;endl;

    return paare;
}
</code></pre>
<p>auch ab?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293089</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293089</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:37:17 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:40:59 GMT]]></title><description><![CDATA[<p>cartel schrieb:</p>
<blockquote>
<p>Ich hab irgendwie das Gefühl das es daran liegt, wie ich meinen Vector fülle. Ist es richtig die Größe vorher anzugeben? Ich habs auch mal ohne probiert und hatte auch 480*640 Elemente drin. Demnach müsste dies stimmen</p>
</blockquote>
<p>Treffer.<br />
reserve statt resize nehmen!<br />
Aber deshalb ein segfault? Den Grund sehe ich noch nicht. Hättest nur 640*480 Stück von 0|0-Paaren rumgammeln.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293090</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293090</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:40:59 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:39:07 GMT]]></title><description><![CDATA[<p>cartel schrieb:</p>
<blockquote>
<p>Ich hab irgendwie das Gefühl das es daran liegt, wie ich meinen Vector fülle. Ist es richtig die Größe vorher anzugeben? Ich habs auch mal ohne probiert und hatte auch 480*640 Elemente drin. Demnach müsste dies stimmen</p>
</blockquote>
<p>Größe vorher angeben ist gut, aber bitte mit <code>reserve()</code> und nicht mit <code>resize()</code> .</p>
<p>cartel schrieb:</p>
<blockquote>
<p>Furble Wurble schrieb:</p>
<blockquote>
<p>Es gibt doch schon einen <code>operator&lt;()</code> für Paar, aka <code>std::pair&lt;int,int&gt;</code> .<br />
Sortier doch einfach: wird erst nach x geordnet, bzw. bei gleichem x nach y.</p>
</blockquote>
<p>Danke für deine Hilfe. Ja das Problem ist, das ich nicht die Paare sortieren muss, sondern ich hab eine Funktion die bekommt die beiden Werte von einem paar übergeben und berechnet daraus einen Wert.</p>
</blockquote>
<p>Mein Fehler...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293091</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:39:07 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:43:40 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>kackt</p>
<pre><code>PaarListe
holeBestePaar(const Image &amp;bild, int num)
{
    cout&lt;&lt;&quot;nu kackt er ab&quot;&lt;&lt;endl;
    	PaarListe paare;
//	paare.resize(bild.getWidth()*bild.getHeight());

	for(int i = 0; i &lt; bild.getWidth(); i++) {
	 for(int j = 0;j &lt; bild.getHeight(); j++) {
                bild.getPixel(i,j);
	 }
	}
    cout&lt;&lt;&quot;doch nicht abgekackt&quot;&lt;&lt;endl;

    return paare;
}
</code></pre>
<p>auch ab?</p>
</blockquote>
<p>So das hab ich mal ausprobiert und dies läuft problemlos durch. Da macht er keine faxen <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="🙂"
    /><br />
Hab jetzt mal reserver genommen. Wie genau kann man sich denn bei den beiden Methoden den Unterschied vorstellen? So rein interessehalber <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /></p>
<p>der Sig Fault unterläuft mir immer noch. Wenn ich die Zeile mit dem sortieren rausnehmen, läuft alles durch habe ich grade gemerkt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293092</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293092</guid><dc:creator><![CDATA[cartel]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:43:40 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:49:22 GMT]]></title><description><![CDATA[<p>reserve reserviert nur speicher, tut aber noch keine Paare rein.<br />
resize tut Paare rein. und nachher tust dz mit push_back nochmal Paare rein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293093</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293093</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:49:22 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:50:40 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>reserve reserviert nur speicher, tut aber noch keine Paare rein.<br />
resize tut Paare rein. und nachher tust dz mit push_back nochmal Paare rein.</p>
</blockquote>
<p>Ah ok. Macht sinn, sehr gut zu wissen <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>
]]></description><link>https://www.c-plusplus.net/forum/post/2293094</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293094</guid><dc:creator><![CDATA[cartel]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:50:40 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:55:19 GMT]]></title><description><![CDATA[<p>cartel schrieb:</p>
<blockquote>
<p>der Sig Fault unterläuft mir immer noch. Wenn ich die Zeile mit dem sortieren rausnehmen, läuft alles durch habe ich grade gemerkt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
</blockquote>
<p>die Klasse <code>bild</code> ist über alle Zweifel erhaben? Kopieren usw. macht alles keine Probleme(tm), <code>getPixel</code> ist <code>const</code> ?<br />
Versuch mal ein capture per Referenz, also <code>[&amp;bild]</code> statt <code>[=]</code> in dem Lambda.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293095</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293095</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:55:19 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 17:56:46 GMT]]></title><description><![CDATA[<p>Mein Fehler.<br />
[&amp;] statt [=]<br />
<a href="http://www.cprogramming.com/c++11/c++11-lambda-closures.html" rel="nofollow">http://www.cprogramming.com/c++11/c++11-lambda-closures.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293096</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293096</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 24 Jan 2013 17:56:46 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 18:00:30 GMT]]></title><description><![CDATA[<p>Zeig mal die Member der Bildklasse; die Funktionen getPixel, getWidth, getHeight; sowie eventuelle spezielle Memberfunktionen (Konstruktoren, Destruktor, Zuweisungsoperator), sofern vorhanden. Außerdem den Aufruf von holeBestePaar, inklusive allem was für die Erstellung des Bildobjektes relevant ist, auf dem die Funktion arbeitet.</p>
<p>volkard schrieb:</p>
<blockquote>
<p>Mein Fehler.<br />
[&amp;] statt [=]<br />
<a href="http://www.cprogramming.com/c++11/c++11-lambda-closures.html" rel="nofollow">http://www.cprogramming.com/c++11/c++11-lambda-closures.html</a></p>
</blockquote>
<p>Das sollte aber doch bei einer Bildklasse mit sinnvoll definiertem Kopierkonstruktor trotzdem funktionieren, bloß elend langsam.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293098</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293098</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 24 Jan 2013 18:00:30 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 18:11:34 GMT]]></title><description><![CDATA[<p>Ich würde sagen:<br />
Der Konstruktor hat new[] drin.<br />
Der Destruktor hat delete[] drin.<br />
Kopierkonstruktor und Zuweisungsoperator fehlen.<br />
Verstoß gegen <a href="http://de.wikipedia.org/wiki/Dreierregel_(C%2B%2B)" rel="nofollow">http://de.wikipedia.org/wiki/Dreierregel_(C%2B%2B)</a></p>
<p>Beste Lösung vermutlich: Kopierkonstruktor und Zuweisungsoperator private machen oder besser mit =delete wegmachen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293101</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293101</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 24 Jan 2013 18:11:34 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 18:17:09 GMT]]></title><description><![CDATA[<p>Hey,</p>
<p>Also das mit dem [&amp;bild] hat jetzt funktioniert. Was bedeutet denn genau dieses &quot;lambda&quot;. Die Bildklasse hab ich leider nicht selbst geschrieben und darf sie leider auch nicht verändern (kennt der ein oder anderen hier bestimmt <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>
<p>Euch zwei vieelen Dank für die schnelle Hilfe. Hat mich echt sehr viel weiter gebracht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293105</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293105</guid><dc:creator><![CDATA[cartel]]></dc:creator><pubDate>Thu, 24 Jan 2013 18:17:09 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 18:22:47 GMT]]></title><description><![CDATA[<p>Jetzt vermute ich mal ganz frech, daß Du kein C++11 in der Lösung verwenden darfst. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293106</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293106</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 24 Jan 2013 18:22:47 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 18:26:49 GMT]]></title><description><![CDATA[<p>Zum Glück darf ich in der Lösung c++11 verwenden. Müssen wir sogar, da wir noch mit Threads arbeiten sollen und es da ein Interface dazu gibt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
Einmal glück gehabt, aber hätte gut sein können, du scheinst dich auszukennen <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>
<p>Mal so interessehalber, wie wäre man ohne c++11 weitergekommen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293110</guid><dc:creator><![CDATA[cartel]]></dc:creator><pubDate>Thu, 24 Jan 2013 18:26:49 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 18:42:20 GMT]]></title><description><![CDATA[<p>cartel schrieb:</p>
<blockquote>
<p>Mal so interessehalber, wie wäre man ohne c++11 weitergekommen?</p>
</blockquote>
<p>Z.B. ein Funktionsobjekt basteln:</p>
<pre><code class="language-cpp">struct compare_by_pixelvalue{
  typedef Paar first_argument_type;
  typedef Paar second_argument_type;
  typedef bool result_type;
  const bild* b;
  compare_by_pixelvalue(const bild&amp; b) : b(&amp;b){}
  bool operator()(const Paar&amp; x, const Paar&amp; y) const {
    return b-&gt;getPixel(x.first, x.second) &lt; b-&gt;getPixel(y.first, y.second);
  }
};

void f(){
  bild b; 
  PaarListe paare;
  // ....
  std::sort(paare.begin(), paare.end(), compare_by_pixelvalue(b));
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2293116</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293116</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Thu, 24 Jan 2013 18:42:20 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 18:55:59 GMT]]></title><description><![CDATA[<p>Ich würde die typedefs noch weglassen und das Bild als const&amp; halten.<br />
Kommt da einegntlich das selbe Compilat raus? Also werden lamdas geinlined?<br />
übrigens &gt; statt &lt;, denke, er wollte die größten Werte vorne.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293126</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293126</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 24 Jan 2013 18:55:59 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 19:35:57 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>Ich würde die typedefs noch weglassen und das Bild als const&amp; halten.<br />
[...]<br />
übrigens &gt; statt &lt;, denke, er wollte die größten Werte vorne.</p>
</blockquote>
<p>Danke für die nette Vorlage...<br />
Jetzt kommt die große Stunde der typedefs <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>
<pre><code class="language-cpp">std::sort(paare.begin(), paare.end(), std::not2(compare_by_pixelvalue(b)));
</code></pre>
<p>Referenzen als Member sind wohl nicht ganz unumstritten. Und da ich mir keinen Zacken aus der Krone breche und die Standardbibliothek es auch so macht bin ich jetzt in der Pointer-Member Fraktion...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293150</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293150</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Thu, 24 Jan 2013 19:35:57 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Thu, 24 Jan 2013 20:20:50 GMT]]></title><description><![CDATA[<p>Furble Wurble schrieb:</p>
<blockquote>
<p>volkard schrieb:</p>
<blockquote>
<p>Ich würde die typedefs noch weglassen und das Bild als const&amp; halten.<br />
[...]<br />
übrigens &gt; statt &lt;, denke, er wollte die größten Werte vorne.</p>
</blockquote>
<p>Danke für die nette Vorlage...<br />
Jetzt kommt die große Stunde der typedefs <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>
<pre><code class="language-cpp">std::sort(paare.begin(), paare.end(), std::not2(compare_by_pixelvalue(b)));
</code></pre>
</blockquote>
<p>Ist das noch eine &quot;Strict weak ordering&quot;?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293169</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293169</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 24 Jan 2013 20:20:50 GMT</pubDate></item><item><title><![CDATA[Reply to Fragen zum std::sort on Fri, 25 Jan 2013 00:06:19 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>Ich würde die typedefs noch weglassen und das Bild als const&amp; halten.</p>
</blockquote>
<p>Würdest du den Funktor dann auch non-assignable machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2293226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2293226</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Fri, 25 Jan 2013 00:06:19 GMT</pubDate></item></channel></rss>