<?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[Frage zu std::list]]></title><description><![CDATA[<p>Ich hab mir hier -&gt; <a href="http://www.cplusplus.com/reference/stl/list/" rel="nofollow">http://www.cplusplus.com/reference/stl/list/</a> gerade mal den Artikel zu std::list durchgelesen aber ein paar Sachen nicht richtig verstanden.</p>
<blockquote>
<p>List containers are implemented as doubly-linked lists;</p>
</blockquote>
<p>- Was ist eine doppelt verlinkte Liste?</p>
<blockquote>
<p>Doubly linked lists can store each of the elements they contain in different and unrelated storage locations.</p>
</blockquote>
<p>- Was sind beziehungslose storage locations?</p>
<p>std::list sieht im moment für mich so aus wie std::vector<br />
Naja, außer das ich bei std::list folgendes nicht machen kann:</p>
<pre><code class="language-cpp">cout&lt;&lt;mylist[0];
</code></pre>
<p>das mag der Compiler nicht.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;list&gt;
using namespace std;

int main()
{
list&lt;int&gt; mylist;
list&lt;int&gt;::iterator it;

mylist.push_back(1);
mylist.push_back(2);
mylist.push_back(3);

it = mylist.begin();
cout&lt;&lt;  *it &lt;&lt; endl;

cout&lt;&lt;mylist[0]&lt;&lt;endl; // 'operator+' ist im Typ 'list&lt;int,allocator&lt;int&gt; &gt;' für Argumente des Typs 'int' nicht implementiert
return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/309563/frage-zu-std-list</link><generator>RSS for Node</generator><lastBuildDate>Wed, 05 Aug 2026 03:34:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/309563.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 25 Oct 2012 13:11:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Frage zu std::list on Thu, 25 Oct 2012 13:11:54 GMT]]></title><description><![CDATA[<p>Ich hab mir hier -&gt; <a href="http://www.cplusplus.com/reference/stl/list/" rel="nofollow">http://www.cplusplus.com/reference/stl/list/</a> gerade mal den Artikel zu std::list durchgelesen aber ein paar Sachen nicht richtig verstanden.</p>
<blockquote>
<p>List containers are implemented as doubly-linked lists;</p>
</blockquote>
<p>- Was ist eine doppelt verlinkte Liste?</p>
<blockquote>
<p>Doubly linked lists can store each of the elements they contain in different and unrelated storage locations.</p>
</blockquote>
<p>- Was sind beziehungslose storage locations?</p>
<p>std::list sieht im moment für mich so aus wie std::vector<br />
Naja, außer das ich bei std::list folgendes nicht machen kann:</p>
<pre><code class="language-cpp">cout&lt;&lt;mylist[0];
</code></pre>
<p>das mag der Compiler nicht.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;list&gt;
using namespace std;

int main()
{
list&lt;int&gt; mylist;
list&lt;int&gt;::iterator it;

mylist.push_back(1);
mylist.push_back(2);
mylist.push_back(3);

it = mylist.begin();
cout&lt;&lt;  *it &lt;&lt; endl;

cout&lt;&lt;mylist[0]&lt;&lt;endl; // 'operator+' ist im Typ 'list&lt;int,allocator&lt;int&gt; &gt;' für Argumente des Typs 'int' nicht implementiert
return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2263916</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263916</guid><dc:creator><![CDATA[c**]]></dc:creator><pubDate>Thu, 25 Oct 2012 13:11:54 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu std::list on Thu, 25 Oct 2012 13:14:50 GMT]]></title><description><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Doubly_linked_list" rel="nofollow">http://en.wikipedia.org/wiki/Doubly_linked_list</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263917</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263917</guid><dc:creator><![CDATA[mazal]]></dc:creator><pubDate>Thu, 25 Oct 2012 13:14:50 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu std::list on Thu, 25 Oct 2012 16:34:07 GMT]]></title><description><![CDATA[<p>Jeder Knoten entählt einen Zeiger auf seinen Vorgänger und Nachfolger. Bei einer einfach verketteten Liste wäre es nur der Vorgänger.</p>
<blockquote>
<p>Was sind beziehungslose storage locations?</p>
</blockquote>
<p>Bei einem Array lägen alle Elemente normalerweise hintereinander im Speicher, bei einer Liste (nicht nur bei doppelten, auch bei Bäumen u.ä.) liegen die Elemente irgendwo im Speicher und die Liste wird dadurch verkettet, dass jedes Element wie schon gesagt Zeiger auf Vorgänger bzw. Nachfolger enthält.<br />
Grob gesagt hat die Liste dort, wo das Array die einzelnen Elemente hat ihre Knoten.</p>
<blockquote>
<p>das mag der Compiler nicht.</p>
</blockquote>
<p>Nein, Listen/Bäume implementieren keinen sog. random-Access-Zugriff. Eine Liste hat auch von der implementierung wenig mit einem Array zu tun. Aber das zu erklären dauert hier zu lange, guck dir den Wikipedia Artikel an.<br />
Bei Fragen kannste ja immernoch fragen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2264004</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2264004</guid><dc:creator><![CDATA[Der Tobi]]></dc:creator><pubDate>Thu, 25 Oct 2012 16:34:07 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu std::list on Thu, 25 Oct 2012 16:35:29 GMT]]></title><description><![CDATA[<p>Edit: bei einer einfachen wäre es nur der Nachfolger.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2264005</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2264005</guid><dc:creator><![CDATA[Der Tobi]]></dc:creator><pubDate>Thu, 25 Oct 2012 16:35:29 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu std::list on Thu, 25 Oct 2012 18:16:15 GMT]]></title><description><![CDATA[<p>Ungefaehr so saehe eine minimale Implementierung einer verketteten Liste aus:</p>
<pre><code class="language-cpp">struct Liste {
    Liste* Naechste;
};
</code></pre>
<p>Eine doppelt-verkettete Liste:</p>
<pre><code class="language-cpp">struct Liste {
    Liste* Naechste;
    Liste* Letzte;
};
</code></pre>
<p>Einzelne Elemente mit dem Indexoperator [] aufzurufen ist schiwerig, da man alle Elemente durchlaufen muss, bis man das gesuchte Element findet. Daher mag das dein Compiler auch nicht. <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 />
Moechte man z.B. das dritte Elemente einer Liste aufrufen, muesste man sowas machen:</p>
<pre><code class="language-cpp">Liste* Dritte = Erste-&gt;Naechste-&gt;Naechste;
</code></pre>
<p>Ein Vector hingegen ist nur eine Abstraktion von einem einfachen Array mit dem Vorteil, dass sich der Benutzer nicht mehr um den Speichermanagment kuemmern muss.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2264041</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2264041</guid><dc:creator><![CDATA[Code Beispiele]]></dc:creator><pubDate>Thu, 25 Oct 2012 18:16:15 GMT</pubDate></item></channel></rss>