<?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[map::lower_bound]]></title><description><![CDATA[<p>Hi,</p>
<p>ich komme mit der 'set/map::lower_bound'-Funktion nicht klar (wohlgemerkt: *keine* 'multimap'). Der Standard sagt (in den Associative Container requirements):</p>
<blockquote>
<p>returns an iterator pointing to the first element with key not less than <code>k</code></p>
</blockquote>
<p>In meinen Augen ergibt das aber keinen großen Sinn, oder der Name ist schlecht gewählt, denn angenommen ich habe ein 'set&lt;int&gt;' mit den Elementen 1, 2, 3, 5. Dann müsste mir 'lower_bound(4)' ja 5 liefern. Das ist aber definitiv *keine* untere Schranke für 4.</p>
<p>Übersehe ich etwas? (Ich hab's auch getestet, und erhalte das vorhergesagte Ergebnis.)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/202361/map-lower_bound</link><generator>RSS for Node</generator><lastBuildDate>Tue, 06 Oct 2026 16:58:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/202361.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 Jan 2008 16:19:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to map::lower_bound on Thu, 10 Jan 2008 16:19:30 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich komme mit der 'set/map::lower_bound'-Funktion nicht klar (wohlgemerkt: *keine* 'multimap'). Der Standard sagt (in den Associative Container requirements):</p>
<blockquote>
<p>returns an iterator pointing to the first element with key not less than <code>k</code></p>
</blockquote>
<p>In meinen Augen ergibt das aber keinen großen Sinn, oder der Name ist schlecht gewählt, denn angenommen ich habe ein 'set&lt;int&gt;' mit den Elementen 1, 2, 3, 5. Dann müsste mir 'lower_bound(4)' ja 5 liefern. Das ist aber definitiv *keine* untere Schranke für 4.</p>
<p>Übersehe ich etwas? (Ich hab's auch getestet, und erhalte das vorhergesagte Ergebnis.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434421</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434421</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Thu, 10 Jan 2008 16:19:30 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Thu, 10 Jan 2008 16:29:22 GMT]]></title><description><![CDATA[<p>? Verstehe nicht was du willst. Er gibt dir doch das zurück was der Standard vorschreibt. Kannst doch jetzt das zu hohe Element löschen ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434433</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434433</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Thu, 10 Jan 2008 16:29:22 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Thu, 10 Jan 2008 16:30:39 GMT]]></title><description><![CDATA[<p>(D)Evil schrieb:</p>
<blockquote>
<p>? Verstehe nicht was du willst. Er gibt dir doch das zurück was der Standard vorschreibt.</p>
</blockquote>
<p>Ja, aber die Rückgabe ist dumm. Eine untere Schranke ist was anderes.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434434</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434434</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Thu, 10 Jan 2008 16:30:39 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Thu, 10 Jan 2008 16:32:44 GMT]]></title><description><![CDATA[<p>Vielleicht mal die Erklärung, wieso mich das interessiert:</p>
<p>Ich baue gerade einen standardkonformen sortierten, assoziativen Container auf Basis einer Skip List (Boost hat noch keine … hint, hint ^^). Die Klasse besitzt dieselbe Schnittstelle wie eine std::map. Und bei den Bound-Funktionen verzage ich gerade an der Implementierung, weil die vom Standard vorgeschriebenen Rückgabewerte einfach keinen Sinn ergeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434437</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434437</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Thu, 10 Jan 2008 16:32:44 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Thu, 10 Jan 2008 16:41:58 GMT]]></title><description><![CDATA[<p>Stell Dir vor, Du wolltest eine Range mit allen Elementen zwischen 8 und 17 haben. Dann kriegste mit lower_bound(8) das untere Ende der Range und mit upperbound(17) das obere Ende. Prima Namensgebung oder? <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/1434441</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434441</guid><dc:creator><![CDATA[Jester]]></dc:creator><pubDate>Thu, 10 Jan 2008 16:41:58 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Thu, 10 Jan 2008 16:56:42 GMT]]></title><description><![CDATA[<p>Zum Misverständnis führt hier wohl, dass du lower_bound so aufgefasst hast, dass du der Methode einen beliebigen Wert gibst und es einen Wert aus der Map sucht der als untere Grenze geeignet ist.<br />
Aber das Verhalten ist so zu verstehen wie Jester bereits erklärt hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434452</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434452</guid><dc:creator><![CDATA[lolz]]></dc:creator><pubDate>Thu, 10 Jan 2008 16:56:42 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Thu, 10 Jan 2008 16:57:48 GMT]]></title><description><![CDATA[<p>Mal angenommen der set hat die Elemente</p>
<pre><code>idx:  0   1   2   3   4   5   6
val:  1   5   9  11  15  20  22
</code></pre>
<p>dann liefern Dir die Aufrufe lower_bound(8) und upper_bound(17) die Iteratoren bei den Indizes<br />
2 und 5 - also das halboffene Intervall [a_2, a_5)<br />
Jetzt kannst Du dies durch einen set ersetzen, dessen kleinstes Element den Wert 8 und dessen größtes Element den Wert 17 hat. Beachte, dass das Intervall halboffen ist und der obere Wert nicht verändert wird.<br />
Also aus</p>
<pre><code>[..........)
idx:  0   1  2   3   4   5   6
val:  1   5  9  11  15  20  22
</code></pre>
<p>wird</p>
<pre><code>val:  1   5  [ 8 ... 17 ] 20  22
</code></pre>
<p>unter Einhaltung der Ordnung des sets</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434453</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434453</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Thu, 10 Jan 2008 16:57:48 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Thu, 10 Jan 2008 17:03:02 GMT]]></title><description><![CDATA[<p>Okay, mit Mengen gibt das Sinn. Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434456</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434456</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Thu, 10 Jan 2008 17:03:02 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Thu, 10 Jan 2008 18:02:44 GMT]]></title><description><![CDATA[<p>wo sowas auch evtl sinn geben könnte, ist mit einer map&lt;double, X&gt; - da double-werte dazu neigen, dass man sie verfehlt wenn man sie berechnet, bringen hier die bounds vielleicht was.</p>
<pre><code class="language-cpp">std::map&lt;double, std::string&gt; mymap;
double a = 1.0/6.0 + 1.0/3.0; //mit etwas pech gibt das eben nicht 0.5

mymap[a] = &quot;Hier steht 0.5, oder?&quot;. //vermutlich mymap[0.49999999999997] oder sowas
cout &lt;&lt; mymap[0.5] &lt;&lt; endl; // gibt wohl n leeren string.
for(/*...*/iterator it = mymap.lower_bound(0.5-epsilon); it != mymap.upper_bound(0.5+epsilon)) cout &lt;&lt; *it.second &lt;&lt; endl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1434494</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434494</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Thu, 10 Jan 2008 18:02:44 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Thu, 10 Jan 2008 18:45:09 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/5021">@Konrad</a> Rudolph: Mir hat das auch mal schlimme Kopfschmerzen bereitet ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434512</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434512</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 10 Jan 2008 18:45:09 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Fri, 11 Jan 2008 07:49:37 GMT]]></title><description><![CDATA[<p>Man sollte dabei natürlich beachten das es entegen dem was Werner Salomon schreibt sicht auf die Keys bezieht und nicht auf die Values. Da die Values ja nicht sortiert sind, macht es keinen Sinn dies auf second anzuwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434676</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434676</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Fri, 11 Jan 2008 07:49:37 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Fri, 11 Jan 2008 08:04:18 GMT]]></title><description><![CDATA[<p>Fellhuhn schrieb:</p>
<blockquote>
<p>Man sollte dabei natürlich beachten das es entegen dem was Werner Salomon schreibt sicht auf die Keys bezieht und nicht auf die Values. Da die Values ja nicht sortiert sind, macht es keinen Sinn dies auf second anzuwenden.</p>
</blockquote>
<p>Ich glaube, Werner meint schon das richtige und die Indizes sind nur zur Veranschaulichung der Position. Mein Beispiel war ja auch mit std::set, da gibt's keine Werte, nur Schlüssel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434680</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434680</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Fri, 11 Jan 2008 08:04:18 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Fri, 11 Jan 2008 08:17:54 GMT]]></title><description><![CDATA[<p>Mit set kommt es hin, sein Beispiel sieht aber eben mehr nach einer Map aus. Deswegen wollte ich das noch einmal erwähnen. <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/1434689</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434689</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Fri, 11 Jan 2008 08:17:54 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Fri, 11 Jan 2008 08:36:24 GMT]]></title><description><![CDATA[<p>Fellhuhn schrieb:</p>
<blockquote>
<p>Mit set kommt es hin, sein Beispiel sieht aber eben mehr nach einer Map aus. Deswegen wollte ich das noch einmal erwähnen. <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>
</blockquote>
<p>Er erwähnt aber explizit &quot;set&quot;. Und das im ersten Satz. <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/1434704</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434704</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Fri, 11 Jan 2008 08:36:24 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Fri, 11 Jan 2008 09:27:00 GMT]]></title><description><![CDATA[<p>Kleinigkeiten! <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1434735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434735</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Fri, 11 Jan 2008 09:27:00 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Fri, 11 Jan 2008 15:02:33 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>mir fällt gerade auf: Eure Erklärung ist fein, aber leider „versagt“ sie, sobald man zu 'equal_range' kommt. Der Standard definiert den Rückgabewert von <code>equal_range(k)</code> als <code>make_pair(lower_bound(k), upper_bound(k))</code> .</p>
<p>Für Multi-Map-Container mag das sinnvoll sein, aber wieso ist die Methode auch in Unique-Map-Containers vorhanden, und nimmt nur einen Parameter an (wenn sie zwei annähme, wäre sie sinnvoller)?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434938</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434938</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Fri, 11 Jan 2008 15:02:33 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Fri, 11 Jan 2008 15:16:30 GMT]]></title><description><![CDATA[<p>was versagt denn da? Du kriegst alle Elemente, x für die weder x&lt;k noch k&lt;x gilt. Die also bezüglich Deiner Ordnung in etwa als &quot;gleich k&quot; einzustufen sind.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434945</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434945</guid><dc:creator><![CDATA[Jester]]></dc:creator><pubDate>Fri, 11 Jan 2008 15:16:30 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Fri, 11 Jan 2008 15:17:54 GMT]]></title><description><![CDATA[<p>Jester schrieb:</p>
<blockquote>
<p>was versagt denn da? Du kriegst alle Elemente, x für die weder x&lt;k noch k&lt;x gilt. Die also bezüglich Deiner Ordnung in etwa als &quot;gleich k&quot; einzustufen sind.</p>
</blockquote>
<p>Eben. <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="😉"
    /> Da kann ich auch gleich 'find' aufrufen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434948</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434948</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Fri, 11 Jan 2008 15:17:54 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Fri, 11 Jan 2008 15:40:41 GMT]]></title><description><![CDATA[<p>Konrad Rudolph schrieb:</p>
<blockquote>
<p>Jester schrieb:</p>
<blockquote>
<p>was versagt denn da? Du kriegst alle Elemente, x für die weder x&lt;k noch k&lt;x gilt. Die also bezüglich Deiner Ordnung in etwa als &quot;gleich k&quot; einzustufen sind.</p>
</blockquote>
<p>Eben. <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="😉"
    /> Da kann ich auch gleich 'find' aufrufen.</p>
</blockquote>
<p>Allerdings mit dem Unterschied, dass du mit lower_bound gleich einen Iterator hast, den du zum Einfügen verwenden kannst, falls das Element fehlt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434962</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434962</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Fri, 11 Jan 2008 15:40:41 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Fri, 11 Jan 2008 15:42:59 GMT]]></title><description><![CDATA[<p>für map und set ist find und equal_range recht ähnlich, ja, bzw. letzteres erscheint wenig sinnvoll. Das gibts wohl hauptsächlich aus Kompatibilitätsgründen zu multimap/multiset bzw. weils schneller ist (ca. doppelt so schnell) wie wenn man lower_bound(k) und upper_bound(k) per hand aufrufen muss.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434964</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434964</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Fri, 11 Jan 2008 15:42:59 GMT</pubDate></item><item><title><![CDATA[Reply to map::lower_bound on Fri, 11 Jan 2008 15:57:54 GMT]]></title><description><![CDATA[<p>Okay, vielen Dank. Ich denke, dann ist alles klar. Die Implementierung dieser Funktionen ist ja sowieso trivial.</p>
<p>Mir zickt nur gerade meine Iterator-Klasse rum. Sieht wohl doch so aus, als müsste ich sie zweimal identisch implementieren: als 'iterator' und 'const_iterator'. Ba.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1434972</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1434972</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Fri, 11 Jan 2008 15:57:54 GMT</pubDate></item></channel></rss>