<?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[Set - allocator?]]></title><description><![CDATA[<p>Ich will gut 60 Strukturen speichern wobei diese über eine Zahl identifiziert werden welche von 1-255 gehen kann. Für eine gute zugriffszeit denke ich sollte ein Set passend sein.</p>
<pre><code class="language-cpp">struct element{
  unsigned char id;
  unsigned int count;
  bool operator&lt;(const element&amp; secondElement){
    return id&lt;secondElement.id;
  }
}

set&lt;element&gt; countElements;
</code></pre>
<p>Mein problem ist nun das ich trotz Google und Suchfunktion nicht herausgefunden habe wie ich den Key für die Set Identifikation anpassen kann. Der Key soll in diesem falle die id der entsprechenden Struktur sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/196258/set-allocator</link><generator>RSS for Node</generator><lastBuildDate>Wed, 30 Sep 2026 09:09:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196258.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 27 Oct 2007 13:59:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Set - allocator? on Sat, 27 Oct 2007 13:59:15 GMT]]></title><description><![CDATA[<p>Ich will gut 60 Strukturen speichern wobei diese über eine Zahl identifiziert werden welche von 1-255 gehen kann. Für eine gute zugriffszeit denke ich sollte ein Set passend sein.</p>
<pre><code class="language-cpp">struct element{
  unsigned char id;
  unsigned int count;
  bool operator&lt;(const element&amp; secondElement){
    return id&lt;secondElement.id;
  }
}

set&lt;element&gt; countElements;
</code></pre>
<p>Mein problem ist nun das ich trotz Google und Suchfunktion nicht herausgefunden habe wie ich den Key für die Set Identifikation anpassen kann. Der Key soll in diesem falle die id der entsprechenden Struktur sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393058</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393058</guid><dc:creator><![CDATA[michael8]]></dc:creator><pubDate>Sat, 27 Oct 2007 13:59:15 GMT</pubDate></item><item><title><![CDATA[Reply to Set - allocator? on Sat, 27 Oct 2007 15:01:55 GMT]]></title><description><![CDATA[<p>Du setzt nicht die Identifikation fest sondern die kleiner-gleich-Relation. Die wird als Funktor per Template-Argument übergeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393093</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393093</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Sat, 27 Oct 2007 15:01:55 GMT</pubDate></item><item><title><![CDATA[Reply to Set - allocator? on Sat, 27 Oct 2007 15:03:28 GMT]]></title><description><![CDATA[<p>Zusatz:</p>
<p>folgender Code würde das z.B. machen:</p>
<pre><code class="language-cpp">struct ltr { // ltr = lower than relation
    bool operator ()(element const&amp; lhs, element const&amp; rhs) { return lhs &lt; rhs; }
};

std::set&lt;element, ltr&gt; myset;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1393095</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393095</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Sat, 27 Oct 2007 15:03:28 GMT</pubDate></item><item><title><![CDATA[Reply to Set - allocator? on Sat, 27 Oct 2007 15:22:35 GMT]]></title><description><![CDATA[<p>Konrad Rudolph schrieb:</p>
<blockquote>
<p>Du setzt nicht die Identifikation fest sondern die kleiner-gleich-Relation. Die wird als Funktor per Template-Argument übergeben.</p>
</blockquote>
<p>Ach so, ich dachte es wird beides benötigt. Dann wird die Identifikation ob das Element bereits existiert auch über die kleiner-gleich Relation ermittelt.<br />
Das heißt doch aber das Einfügeoperationen genau wie die Suche O(log(n)) haben.?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393110</guid><dc:creator><![CDATA[michael8]]></dc:creator><pubDate>Sat, 27 Oct 2007 15:22:35 GMT</pubDate></item><item><title><![CDATA[Reply to Set - allocator? on Sat, 27 Oct 2007 15:37:22 GMT]]></title><description><![CDATA[<p>michael8 schrieb:</p>
<blockquote>
<p>Konrad Rudolph schrieb:</p>
<blockquote>
<p>Du setzt nicht die Identifikation fest sondern die kleiner-gleich-Relation. Die wird als Funktor per Template-Argument übergeben.</p>
</blockquote>
<p>Ach so, ich dachte es wird beides benötigt. Dann wird die Identifikation ob das Element bereits existiert auch über die kleiner-gleich Relation ermittelt.<br />
Das heißt doch aber das Einfügeoperationen genau wie die Suche O(log(n)) haben.?</p>
</blockquote>
<p>Ja haben sie, das hat aber mit der Identifikation des Elements nichts zu tun sondern mit dem internen Aufbau der Datenstruktur als Suchbaum (üblicherweise ein Rot-Schwarz-Baum).</p>
<p>/EDIT: Die Gleichheits-Operation wird für einen Suchbaum übrigens in der Tat nicht benötigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393128</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393128</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Sat, 27 Oct 2007 15:37:22 GMT</pubDate></item><item><title><![CDATA[Reply to Set - allocator? on Sat, 27 Oct 2007 17:19:43 GMT]]></title><description><![CDATA[<p>Ok, danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1393181</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1393181</guid><dc:creator><![CDATA[michael8]]></dc:creator><pubDate>Sat, 27 Oct 2007 17:19:43 GMT</pubDate></item></channel></rss>