<?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[deque container performance ??]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>Warum besteht ein performance unterschied wenn man elemente am anfangs eines deque container einfuegt und am ende eines deque containers? Wo koennte ich hilfreiches Material zu diesem Thema finden?</p>
<p>mfg<br />
Daniel</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/138510/deque-container-performance</link><generator>RSS for Node</generator><lastBuildDate>Sun, 30 Aug 2026 12:25:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/138510.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 26 Feb 2006 23:11:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to deque container performance ?? on Sun, 26 Feb 2006 23:11:26 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>Warum besteht ein performance unterschied wenn man elemente am anfangs eines deque container einfuegt und am ende eines deque containers? Wo koennte ich hilfreiches Material zu diesem Thema finden?</p>
<p>mfg<br />
Daniel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1003777</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1003777</guid><dc:creator><![CDATA[Endurance]]></dc:creator><pubDate>Sun, 26 Feb 2006 23:11:26 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Sun, 26 Feb 2006 23:13:32 GMT]]></title><description><![CDATA[<p>Schau doch in den Sourcecode deiner STL.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1003778</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1003778</guid><dc:creator><![CDATA[............]]></dc:creator><pubDate>Sun, 26 Feb 2006 23:13:32 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Sun, 26 Feb 2006 23:16:13 GMT]]></title><description><![CDATA[<p>Muss nicht so sein. Der Standard schreibt ja nicht vor wie man die Klassen implementieren muss.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1003779</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1003779</guid><dc:creator><![CDATA[Kenner der STL]]></dc:creator><pubDate>Sun, 26 Feb 2006 23:16:13 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Sun, 26 Feb 2006 23:21:58 GMT]]></title><description><![CDATA[<p>Da gibts doch sicherlich schon Analysen zu oder? Bei google hab ich nichts gefunden, da wurden halt nur alle Container miteinander verglichen.</p>
<p>Danke fuer die Hilfe!<br />
Daniel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1003780</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1003780</guid><dc:creator><![CDATA[Endurance]]></dc:creator><pubDate>Sun, 26 Feb 2006 23:21:58 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Sun, 26 Feb 2006 23:32:16 GMT]]></title><description><![CDATA[<p>Wie kommst du überhaupt darauf das es langsamer ist vorne einzufügen? Hast du Test gemacht? Wenn ja dann zeig die uns doch mal...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1003785</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1003785</guid><dc:creator><![CDATA[hmmmmmmmm]]></dc:creator><pubDate>Sun, 26 Feb 2006 23:32:16 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Sun, 26 Feb 2006 23:39:27 GMT]]></title><description><![CDATA[<p>Wenn ich nen deque v hab und 1000000 elemente am ende einfuege, dann dauert es genau 2.679s.</p>
<pre><code class="language-cpp">for (int a=1; a&lt;=d; a++)
v.insert(v.end(),a);
</code></pre>
<p>d=1000000</p>
<p>Wenn ich 1000000 elemente am anfang einfuege dauert es 3.097s</p>
<pre><code class="language-cpp">for (int a=1; a&lt;=d; a++)
v.insert(v.begin(),a);
</code></pre>
<p>d=1000000</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1003788</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1003788</guid><dc:creator><![CDATA[Endurance]]></dc:creator><pubDate>Sun, 26 Feb 2006 23:39:27 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 00:00:15 GMT]]></title><description><![CDATA[<p>Wie misst du die Zeit?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1003798</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1003798</guid><dc:creator><![CDATA[hmmmmmmmm]]></dc:creator><pubDate>Mon, 27 Feb 2006 00:00:15 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 04:38:11 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">int main( )
{ LARGE_INTEGER LI1,LI2,LIF;             
QueryPerformanceFrequency(&amp;LIF);
double number = (double)LIF.HighPart * UINT_MAX + (double)LIF.LowPart;
double dt, fq = 1.0/number;
int f = LIF.LowPart;
vector&lt;int&gt; v;
QueryPerformanceCounter(&amp;LI1);   
for (int a=1; a&lt;=100000; a++)    //irgend ein container auffuellen
v.insert(v.begin(),a);
QueryPerformanceCounter(&amp;LI2);   
dt = ( ( (double)(LI2.HighPart)*UINT_MAX + (double)LI2.LowPart )
- ( (double)(LI1.HighPart)*UINT_MAX + (double)LI1.LowPart ) )*fq;
cout &lt;&lt; &quot;\tfinished with time &quot; &lt;&lt; dt &lt;&lt; endl;
return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1003843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1003843</guid><dc:creator><![CDATA[Endurance]]></dc:creator><pubDate>Mon, 27 Feb 2006 04:38:11 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 07:31:03 GMT]]></title><description><![CDATA[<p>Hmm, du verwendest in deiner Messung keine deque, sondern einen Vektor (und der ist bei Insert's am Anfang nicht besonders performant) <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/1003868</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1003868</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 27 Feb 2006 07:31:03 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 08:41:35 GMT]]></title><description><![CDATA[<p>Endurance schrieb:</p>
<blockquote>
<p>Warum besteht ein performance unterschied wenn man elemente am anfangs eines deque container einfuegt und am ende eines deque containers?</p>
</blockquote>
<p>Die Garantie, die der C++-Standard dir gibt, ist dass das Einfügen in ein Deque am Anfang wie am Ende konstante Zeit benötigt - sofern keine Reallokation des Speichers anfällt. Konstant heißt: nicht von der Anzahl der enthaltenen Elemente abhängig. Es heißt aber nicht, dass das Einfügen am Anfang wie am Ende gleich-schnell sein muss.</p>
<p>Informationen dazu findest zu z.B. im Stroustrup. Das wird in den Kapiteln über die verschiedenen Container-Klassen recht genau behandelt.</p>
<p>Falls du dir die Zeitunterschiede nicht erklären kannst - versuch es doch mal selbst und gleich-schnell zu implementieren <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="😉"
    /> (oder zumindest die Überlegung anstellen wie du es machen würdest)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1003902</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1003902</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Mon, 27 Feb 2006 08:41:35 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 11:24:46 GMT]]></title><description><![CDATA[<p>7H3 N4C3R schrieb:</p>
<blockquote>
<p>Die Garantie, die der C++-Standard dir gibt, ist dass das Einfügen in ein Deque am Anfang wie am Ende konstante Zeit benötigt - sofern keine Reallokation des Speichers anfällt.</p>
</blockquote>
<p>allerdings garantiert der standard für deque gerade, dass beim einfügen am anfang oder ende NIEMALS eine reallokation stattfindet.<br />
auch ist das konzept der (amortisiert) konstanten zeit ist etwas anders - es heisst nicht <em>soweit</em> keine reallokation stattfindet sondern <em>trotzdem</em> eine reallokation stattfinden kann. nur deshalb muss std::vector zwingend eine expotentielle wachstumsfunktion benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1003990</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1003990</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 27 Feb 2006 11:24:46 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 12:09:32 GMT]]></title><description><![CDATA[<p>Ups, ich habe mich im Wort vertan. Nicht Reallokation, sondern allgemein Allokation.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004020</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004020</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Mon, 27 Feb 2006 12:09:32 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 15:27:20 GMT]]></title><description><![CDATA[<p>Was ist denn Stroustrup, und wo finde ich den, ihn, das???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004304</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004304</guid><dc:creator><![CDATA[Endurance]]></dc:creator><pubDate>Mon, 27 Feb 2006 15:27:20 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 15:28:22 GMT]]></title><description><![CDATA[<p>Endurance schrieb:</p>
<blockquote>
<p>Was ist denn Stroustrup, und wo finde ich den, ihn, das???</p>
</blockquote>
<p>Google.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004305</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004305</guid><dc:creator><![CDATA[dumm?]]></dc:creator><pubDate>Mon, 27 Feb 2006 15:28:22 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 15:31:49 GMT]]></title><description><![CDATA[<p>Ach nae, google.<br />
Wenn ich Stroustrup in google eingebe kommen 1000000000000000000 seiten mit allen moeglichen Sachen. Gibts da keine genaue quelle, wo uber die ST container peformance gesprochen wird?</p>
<p>Daniel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004310</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004310</guid><dc:creator><![CDATA[Endurance]]></dc:creator><pubDate>Mon, 27 Feb 2006 15:31:49 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 15:34:13 GMT]]></title><description><![CDATA[<p>klick den ersten link an. dann kommst du auf die seite vom erfinder von c++. der hat ein paar bücher geschrieben. und davon sollste dir &quot;The C++ Programming Language&quot; kaufen. gibts auch auf deutsch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004313</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004313</guid><dc:creator><![CDATA[dumm?]]></dc:creator><pubDate>Mon, 27 Feb 2006 15:34:13 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 15:36:15 GMT]]></title><description><![CDATA[<p>Ok mach ich ma, aber lieber in engl...... meine Kurse sind auch in engl.</p>
<p>Hat denn keiner nen Hinweis wo ich ne antwort auf meine Frage bekomme, ausser bei Stroustrup??</p>
<p>Daniel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004317</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004317</guid><dc:creator><![CDATA[Endurance]]></dc:creator><pubDate>Mon, 27 Feb 2006 15:36:15 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 15:39:37 GMT]]></title><description><![CDATA[<p>Warum benutzt du in deinem Code std::vector aber fragst dann nach std::deque? Irgendwas stimmt doch da nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004325</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004325</guid><dc:creator><![CDATA[v]]></dc:creator><pubDate>Mon, 27 Feb 2006 15:39:37 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 15:48:53 GMT]]></title><description><![CDATA[<p>Weil ich mehrere Aufgaben bewaeltigen muss. Der code ist nen Standard code wo man timen kann wie lange es dauert einen bestimmten Container aufzufuellen. Ich hab 8 Aufgaben, und eine davon fragt halt wieso ein performance unterschied besteht wenn man Elemnte am Anfang und am Ende einer deque einfuegt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004346</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004346</guid><dc:creator><![CDATA[Endurancw]]></dc:creator><pubDate>Mon, 27 Feb 2006 15:48:53 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 15:50:36 GMT]]></title><description><![CDATA[<p>Das ist dann wohl eine Scherzfrage. Es besteht nämlich kein Performance-Unterschied.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004348</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004348</guid><dc:creator><![CDATA[Kenner der Scherzfragen]]></dc:creator><pubDate>Mon, 27 Feb 2006 15:50:36 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 18:05:44 GMT]]></title><description><![CDATA[<p>Ok das kann natuerlich auch sein, aber warum bekomm ich dann andere ergebnisse?<br />
Versuch mal meinen timing code mit 6000000 elementen die du mit insert in eine deque einfuegst: Einmal mit</p>
<pre><code class="language-cpp">v.insert(v.end(), a)
</code></pre>
<p>und einmal mit</p>
<pre><code class="language-cpp">v.insert(begin(), a)
</code></pre>
<p>Je groesser die Anzahl der Elemente, desto groesser is der unterschied.<br />
Das muss irgendwas mit der Speicherreservierung zu tun haben, oder wie eine deque die iterators hin und her schiebt wenn man neue elemente einfuegt.</p>
<p>Daniel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004494</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004494</guid><dc:creator><![CDATA[Endurance]]></dc:creator><pubDate>Mon, 27 Feb 2006 18:05:44 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 18:06:58 GMT]]></title><description><![CDATA[<p>sorry,</p>
<pre><code class="language-cpp">v.insert(v.begin(),a)
</code></pre>
<p>meinte ich, NICHT</p>
<pre><code class="language-cpp">v.insert(begin(),a)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1004497</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004497</guid><dc:creator><![CDATA[Endurance]]></dc:creator><pubDate>Mon, 27 Feb 2006 18:06:58 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 18:10:53 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>auch ist das konzept der (amortisiert) konstanten zeit ist etwas anders - es heisst nicht <em>soweit</em> keine reallokation stattfindet sondern <em>trotzdem</em> eine reallokation stattfinden kann. nur deshalb muss std::vector zwingend eine expotentielle wachstumsfunktion benutzen.</p>
</blockquote>
<p>Huh? Amortisiert konstant heißt doch: im Mittel konstant. Wenn aber eine Allokation anfällt, dann kann es langsamer sein (n Elemente umkopieren kostet O(n), auch wenn es im Schnitt wieder nur O(1) ist). Wenn ich Deine Aussage hier richtig lese behauptest Du aber gerade das Gegenteil.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004504</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004504</guid><dc:creator><![CDATA[Jester]]></dc:creator><pubDate>Mon, 27 Feb 2006 18:10:53 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 18:40:50 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void push_front(const _Ty&amp; _Val)
	{	// insert element at beginning

#if _HAS_ITERATOR_DEBUGGING
	this-&gt;_Orphan_all();
#endif /* _HAS_ITERATOR_DEBUGGING */

	if (_Myoff % _DEQUESIZ == 0
		&amp;&amp; _Mapsize &lt;= (_Mysize + _DEQUESIZ) / _DEQUESIZ)
		_Growmap(1);
	size_type _Newoff = _Myoff != 0 ? _Myoff
		: _Mapsize * _DEQUESIZ;
	size_type _Block = --_Newoff / _DEQUESIZ;
	if (_Map[_Block] == 0)
		_Map[_Block] = this-&gt;_Alval.allocate(_DEQUESIZ);
	this-&gt;_Alval.construct(_Map[_Block] + _Newoff % _DEQUESIZ, _Val);
	_Myoff = _Newoff;
	++_Mysize;
	}

void push_back(const _Ty&amp; _Val)
	{	// insert element at end

#if _HAS_ITERATOR_DEBUGGING
	this-&gt;_Orphan_all();
#endif /* _HAS_ITERATOR_DEBUGGING */

	if ((_Myoff + _Mysize) % _DEQUESIZ == 0
		&amp;&amp; _Mapsize &lt;= (_Mysize + _DEQUESIZ) / _DEQUESIZ)
		_Growmap(1);
	size_type _Newoff = _Myoff + _Mysize;
	size_type _Block = _Newoff / _DEQUESIZ;
	if (_Mapsize &lt;= _Block)
		_Block -= _Mapsize;
	if (_Map[_Block] == 0)
		_Map[_Block] = this-&gt;_Alval.allocate(_DEQUESIZ);
	this-&gt;_Alval.construct(_Map[_Block] + _Newoff % _DEQUESIZ, _Val);
	++_Mysize;
	}
</code></pre>
<p>sind kleine unterschiede zu sehen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004538</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004538</guid><dc:creator><![CDATA[quellcode.]]></dc:creator><pubDate>Mon, 27 Feb 2006 18:40:50 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 19:10:34 GMT]]></title><description><![CDATA[<p>Cool, is das der Quellcode der deque Class??<br />
Wie gesagt ich benutze ja insert, nicht push_front und push_back, also kann ich glaube ich mit dem code nich das meiste anfangen. Aber selbst wenn ich push_font verwenden wuerde haette ich glaube ich so meine Probleme mit dem code.</p>
<p>Daniel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004564</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004564</guid><dc:creator><![CDATA[Endurance]]></dc:creator><pubDate>Mon, 27 Feb 2006 19:10:34 GMT</pubDate></item><item><title><![CDATA[Reply to deque container performance ?? on Mon, 27 Feb 2006 19:16:09 GMT]]></title><description><![CDATA[<p>Der Quellcode stammt aus Visual Studio 2005. Einfach die Datei &quot;deque&quot; öffnen, da steht alles drin.</p>
<p>Bei insert werden diese Funktionen aufgerufen.</p>
<pre><code class="language-cpp">if(iterator == begin())
{
    push_front(...);
}
else if(iterator == end())
{
    push_back(...);
}
else
{
    ...
}
</code></pre>
<p>Ich verstehe den Code auch nicht, da muss man sich schon länger mit beschäftigen. Aber versuch doch mal selbst eine Deque Klasse zu schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1004567</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1004567</guid><dc:creator><![CDATA[quellcode.]]></dc:creator><pubDate>Mon, 27 Feb 2006 19:16:09 GMT</pubDate></item></channel></rss>